summaryrefslogtreecommitdiff
path: root/deps/v8/src/parser.cc
diff options
context:
space:
mode:
authorAli Ijaz Sheikh <ofrobots@google.com>2015-10-12 16:16:21 -0700
committerAli Ijaz Sheikh <ofrobots@google.com>2015-10-14 11:20:35 -0700
commit770cd229f9638064b6f39b038b2140bbd6a7a543 (patch)
treee2a410ea6488c0ad8dba9276eb64fdf3a985f94a /deps/v8/src/parser.cc
parent972a0c851586ddde30f948d1ea8510f74e141f7c (diff)
downloadnode-new-770cd229f9638064b6f39b038b2140bbd6a7a543.tar.gz
deps: upgrade V8 to 4.6.85.25
Move up to the latest patch level from the V8 4.6 branch: https://github.com/v8/v8/compare/4.6.85.23...4.6.85.25 PR-URL: https://github.com/nodejs/node/pull/3351 Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/src/parser.cc')
-rw-r--r--deps/v8/src/parser.cc38
1 files changed, 36 insertions, 2 deletions
diff --git a/deps/v8/src/parser.cc b/deps/v8/src/parser.cc
index ecc6530135..2b6467ba3d 100644
--- a/deps/v8/src/parser.cc
+++ b/deps/v8/src/parser.cc
@@ -4135,10 +4135,44 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
}
}
if (!is_lazily_parsed) {
- body = ParseEagerFunctionBody(function_name, pos, formals, kind,
- function_type, CHECK_OK);
+ // Determine whether the function body can be discarded after parsing.
+ // The preconditions are:
+ // - Lazy compilation has to be enabled.
+ // - Neither V8 natives nor native function declarations can be allowed,
+ // since parsing one would retroactively force the function to be
+ // eagerly compiled.
+ // - The invoker of this parser can't depend on the AST being eagerly
+ // built (either because the function is about to be compiled, or
+ // because the AST is going to be inspected for some reason).
+ // - Because of the above, we can't be attempting to parse a
+ // FunctionExpression; even without enclosing parentheses it might be
+ // immediately invoked.
+ // - The function literal shouldn't be hinted to eagerly compile.
+ bool use_temp_zone =
+ FLAG_lazy && !allow_natives() && extension_ == NULL && allow_lazy() &&
+ function_type == FunctionLiteral::DECLARATION &&
+ eager_compile_hint != FunctionLiteral::kShouldEagerCompile;
+ // Open a new BodyScope, which sets our AstNodeFactory to allocate in the
+ // new temporary zone if the preconditions are satisfied, and ensures that
+ // the previous zone is always restored after parsing the body.
+ // For the purpose of scope analysis, some ZoneObjects allocated by the
+ // factory must persist after the function body is thrown away and
+ // temp_zone is deallocated. These objects are instead allocated in a
+ // parser-persistent zone (see parser_zone_ in AstNodeFactory).
+ {
+ Zone temp_zone;
+ AstNodeFactory::BodyScope inner(factory(), &temp_zone, use_temp_zone);
+
+ body = ParseEagerFunctionBody(function_name, pos, formals, kind,
+ function_type, CHECK_OK);
+ }
materialized_literal_count = function_state.materialized_literal_count();
expected_property_count = function_state.expected_property_count();
+ if (use_temp_zone) {
+ // If the preconditions are correct the function body should never be
+ // accessed, but do this anyway for better behaviour if they're wrong.
+ body = NULL;
+ }
}
// Parsing the body may change the language mode in our scope.