Commit c6d421ff authored by jochen's avatar jochen Committed by Commit bot

Introduce a separate FunctionLiteral ID for Eval

Top level SharedFunctionInfos will end up in a scripts SFI list, but
eval'd SFIs shouldn't. Separate IDs will allow for adding a
corresponding DCHECK.

BUG=v8:5589
R=marja@chromium.org

Review-Url: https://codereview.chromium.org/2533303006
Cr-Commit-Position: refs/heads/master@{#41421}
parent f8fec66f
...@@ -2550,7 +2550,7 @@ class FunctionLiteral final : public Expression { ...@@ -2550,7 +2550,7 @@ class FunctionLiteral final : public Expression {
kAccessorOrMethod kAccessorOrMethod
}; };
enum IdType { kIdTypeInvalid = -1, kIdTypeTopLevel = 0 }; enum IdType { kIdTypeEval = -2, kIdTypeInvalid = -1, kIdTypeTopLevel = 0 };
enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters }; enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters };
...@@ -3452,14 +3452,14 @@ class AstNodeFactory final BASE_EMBEDDED { ...@@ -3452,14 +3452,14 @@ class AstNodeFactory final BASE_EMBEDDED {
FunctionLiteral* NewScriptOrEvalFunctionLiteral( FunctionLiteral* NewScriptOrEvalFunctionLiteral(
DeclarationScope* scope, ZoneList<Statement*>* body, DeclarationScope* scope, ZoneList<Statement*>* body,
int materialized_literal_count, int expected_property_count, int materialized_literal_count, int expected_property_count,
int parameter_count) { int parameter_count, int function_literal_id) {
return new (zone_) FunctionLiteral( return new (zone_) FunctionLiteral(
zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope, zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope,
body, materialized_literal_count, expected_property_count, body, materialized_literal_count, expected_property_count,
parameter_count, parameter_count, FunctionLiteral::kAnonymousExpression, parameter_count, parameter_count, FunctionLiteral::kAnonymousExpression,
FunctionLiteral::kNoDuplicateParameters, FunctionLiteral::kNoDuplicateParameters,
FunctionLiteral::kShouldLazyCompile, 0, false, true, FunctionLiteral::kShouldLazyCompile, 0, false, true,
FunctionLiteral::kIdTypeTopLevel); function_literal_id);
} }
ClassLiteral::Property* NewClassLiteralProperty( ClassLiteral::Property* NewClassLiteralProperty(
......
...@@ -729,6 +729,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { ...@@ -729,6 +729,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
ParsingModeScope mode(this, allow_lazy_ ? PARSE_LAZILY : PARSE_EAGERLY); ParsingModeScope mode(this, allow_lazy_ ? PARSE_LAZILY : PARSE_EAGERLY);
ResetFunctionLiteralId(); ResetFunctionLiteralId();
DCHECK(info->function_literal_id() == FunctionLiteral::kIdTypeTopLevel || DCHECK(info->function_literal_id() == FunctionLiteral::kIdTypeTopLevel ||
info->function_literal_id() == FunctionLiteral::kIdTypeEval ||
info->function_literal_id() == FunctionLiteral::kIdTypeInvalid); info->function_literal_id() == FunctionLiteral::kIdTypeInvalid);
FunctionLiteral* result = NULL; FunctionLiteral* result = NULL;
...@@ -816,7 +817,9 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { ...@@ -816,7 +817,9 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
int parameter_count = parsing_module_ ? 1 : 0; int parameter_count = parsing_module_ ? 1 : 0;
result = factory()->NewScriptOrEvalFunctionLiteral( result = factory()->NewScriptOrEvalFunctionLiteral(
scope, body, function_state.materialized_literal_count(), scope, body, function_state.materialized_literal_count(),
function_state.expected_property_count(), parameter_count); function_state.expected_property_count(), parameter_count,
info->is_eval() ? FunctionLiteral::kIdTypeEval
: FunctionLiteral::kIdTypeTopLevel);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment