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

Side by Side Diff: src/parser.cc

Issue 1399503002: Cherry-picked: Fixes for initial memory pressure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.6
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/ast.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/parser.h" 5 #include "src/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/ast-literal-reindexer.h" 9 #include "src/ast-literal-reindexer.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 4117 matching lines...) Expand 10 before | Expand all | Expand 10 after
4128 is_lazily_parsed = false; 4128 is_lazily_parsed = false;
4129 4129
4130 // This is probably an initialization function. Inform the compiler it 4130 // This is probably an initialization function. Inform the compiler it
4131 // should also eager-compile this function, and that we expect it to be 4131 // should also eager-compile this function, and that we expect it to be
4132 // used once. 4132 // used once.
4133 eager_compile_hint = FunctionLiteral::kShouldEagerCompile; 4133 eager_compile_hint = FunctionLiteral::kShouldEagerCompile;
4134 should_be_used_once_hint = true; 4134 should_be_used_once_hint = true;
4135 } 4135 }
4136 } 4136 }
4137 if (!is_lazily_parsed) { 4137 if (!is_lazily_parsed) {
4138 body = ParseEagerFunctionBody(function_name, pos, formals, kind, 4138 // Determine whether the function body can be discarded after parsing.
4139 function_type, CHECK_OK); 4139 // The preconditions are:
4140 // - Lazy compilation has to be enabled.
4141 // - Neither V8 natives nor native function declarations can be allowed,
4142 // since parsing one would retroactively force the function to be
4143 // eagerly compiled.
4144 // - The invoker of this parser can't depend on the AST being eagerly
4145 // built (either because the function is about to be compiled, or
4146 // because the AST is going to be inspected for some reason).
4147 // - Because of the above, we can't be attempting to parse a
4148 // FunctionExpression; even without enclosing parentheses it might be
4149 // immediately invoked.
4150 // - The function literal shouldn't be hinted to eagerly compile.
4151 bool use_temp_zone =
4152 FLAG_lazy && !allow_natives() && extension_ == NULL && allow_lazy() &&
4153 function_type == FunctionLiteral::DECLARATION &&
4154 eager_compile_hint != FunctionLiteral::kShouldEagerCompile;
4155 // Open a new BodyScope, which sets our AstNodeFactory to allocate in the
4156 // new temporary zone if the preconditions are satisfied, and ensures that
4157 // the previous zone is always restored after parsing the body.
4158 // For the purpose of scope analysis, some ZoneObjects allocated by the
4159 // factory must persist after the function body is thrown away and
4160 // temp_zone is deallocated. These objects are instead allocated in a
4161 // parser-persistent zone (see parser_zone_ in AstNodeFactory).
4162 {
4163 Zone temp_zone;
4164 AstNodeFactory::BodyScope inner(factory(), &temp_zone, use_temp_zone);
4165
4166 body = ParseEagerFunctionBody(function_name, pos, formals, kind,
4167 function_type, CHECK_OK);
4168 }
4140 materialized_literal_count = function_state.materialized_literal_count(); 4169 materialized_literal_count = function_state.materialized_literal_count();
4141 expected_property_count = function_state.expected_property_count(); 4170 expected_property_count = function_state.expected_property_count();
4171 if (use_temp_zone) {
4172 // If the preconditions are correct the function body should never be
4173 // accessed, but do this anyway for better behaviour if they're wrong.
4174 body = NULL;
4175 }
4142 } 4176 }
4143 4177
4144 // Parsing the body may change the language mode in our scope. 4178 // Parsing the body may change the language mode in our scope.
4145 language_mode = scope->language_mode(); 4179 language_mode = scope->language_mode();
4146 4180
4147 if (is_strong(language_mode) && IsSubclassConstructor(kind)) { 4181 if (is_strong(language_mode) && IsSubclassConstructor(kind)) {
4148 if (!function_state.super_location().IsValid()) { 4182 if (!function_state.super_location().IsValid()) {
4149 ReportMessageAt(function_name_location, 4183 ReportMessageAt(function_name_location,
4150 MessageTemplate::kStrongSuperCallMissing, 4184 MessageTemplate::kStrongSuperCallMissing,
4151 kReferenceError); 4185 kReferenceError);
(...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after
6042 Expression* Parser::SpreadCallNew(Expression* function, 6076 Expression* Parser::SpreadCallNew(Expression* function,
6043 ZoneList<v8::internal::Expression*>* args, 6077 ZoneList<v8::internal::Expression*>* args,
6044 int pos) { 6078 int pos) {
6045 args->InsertAt(0, function, zone()); 6079 args->InsertAt(0, function, zone());
6046 6080
6047 return factory()->NewCallRuntime( 6081 return factory()->NewCallRuntime(
6048 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 6082 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
6049 } 6083 }
6050 } // namespace internal 6084 } // namespace internal
6051 } // namespace v8 6085 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698