Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index e19af1cd5cd3dd265633660544b675246588c17b..cee215f996aa42209bd9bac97492225d5ee50ce7 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -656,6 +656,9 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, |
| scope->set_start_position(0); |
| scope->set_end_position(source->length()); |
| FunctionState function_state(this, scope, isolate()); |
| + int ast_nodes_before = isolate()->ast_node_count(); |
|
Kevin Millikin (Chromium)
2011/11/28 12:11:59
It seems overly complicated to use the global coun
ulan
2011/11/29 14:06:52
Done.
|
| + int non_primitive_ast_nodes_before = |
| + isolate()->non_primitive_ast_node_count(); |
|
Kevin Millikin (Chromium)
2011/11/28 12:11:59
There's no need to count them is there? If not, i
ulan
2011/11/29 14:06:52
Done.
|
| top_scope_->SetStrictModeFlag(info->strict_mode_flag()); |
| ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16); |
| bool ok = true; |
| @@ -669,6 +672,10 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, |
| CheckConflictingVarDeclarations(scope, &ok); |
| } |
| + int ast_nodes_added = isolate()->ast_node_count() - ast_nodes_before + 1; |
| + bool is_primitive = (isolate()->non_primitive_ast_node_count() - |
| + non_primitive_ast_nodes_before == 0); |
| + |
| if (ok) { |
| result = new(zone()) FunctionLiteral( |
| isolate(), |
| @@ -682,7 +689,9 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, |
| function_state.this_property_assignments(), |
| 0, |
| FunctionLiteral::ANONYMOUS_EXPRESSION, |
| - false); // Does not have duplicate parameters. |
| + false, // Does not have duplicate parameters. |
| + ast_nodes_added, |
| + is_primitive); |
| } else if (stack_overflow_) { |
| isolate()->StackOverflow(); |
| } |
| @@ -2183,7 +2192,7 @@ Statement* Parser::ParseWithStatement(ZoneStringList* labels, bool* ok) { |
| stmt = ParseStatement(labels, CHECK_OK); |
| with_scope->set_end_position(scanner().location().end_pos); |
| } |
| - return new(zone()) WithStatement(expr, stmt); |
| + return new(zone()) WithStatement(isolate(), expr, stmt); |
| } |
| @@ -2349,7 +2358,8 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
| // If we have both, create an inner try/catch. |
| ASSERT(catch_scope != NULL && catch_variable != NULL); |
| int index = current_function_state_->NextHandlerIndex(); |
| - TryCatchStatement* statement = new(zone()) TryCatchStatement(index, |
| + TryCatchStatement* statement = new(zone()) TryCatchStatement(isolate(), |
| + index, |
| try_block, |
| catch_scope, |
| catch_variable, |
| @@ -2365,7 +2375,8 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
| ASSERT(finally_block == NULL); |
| ASSERT(catch_scope != NULL && catch_variable != NULL); |
| int index = current_function_state_->NextHandlerIndex(); |
| - result = new(zone()) TryCatchStatement(index, |
| + result = new(zone()) TryCatchStatement(isolate(), |
| + index, |
| try_block, |
| catch_scope, |
| catch_variable, |
| @@ -2373,7 +2384,8 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
| } else { |
| ASSERT(finally_block != NULL); |
| int index = current_function_state_->NextHandlerIndex(); |
| - result = new(zone()) TryFinallyStatement(index, |
| + result = new(zone()) TryFinallyStatement(isolate(), |
| + index, |
| try_block, |
| finally_block); |
| // Combine the jump targets of the try block and the possible catch block. |
| @@ -3938,6 +3950,9 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name, |
| int materialized_literal_count; |
| int expected_property_count; |
| int handler_count = 0; |
| + int ast_node_count_before = isolate_->ast_node_count(); |
| + int non_primitive_ast_node_count_before = |
| + isolate_->non_primitive_ast_node_count(); |
| bool only_simple_this_property_assignments; |
| Handle<FixedArray> this_property_assignments; |
| bool has_duplicate_parameters = false; |
| @@ -4119,6 +4134,10 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name, |
| CheckConflictingVarDeclarations(scope, CHECK_OK); |
| } |
| + int ast_nodes_added = isolate_->ast_node_count() - ast_node_count_before + 1; |
| + bool is_primitive = (isolate_->non_primitive_ast_node_count() - |
| + non_primitive_ast_node_count_before == 0); |
| + |
| FunctionLiteral* function_literal = |
| new(zone()) FunctionLiteral(isolate(), |
| function_name, |
| @@ -4131,7 +4150,9 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name, |
| this_property_assignments, |
| num_parameters, |
| type, |
| - has_duplicate_parameters); |
| + has_duplicate_parameters, |
| + ast_nodes_added, |
| + is_primitive); |
| function_literal->set_function_token_position(function_token_position); |
| if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); |