Commit c4e7992c authored by verwaest's avatar verwaest Committed by Commit bot

Add support to trace preparsing decisions

BUG=v8:5501

Review-Url: https://codereview.chromium.org/2424013002
Cr-Commit-Position: refs/heads/master@{#40383}
parent 0ef0d5b2
...@@ -830,6 +830,7 @@ DEFINE_BOOL(trace_maps, false, "trace map creation") ...@@ -830,6 +830,7 @@ DEFINE_BOOL(trace_maps, false, "trace map creation")
// parser.cc // parser.cc
DEFINE_BOOL(allow_natives_syntax, false, "allow natives syntax") DEFINE_BOOL(allow_natives_syntax, false, "allow natives syntax")
DEFINE_BOOL(trace_parse, false, "trace parsing and preparsing") DEFINE_BOOL(trace_parse, false, "trace parsing and preparsing")
DEFINE_BOOL(trace_preparse, false, "trace preparsing decisions")
DEFINE_BOOL(lazy_inner_functions, false, "enable lazy parsing inner functions") DEFINE_BOOL(lazy_inner_functions, false, "enable lazy parsing inner functions")
// simulator-arm.cc, simulator-arm64.cc and simulator-mips.cc // simulator-arm.cc, simulator-arm64.cc and simulator-mips.cc
......
...@@ -2696,13 +2696,23 @@ FunctionLiteral* Parser::ParseFunctionLiteral( ...@@ -2696,13 +2696,23 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
expected_property_count = function_state.expected_property_count(); expected_property_count = function_state.expected_property_count();
} }
if (use_temp_zone || is_lazy_top_level_function) { DCHECK(use_temp_zone || !is_lazy_top_level_function);
if (use_temp_zone) {
// If the preconditions are correct the function body should never be // If the preconditions are correct the function body should never be
// accessed, but do this anyway for better behaviour if they're wrong. // accessed, but do this anyway for better behaviour if they're wrong.
body = nullptr; body = nullptr;
scope->AnalyzePartially(&previous_zone_ast_node_factory); scope->AnalyzePartially(&previous_zone_ast_node_factory);
} }
if (FLAG_trace_preparse) {
PrintF(" [%s]: %i-%i %.*s\n",
is_lazy_top_level_function
? "Preparse no-resolution"
: (use_temp_zone ? "Preparse resolution" : "Full parse"),
scope->start_position(), scope->end_position(),
function_name->byte_length(), function_name->raw_data());
}
// Parsing the body may change the language mode in our scope. // Parsing the body may change the language mode in our scope.
language_mode = scope->language_mode(); language_mode = scope->language_mode();
......
...@@ -177,11 +177,19 @@ PreParser::Expression PreParser::ParseFunctionLiteral( ...@@ -177,11 +177,19 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind);
ValidateFormalParameters(language_mode, allow_duplicate_parameters, CHECK_OK); ValidateFormalParameters(language_mode, allow_duplicate_parameters, CHECK_OK);
int end_position = scanner()->location().end_pos;
if (is_strict(language_mode)) { if (is_strict(language_mode)) {
int end_position = scanner()->location().end_pos;
CheckStrictOctalLiteral(start_position, end_position, CHECK_OK); CheckStrictOctalLiteral(start_position, end_position, CHECK_OK);
CheckDecimalLiteralWithLeadingZero(start_position, end_position); CheckDecimalLiteralWithLeadingZero(start_position, end_position);
} }
function_scope->set_end_position(end_position);
if (FLAG_trace_preparse) {
PrintF(" [%s]: %i-%i\n",
track_unresolved_variables_ ? "Preparse resolution"
: "Preparse no-resolution",
function_scope->start_position(), function_scope->end_position());
}
return Expression::Default(); return Expression::Default();
} }
......
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