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

Side by Side Diff: src/parser.cc

Issue 8677008: Relax inlining limits for simple leaf functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« src/hydrogen.cc ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 FunctionLiteral* result = NULL; 649 FunctionLiteral* result = NULL;
650 { Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE); 650 { Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE);
651 info->SetGlobalScope(scope); 651 info->SetGlobalScope(scope);
652 if (!info->is_global()) { 652 if (!info->is_global()) {
653 scope = Scope::DeserializeScopeChain(*info->calling_context(), scope); 653 scope = Scope::DeserializeScopeChain(*info->calling_context(), scope);
654 scope = NewScope(scope, EVAL_SCOPE); 654 scope = NewScope(scope, EVAL_SCOPE);
655 } 655 }
656 scope->set_start_position(0); 656 scope->set_start_position(0);
657 scope->set_end_position(source->length()); 657 scope->set_end_position(source->length());
658 FunctionState function_state(this, scope, isolate()); 658 FunctionState function_state(this, scope, isolate());
659 int ast_nodes_before = isolate()->ast_node_count();
660 int heavy_ast_nodes_before = isolate()->heavy_ast_node_count();
659 top_scope_->SetStrictModeFlag(info->strict_mode_flag()); 661 top_scope_->SetStrictModeFlag(info->strict_mode_flag());
660 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16); 662 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16);
661 bool ok = true; 663 bool ok = true;
662 int beg_loc = scanner().location().beg_pos; 664 int beg_loc = scanner().location().beg_pos;
663 ParseSourceElements(body, Token::EOS, &ok); 665 ParseSourceElements(body, Token::EOS, &ok);
664 if (ok && top_scope_->is_strict_mode()) { 666 if (ok && top_scope_->is_strict_mode()) {
665 CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok); 667 CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok);
666 } 668 }
667 669
668 if (ok && harmony_scoping_) { 670 if (ok && harmony_scoping_) {
669 CheckConflictingVarDeclarations(scope, &ok); 671 CheckConflictingVarDeclarations(scope, &ok);
670 } 672 }
671 673
674 int ast_nodes_added = isolate()->ast_node_count() - ast_nodes_before + 1;
675 bool is_primitive =
676 (isolate()->heavy_ast_node_count() - heavy_ast_nodes_before == 0);
677
672 if (ok) { 678 if (ok) {
673 result = new(zone()) FunctionLiteral( 679 result = new(zone()) FunctionLiteral(
674 isolate(), 680 isolate(),
675 no_name, 681 no_name,
676 top_scope_, 682 top_scope_,
677 body, 683 body,
678 function_state.materialized_literal_count(), 684 function_state.materialized_literal_count(),
679 function_state.expected_property_count(), 685 function_state.expected_property_count(),
680 function_state.handler_count(), 686 function_state.handler_count(),
681 function_state.only_simple_this_property_assignments(), 687 function_state.only_simple_this_property_assignments(),
682 function_state.this_property_assignments(), 688 function_state.this_property_assignments(),
683 0, 689 0,
684 FunctionLiteral::ANONYMOUS_EXPRESSION, 690 FunctionLiteral::ANONYMOUS_EXPRESSION,
685 false); // Does not have duplicate parameters. 691 false, // Does not have duplicate parameters.
692 ast_nodes_added,
693 is_primitive);
686 } else if (stack_overflow_) { 694 } else if (stack_overflow_) {
687 isolate()->StackOverflow(); 695 isolate()->StackOverflow();
688 } 696 }
689 } 697 }
690 698
691 // Make sure the target stack is empty. 699 // Make sure the target stack is empty.
692 ASSERT(target_stack_ == NULL); 700 ASSERT(target_stack_ == NULL);
693 701
694 // If there was a syntax error we have to get rid of the AST 702 // If there was a syntax error we have to get rid of the AST
695 // and it is not safe to do so before the scope has been deleted. 703 // and it is not safe to do so before the scope has been deleted.
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 Expect(Token::RPAREN, CHECK_OK); 2184 Expect(Token::RPAREN, CHECK_OK);
2177 2185
2178 top_scope_->DeclarationScope()->RecordWithStatement(); 2186 top_scope_->DeclarationScope()->RecordWithStatement();
2179 Scope* with_scope = NewScope(top_scope_, WITH_SCOPE); 2187 Scope* with_scope = NewScope(top_scope_, WITH_SCOPE);
2180 Statement* stmt; 2188 Statement* stmt;
2181 { BlockState block_state(this, with_scope); 2189 { BlockState block_state(this, with_scope);
2182 with_scope->set_start_position(scanner().peek_location().beg_pos); 2190 with_scope->set_start_position(scanner().peek_location().beg_pos);
2183 stmt = ParseStatement(labels, CHECK_OK); 2191 stmt = ParseStatement(labels, CHECK_OK);
2184 with_scope->set_end_position(scanner().location().end_pos); 2192 with_scope->set_end_position(scanner().location().end_pos);
2185 } 2193 }
2186 return new(zone()) WithStatement(expr, stmt); 2194 return new(zone()) WithStatement(isolate(), expr, stmt);
2187 } 2195 }
2188 2196
2189 2197
2190 CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) { 2198 CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) {
2191 // CaseClause :: 2199 // CaseClause ::
2192 // 'case' Expression ':' Statement* 2200 // 'case' Expression ':' Statement*
2193 // 'default' ':' Statement* 2201 // 'default' ':' Statement*
2194 2202
2195 Expression* label = NULL; // NULL expression indicates default case 2203 Expression* label = NULL; // NULL expression indicates default case
2196 if (peek() == Token::CASE) { 2204 if (peek() == Token::CASE) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2342 2350
2343 // Simplify the AST nodes by converting: 2351 // Simplify the AST nodes by converting:
2344 // 'try B0 catch B1 finally B2' 2352 // 'try B0 catch B1 finally B2'
2345 // to: 2353 // to:
2346 // 'try { try B0 catch B1 } finally B2' 2354 // 'try { try B0 catch B1 } finally B2'
2347 2355
2348 if (catch_block != NULL && finally_block != NULL) { 2356 if (catch_block != NULL && finally_block != NULL) {
2349 // If we have both, create an inner try/catch. 2357 // If we have both, create an inner try/catch.
2350 ASSERT(catch_scope != NULL && catch_variable != NULL); 2358 ASSERT(catch_scope != NULL && catch_variable != NULL);
2351 int index = current_function_state_->NextHandlerIndex(); 2359 int index = current_function_state_->NextHandlerIndex();
2352 TryCatchStatement* statement = new(zone()) TryCatchStatement(index, 2360 TryCatchStatement* statement = new(zone()) TryCatchStatement(isolate(),
2361 index,
2353 try_block, 2362 try_block,
2354 catch_scope, 2363 catch_scope,
2355 catch_variable, 2364 catch_variable,
2356 catch_block); 2365 catch_block);
2357 statement->set_escaping_targets(try_collector.targets()); 2366 statement->set_escaping_targets(try_collector.targets());
2358 try_block = new(zone()) Block(isolate(), NULL, 1, false); 2367 try_block = new(zone()) Block(isolate(), NULL, 1, false);
2359 try_block->AddStatement(statement); 2368 try_block->AddStatement(statement);
2360 catch_block = NULL; // Clear to indicate it's been handled. 2369 catch_block = NULL; // Clear to indicate it's been handled.
2361 } 2370 }
2362 2371
2363 TryStatement* result = NULL; 2372 TryStatement* result = NULL;
2364 if (catch_block != NULL) { 2373 if (catch_block != NULL) {
2365 ASSERT(finally_block == NULL); 2374 ASSERT(finally_block == NULL);
2366 ASSERT(catch_scope != NULL && catch_variable != NULL); 2375 ASSERT(catch_scope != NULL && catch_variable != NULL);
2367 int index = current_function_state_->NextHandlerIndex(); 2376 int index = current_function_state_->NextHandlerIndex();
2368 result = new(zone()) TryCatchStatement(index, 2377 result = new(zone()) TryCatchStatement(isolate(),
2378 index,
2369 try_block, 2379 try_block,
2370 catch_scope, 2380 catch_scope,
2371 catch_variable, 2381 catch_variable,
2372 catch_block); 2382 catch_block);
2373 } else { 2383 } else {
2374 ASSERT(finally_block != NULL); 2384 ASSERT(finally_block != NULL);
2375 int index = current_function_state_->NextHandlerIndex(); 2385 int index = current_function_state_->NextHandlerIndex();
2376 result = new(zone()) TryFinallyStatement(index, 2386 result = new(zone()) TryFinallyStatement(isolate(),
2387 index,
2377 try_block, 2388 try_block,
2378 finally_block); 2389 finally_block);
2379 // Combine the jump targets of the try block and the possible catch block. 2390 // Combine the jump targets of the try block and the possible catch block.
2380 try_collector.targets()->AddAll(*catch_collector.targets()); 2391 try_collector.targets()->AddAll(*catch_collector.targets());
2381 } 2392 }
2382 2393
2383 result->set_escaping_targets(try_collector.targets()); 2394 result->set_escaping_targets(try_collector.targets());
2384 return result; 2395 return result;
2385 } 2396 }
2386 2397
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
3931 // Function declarations are function scoped in normal mode, so they are 3942 // Function declarations are function scoped in normal mode, so they are
3932 // hoisted. In harmony block scoping mode they are block scoped, so they 3943 // hoisted. In harmony block scoping mode they are block scoped, so they
3933 // are not hoisted. 3944 // are not hoisted.
3934 Scope* scope = (type == FunctionLiteral::DECLARATION && !harmony_scoping_) 3945 Scope* scope = (type == FunctionLiteral::DECLARATION && !harmony_scoping_)
3935 ? NewScope(top_scope_->DeclarationScope(), FUNCTION_SCOPE) 3946 ? NewScope(top_scope_->DeclarationScope(), FUNCTION_SCOPE)
3936 : NewScope(top_scope_, FUNCTION_SCOPE); 3947 : NewScope(top_scope_, FUNCTION_SCOPE);
3937 ZoneList<Statement*>* body = NULL; 3948 ZoneList<Statement*>* body = NULL;
3938 int materialized_literal_count; 3949 int materialized_literal_count;
3939 int expected_property_count; 3950 int expected_property_count;
3940 int handler_count = 0; 3951 int handler_count = 0;
3952 int ast_node_count_before = isolate_->ast_node_count();
3953 int heavy_ast_node_count_before = isolate_->heavy_ast_node_count();
3941 bool only_simple_this_property_assignments; 3954 bool only_simple_this_property_assignments;
3942 Handle<FixedArray> this_property_assignments; 3955 Handle<FixedArray> this_property_assignments;
3943 bool has_duplicate_parameters = false; 3956 bool has_duplicate_parameters = false;
3944 // Parse function body. 3957 // Parse function body.
3945 { FunctionState function_state(this, scope, isolate()); 3958 { FunctionState function_state(this, scope, isolate());
3946 top_scope_->SetScopeName(function_name); 3959 top_scope_->SetScopeName(function_name);
3947 3960
3948 // FormalParameterList :: 3961 // FormalParameterList ::
3949 // '(' (Identifier)*[','] ')' 3962 // '(' (Identifier)*[','] ')'
3950 Expect(Token::LPAREN, CHECK_OK); 3963 Expect(Token::LPAREN, CHECK_OK);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
4112 CheckOctalLiteral(scope->start_position(), 4125 CheckOctalLiteral(scope->start_position(),
4113 scope->end_position(), 4126 scope->end_position(),
4114 CHECK_OK); 4127 CHECK_OK);
4115 } 4128 }
4116 } 4129 }
4117 4130
4118 if (harmony_scoping_) { 4131 if (harmony_scoping_) {
4119 CheckConflictingVarDeclarations(scope, CHECK_OK); 4132 CheckConflictingVarDeclarations(scope, CHECK_OK);
4120 } 4133 }
4121 4134
4135 int ast_nodes_added = isolate_->ast_node_count() - ast_node_count_before + 1;
4136 bool is_primitive =
4137 (isolate_->heavy_ast_node_count() - heavy_ast_node_count_before == 0);
4138
4122 FunctionLiteral* function_literal = 4139 FunctionLiteral* function_literal =
4123 new(zone()) FunctionLiteral(isolate(), 4140 new(zone()) FunctionLiteral(isolate(),
4124 function_name, 4141 function_name,
4125 scope, 4142 scope,
4126 body, 4143 body,
4127 materialized_literal_count, 4144 materialized_literal_count,
4128 expected_property_count, 4145 expected_property_count,
4129 handler_count, 4146 handler_count,
4130 only_simple_this_property_assignments, 4147 only_simple_this_property_assignments,
4131 this_property_assignments, 4148 this_property_assignments,
4132 num_parameters, 4149 num_parameters,
4133 type, 4150 type,
4134 has_duplicate_parameters); 4151 has_duplicate_parameters,
4152 ast_nodes_added,
4153 is_primitive);
4135 function_literal->set_function_token_position(function_token_position); 4154 function_literal->set_function_token_position(function_token_position);
4136 4155
4137 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); 4156 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal);
4138 return function_literal; 4157 return function_literal;
4139 } 4158 }
4140 4159
4141 4160
4142 Expression* Parser::ParseV8Intrinsic(bool* ok) { 4161 Expression* Parser::ParseV8Intrinsic(bool* ok) {
4143 // CallRuntime :: 4162 // CallRuntime ::
4144 // '%' Identifier Arguments 4163 // '%' Identifier Arguments
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
5459 ASSERT(info->isolate()->has_pending_exception()); 5478 ASSERT(info->isolate()->has_pending_exception());
5460 } else { 5479 } else {
5461 result = parser.ParseProgram(info); 5480 result = parser.ParseProgram(info);
5462 } 5481 }
5463 } 5482 }
5464 info->SetFunction(result); 5483 info->SetFunction(result);
5465 return (result != NULL); 5484 return (result != NULL);
5466 } 5485 }
5467 5486
5468 } } // namespace v8::internal 5487 } } // namespace v8::internal
OLDNEW
« src/hydrogen.cc ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698