Fix: AstValueFactory must be internalized before ThrowPendingError.
authormarja@chromium.org <marja@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 17 Jun 2014 11:48:37 +0000 (11:48 +0000)
committermarja@chromium.org <marja@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 17 Jun 2014 11:48:37 +0000 (11:48 +0000)
R=rossberg@chromium.org
BUG=385193
LOG=N

Review URL: https://codereview.chromium.org/335373002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21872 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/ast-value-factory.h
src/parser.cc
test/cctest/test-parsing.cc

index 59efa58..7749b5c 100644 (file)
@@ -248,6 +248,9 @@ class AstValueFactory {
   const AstString* GetString(Handle<String> literal);
 
   void Internalize(Isolate* isolate);
+  bool IsInternalized() {
+    return isolate_ != NULL;
+  }
 
 #define F(name, str) \
   const AstString* name##_string() const { return name##_string_; }
index aa686a2..42d0949 100644 (file)
@@ -911,6 +911,7 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
       }
     }
 
+    ast_value_factory_->Internalize(isolate());
     if (ok) {
       result = factory()->NewFunctionLiteral(
           ast_value_factory_->empty_string(),
@@ -1031,6 +1032,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) {
   // Make sure the target stack is empty.
   ASSERT(target_stack_ == NULL);
 
+  ast_value_factory_->Internalize(isolate());
   if (result == NULL) {
     if (stack_overflow()) {
       isolate()->StackOverflow();
@@ -3884,6 +3886,7 @@ void Parser::RegisterTargetUse(Label* target, Target* stop) {
 
 
 void Parser::ThrowPendingError() {
+  ASSERT(ast_value_factory_->IsInternalized());
   if (has_pending_error_) {
     MessageLocation location(script_,
                              pending_error_location_.beg_pos,
@@ -4844,7 +4847,7 @@ bool Parser::Parse() {
     }
   }
   info()->SetFunction(result);
-  ast_value_factory_->Internalize(isolate());
+  ASSERT(ast_value_factory_->IsInternalized());
   // info takes ownership of ast_value_factory_.
   if (info()->ast_value_factory() == NULL) {
     info()->SetAstValueFactory(ast_value_factory_);
index bd6b06d..79b32e8 100644 (file)
@@ -2552,3 +2552,20 @@ TEST(FuncNameInferrerEscaped) {
   i::DeleteArray(two_byte_source);
   i::DeleteArray(two_byte_name);
 }
+
+
+TEST(RegressionLazyFunctionWithErrorWithArg) {
+  // The bug occurred when a lazy function had an error which requires a
+  // parameter (such as "unknown label" here). The error message was processed
+  // before the AstValueFactory containing the error message string was
+  // internalized.
+  v8::Isolate* isolate = CcTest::isolate();
+  v8::HandleScope scope(isolate);
+  LocalContext env;
+  i::FLAG_lazy = true;
+  i::FLAG_min_preparse_length = 0;
+  CompileRun("function this_is_lazy() {\n"
+             "  break p;\n"
+             "}\n"
+             "this_is_lazy();\n");
+}