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

Side by Side Diff: src/hydrogen.cc

Issue 356773002: Allow inlining of functions containing %_Arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/ast.cc ('k') | test/mjsunit/compiler/inline-arguments.js » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/hydrogen.h" 5 #include "src/hydrogen.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 7720 matching lines...) Expand 10 before | Expand all | Expand 10 after
7731 HEnvironment* inner_env = 7731 HEnvironment* inner_env =
7732 environment()->CopyForInlining(target, 7732 environment()->CopyForInlining(target,
7733 arguments_count, 7733 arguments_count,
7734 function, 7734 function,
7735 undefined, 7735 undefined,
7736 function_state()->inlining_kind()); 7736 function_state()->inlining_kind());
7737 7737
7738 HConstant* context = Add<HConstant>(Handle<Context>(target->context())); 7738 HConstant* context = Add<HConstant>(Handle<Context>(target->context()));
7739 inner_env->BindContext(context); 7739 inner_env->BindContext(context);
7740 7740
7741 HArgumentsObject* arguments_object = NULL; 7741 // Create a dematerialized arguments object for the function, also copy the
7742 // current arguments values to use them for materialization.
7743 HEnvironment* arguments_env = inner_env->arguments_environment();
7744 int parameter_count = arguments_env->parameter_count();
7745 HArgumentsObject* arguments_object = Add<HArgumentsObject>(parameter_count);
7746 for (int i = 0; i < parameter_count; i++) {
7747 arguments_object->AddArgument(arguments_env->Lookup(i), zone());
7748 }
7742 7749
7743 // If the function uses arguments object create and bind one, also copy 7750 // If the function uses arguments object then bind bind one.
7744 // current arguments values to use them for materialization.
7745 if (function->scope()->arguments() != NULL) { 7751 if (function->scope()->arguments() != NULL) {
7746 ASSERT(function->scope()->arguments()->IsStackAllocated()); 7752 ASSERT(function->scope()->arguments()->IsStackAllocated());
7747 HEnvironment* arguments_env = inner_env->arguments_environment();
7748 int arguments_count = arguments_env->parameter_count();
7749 arguments_object = Add<HArgumentsObject>(arguments_count);
7750 inner_env->Bind(function->scope()->arguments(), arguments_object); 7753 inner_env->Bind(function->scope()->arguments(), arguments_object);
7751 for (int i = 0; i < arguments_count; i++) {
7752 arguments_object->AddArgument(arguments_env->Lookup(i), zone());
7753 }
7754 } 7754 }
7755 7755
7756 // Capture the state before invoking the inlined function for deopt in the 7756 // Capture the state before invoking the inlined function for deopt in the
7757 // inlined function. This simulate has no bailout-id since it's not directly 7757 // inlined function. This simulate has no bailout-id since it's not directly
7758 // reachable for deopt, and is only used to capture the state. If the simulate 7758 // reachable for deopt, and is only used to capture the state. If the simulate
7759 // becomes reachable by merging, the ast id of the simulate merged into it is 7759 // becomes reachable by merging, the ast id of the simulate merged into it is
7760 // adopted. 7760 // adopted.
7761 Add<HSimulate>(BailoutId::None()); 7761 Add<HSimulate>(BailoutId::None());
7762 7762
7763 current_block()->UpdateEnvironment(inner_env); 7763 current_block()->UpdateEnvironment(inner_env);
(...skipping 3555 matching lines...) Expand 10 before | Expand all | Expand 10 after
11319 // Number of arguments without receiver. 11319 // Number of arguments without receiver.
11320 int argument_count = environment()-> 11320 int argument_count = environment()->
11321 arguments_environment()->parameter_count() - 1; 11321 arguments_environment()->parameter_count() - 1;
11322 result = New<HConstant>(argument_count); 11322 result = New<HConstant>(argument_count);
11323 } 11323 }
11324 return ast_context()->ReturnInstruction(result, call->id()); 11324 return ast_context()->ReturnInstruction(result, call->id());
11325 } 11325 }
11326 11326
11327 11327
11328 void HOptimizedGraphBuilder::GenerateArguments(CallRuntime* call) { 11328 void HOptimizedGraphBuilder::GenerateArguments(CallRuntime* call) {
11329 // Our implementation of arguments (based on this stack frame or an
11330 // adapter below it) does not work for inlined functions. This runtime
11331 // function is blacklisted by AstNode::IsInlineable.
11332 ASSERT(function_state()->outer() == NULL);
11333 ASSERT(call->arguments()->length() == 1); 11329 ASSERT(call->arguments()->length() == 1);
11334 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 11330 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
11335 HValue* index = Pop(); 11331 HValue* index = Pop();
11336 HInstruction* elements = Add<HArgumentsElements>(false); 11332 HInstruction* result = NULL;
11337 HInstruction* length = Add<HArgumentsLength>(elements); 11333 if (function_state()->outer() == NULL) {
11338 HInstruction* checked_index = Add<HBoundsCheck>(index, length); 11334 HInstruction* elements = Add<HArgumentsElements>(false);
11339 HAccessArgumentsAt* result = New<HAccessArgumentsAt>( 11335 HInstruction* length = Add<HArgumentsLength>(elements);
11340 elements, length, checked_index); 11336 HInstruction* checked_index = Add<HBoundsCheck>(index, length);
11337 result = New<HAccessArgumentsAt>(elements, length, checked_index);
11338 } else {
11339 EnsureArgumentsArePushedForAccess();
11340
11341 // Number of arguments without receiver.
11342 HInstruction* elements = function_state()->arguments_elements();
11343 int argument_count = environment()->
11344 arguments_environment()->parameter_count() - 1;
11345 HInstruction* length = Add<HConstant>(argument_count);
11346 HInstruction* checked_key = Add<HBoundsCheck>(index, length);
11347 result = New<HAccessArgumentsAt>(elements, length, checked_key);
11348 }
11341 return ast_context()->ReturnInstruction(result, call->id()); 11349 return ast_context()->ReturnInstruction(result, call->id());
11342 } 11350 }
11343 11351
11344 11352
11345 // Support for accessing the class and value fields of an object. 11353 // Support for accessing the class and value fields of an object.
11346 void HOptimizedGraphBuilder::GenerateClassOf(CallRuntime* call) { 11354 void HOptimizedGraphBuilder::GenerateClassOf(CallRuntime* call) {
11347 // The special form detected by IsClassOfTest is detected before we get here 11355 // The special form detected by IsClassOfTest is detected before we get here
11348 // and does not cause a bailout. 11356 // and does not cause a bailout.
11349 return Bailout(kInlinedRuntimeFunctionClassOf); 11357 return Bailout(kInlinedRuntimeFunctionClassOf);
11350 } 11358 }
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
12356 if (ShouldProduceTraceOutput()) { 12364 if (ShouldProduceTraceOutput()) {
12357 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 12365 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
12358 } 12366 }
12359 12367
12360 #ifdef DEBUG 12368 #ifdef DEBUG
12361 graph_->Verify(false); // No full verify. 12369 graph_->Verify(false); // No full verify.
12362 #endif 12370 #endif
12363 } 12371 }
12364 12372
12365 } } // namespace v8::internal 12373 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | test/mjsunit/compiler/inline-arguments.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698