Fix: AstValueFactory must be internalized before ThrowPendingError.

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
This commit is contained in:
marja@chromium.org 2014-06-17 11:48:37 +00:00
parent 944e7f09d2
commit 3b53ba87c8
3 changed files with 24 additions and 1 deletions

View 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_; }

View 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_);

View 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");
}