Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Unified Diff: src/parsing/parser.cc

Issue 2156013002: Put FunctionLiterals into temp_zone too. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: code review (titzer@) Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index d0cf28a488d078a317c763be8f6a03038bae8289..7cac942e09e59544569c66563ea11b564d3b6a43 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -166,6 +166,27 @@ int ParseData::FunctionsSize() {
return static_cast<int>(Data()[PreparseDataConstants::kFunctionsSizeOffset]);
}
+// Helper for putting parts of the parse results into a temporary zone when
+// parsing inner function bodies.
+class DiscardableZoneScope {
+ public:
+ DiscardableZoneScope(Parser* parser, Zone* temp_zone, bool use_temp_zone)
+ : ast_node_factory_scope_(parser->factory(), temp_zone, use_temp_zone),
+ fni_(parser->ast_value_factory_, temp_zone),
+ parser_(parser),
+ prev_fni_(parser->fni_) {
+ if (use_temp_zone) {
+ parser_->fni_ = &fni_;
+ }
+ }
+ ~DiscardableZoneScope() { parser_->fni_ = prev_fni_; }
+
+ private:
+ AstNodeFactory::BodyScope ast_node_factory_scope_;
+ FuncNameInferrer fni_;
+ Parser* parser_;
+ FuncNameInferrer* prev_fni_;
+};
void Parser::SetCachedData(ParseInfo* info) {
if (compile_options_ == ScriptCompiler::kNoCompileOptions) {
@@ -4420,7 +4441,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
function_type == FunctionLiteral::kDeclaration &&
eager_compile_hint != FunctionLiteral::kShouldEagerCompile &&
!(FLAG_validate_asm && scope->asm_function());
- // Open a new BodyScope, which sets our AstNodeFactory to allocate in the
+ // Open a new zone scope, 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
@@ -4429,8 +4450,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
// parser-persistent zone (see parser_zone_ in AstNodeFactory).
{
Zone temp_zone(zone()->allocator());
- AstNodeFactory::BodyScope inner(factory(), &temp_zone, use_temp_zone);
-
+ DiscardableZoneScope(this, &temp_zone, use_temp_zone);
body = ParseEagerFunctionBody(function_name, pos, formals, kind,
function_type, CHECK_OK);
}
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698