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

Side by Side Diff: src/crankshaft/hydrogen.cc

Issue 1419813010: [runtime] Remove the very dangerous %_CallFunction intrinsic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | src/debug/debug.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/crankshaft/hydrogen.h" 5 #include "src/crankshaft/hydrogen.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/allocation-site-scopes.h" 9 #include "src/allocation-site-scopes.h"
10 #include "src/ast-numbering.h" 10 #include "src/ast-numbering.h"
(...skipping 12696 matching lines...) Expand 10 before | Expand all | Expand 10 after
12707 HValue* target = Pop(); 12707 HValue* target = Pop();
12708 HValue* values[] = {context(), target, 12708 HValue* values[] = {context(), target,
12709 Add<HConstant>(call->arguments()->length() - 2)}; 12709 Add<HConstant>(call->arguments()->length() - 2)};
12710 HInstruction* result = New<HCallWithDescriptor>( 12710 HInstruction* result = New<HCallWithDescriptor>(
12711 trampoline, call->arguments()->length() - 1, descriptor, 12711 trampoline, call->arguments()->length() - 1, descriptor,
12712 Vector<HValue*>(values, arraysize(values))); 12712 Vector<HValue*>(values, arraysize(values)));
12713 return ast_context()->ReturnInstruction(result, call->id()); 12713 return ast_context()->ReturnInstruction(result, call->id());
12714 } 12714 }
12715 12715
12716 12716
12717 // Fast call for custom callbacks.
12718 void HOptimizedGraphBuilder::GenerateCallFunction(CallRuntime* call) {
12719 // 1 ~ The function to call is not itself an argument to the call.
12720 int arg_count = call->arguments()->length() - 1;
12721 DCHECK(arg_count >= 1); // There's always at least a receiver.
12722
12723 CHECK_ALIVE(VisitExpressions(call->arguments()));
12724 // The function is the last argument
12725 HValue* function = Pop();
12726 // Push the arguments to the stack
12727 PushArgumentsFromEnvironment(arg_count);
12728
12729 IfBuilder if_is_jsfunction(this);
12730 if_is_jsfunction.If<HHasInstanceTypeAndBranch>(function, JS_FUNCTION_TYPE);
12731
12732 if_is_jsfunction.Then();
12733 {
12734 HInstruction* invoke_result =
12735 Add<HInvokeFunction>(function, arg_count);
12736 if (!ast_context()->IsEffect()) {
12737 Push(invoke_result);
12738 }
12739 Add<HSimulate>(call->id(), FIXED_SIMULATE);
12740 }
12741
12742 if_is_jsfunction.Else();
12743 {
12744 HInstruction* call_result =
12745 Add<HCallFunction>(function, arg_count);
12746 if (!ast_context()->IsEffect()) {
12747 Push(call_result);
12748 }
12749 Add<HSimulate>(call->id(), FIXED_SIMULATE);
12750 }
12751 if_is_jsfunction.End();
12752
12753 if (ast_context()->IsEffect()) {
12754 // EffectContext::ReturnValue ignores the value, so we can just pass
12755 // 'undefined' (as we do not have the call result anymore).
12756 return ast_context()->ReturnValue(graph()->GetConstantUndefined());
12757 } else {
12758 return ast_context()->ReturnValue(Pop());
12759 }
12760 }
12761
12762
12763 // Fast call to math functions. 12717 // Fast call to math functions.
12764 void HOptimizedGraphBuilder::GenerateMathPow(CallRuntime* call) { 12718 void HOptimizedGraphBuilder::GenerateMathPow(CallRuntime* call) {
12765 DCHECK_EQ(2, call->arguments()->length()); 12719 DCHECK_EQ(2, call->arguments()->length());
12766 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 12720 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
12767 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 12721 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
12768 HValue* right = Pop(); 12722 HValue* right = Pop();
12769 HValue* left = Pop(); 12723 HValue* left = Pop();
12770 HInstruction* result = NewUncasted<HPower>(left, right); 12724 HInstruction* result = NewUncasted<HPower>(left, right);
12771 return ast_context()->ReturnInstruction(result, call->id()); 12725 return ast_context()->ReturnInstruction(result, call->id());
12772 } 12726 }
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
13681 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13635 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13682 } 13636 }
13683 13637
13684 #ifdef DEBUG 13638 #ifdef DEBUG
13685 graph_->Verify(false); // No full verify. 13639 graph_->Verify(false); // No full verify.
13686 #endif 13640 #endif
13687 } 13641 }
13688 13642
13689 } // namespace internal 13643 } // namespace internal
13690 } // namespace v8 13644 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | src/debug/debug.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698