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

Side by Side Diff: src/arm64/full-codegen-arm64.cc

Issue 1202963005: Fix receiver when calling eval() bound by with scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Full-codegen impls for all arches Created 5 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
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ast.h » ('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/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_ARM64 7 #if V8_TARGET_ARCH_ARM64
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 2811 matching lines...) Expand 10 before | Expand all | Expand 10 after
2822 __ JumpIfRoot(x1, Heap::kTheHoleValueRootIndex, &uninitialized_this); 2822 __ JumpIfRoot(x1, Heap::kTheHoleValueRootIndex, &uninitialized_this);
2823 __ Mov(x0, Operand(this_var->name())); 2823 __ Mov(x0, Operand(this_var->name()));
2824 __ Push(x0); 2824 __ Push(x0);
2825 __ CallRuntime(Runtime::kThrowReferenceError, 1); 2825 __ CallRuntime(Runtime::kThrowReferenceError, 1);
2826 __ bind(&uninitialized_this); 2826 __ bind(&uninitialized_this);
2827 2827
2828 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); 2828 EmitVariableAssignment(this_var, Token::INIT_CONST, slot);
2829 } 2829 }
2830 2830
2831 2831
2832 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls.
2833 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
2834 VariableProxy* callee = expr->expression()->AsVariableProxy();
2835 if (callee->var()->IsLookupSlot()) {
2836 Label slow, done;
2837
2838 {
2839 PreservePositionScope scope(masm()->positions_recorder());
2840 // Generate code for loading from variables potentially shadowed
2841 // by eval-introduced variables.
2842 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done);
2843 }
2844
2845 __ Bind(&slow);
2846 // Call the runtime to find the function to call (returned in x0)
2847 // and the object holding it (returned in x1).
2848 __ Mov(x10, Operand(callee->name()));
2849 __ Push(context_register(), x10);
2850 __ CallRuntime(Runtime::kLoadLookupSlot, 2);
2851 __ Push(x0, x1); // Receiver, function.
2852 PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS);
2853
2854 // If fast case code has been generated, emit code to push the
2855 // function and receiver and have the slow path jump around this
2856 // code.
2857 if (done.is_linked()) {
2858 Label call;
2859 __ B(&call);
2860 __ Bind(&done);
2861 // Push function.
2862 // The receiver is implicitly the global receiver. Indicate this
2863 // by passing the undefined to the call function stub.
2864 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex);
2865 __ Push(x0, x1);
2866 __ Bind(&call);
2867 }
2868 } else {
2869 VisitForStackValue(callee);
2870 // refEnv.WithBaseObject()
2871 __ LoadRoot(x10, Heap::kUndefinedValueRootIndex);
2872 __ Push(x10); // Reserved receiver slot.
2873 }
2874 }
2875
2876
2832 void FullCodeGenerator::VisitCall(Call* expr) { 2877 void FullCodeGenerator::VisitCall(Call* expr) {
2833 #ifdef DEBUG 2878 #ifdef DEBUG
2834 // We want to verify that RecordJSReturnSite gets called on all paths 2879 // We want to verify that RecordJSReturnSite gets called on all paths
2835 // through this function. Avoid early returns. 2880 // through this function. Avoid early returns.
2836 expr->return_is_recorded_ = false; 2881 expr->return_is_recorded_ = false;
2837 #endif 2882 #endif
2838 2883
2839 Comment cmnt(masm_, "[ Call"); 2884 Comment cmnt(masm_, "[ Call");
2840 Expression* callee = expr->expression(); 2885 Expression* callee = expr->expression();
2841 Call::CallType call_type = expr->GetCallType(isolate()); 2886 Call::CallType call_type = expr->GetCallType(isolate());
2842 2887
2843 if (call_type == Call::POSSIBLY_EVAL_CALL) { 2888 if (call_type == Call::POSSIBLY_EVAL_CALL) {
2844 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval 2889 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
2845 // to resolve the function we need to call. Then we call the resolved 2890 // to resolve the function we need to call. Then we call the resolved
2846 // function using the given arguments. 2891 // function using the given arguments.
2847 ZoneList<Expression*>* args = expr->arguments(); 2892 ZoneList<Expression*>* args = expr->arguments();
2848 int arg_count = args->length(); 2893 int arg_count = args->length();
2849 2894
2850 { 2895 {
2851 PreservePositionScope pos_scope(masm()->positions_recorder()); 2896 PreservePositionScope pos_scope(masm()->positions_recorder());
2852 VisitForStackValue(callee); 2897 PushCalleeAndWithBaseObject(expr);
2853 __ LoadRoot(x10, Heap::kUndefinedValueRootIndex);
2854 __ Push(x10); // Reserved receiver slot.
2855 2898
2856 // Push the arguments. 2899 // Push the arguments.
2857 for (int i = 0; i < arg_count; i++) { 2900 for (int i = 0; i < arg_count; i++) {
2858 VisitForStackValue(args->at(i)); 2901 VisitForStackValue(args->at(i));
2859 } 2902 }
2860 2903
2861 // Push a copy of the function (found below the arguments) and 2904 // Push a copy of the function (found below the arguments) and
2862 // resolve eval. 2905 // resolve eval.
2863 __ Peek(x10, (arg_count + 1) * kPointerSize); 2906 __ Peek(x10, (arg_count + 1) * kPointerSize);
2864 __ Push(x10); 2907 __ Push(x10);
2865 EmitResolvePossiblyDirectEval(arg_count); 2908 EmitResolvePossiblyDirectEval(arg_count);
2866 2909
2867 // Touch up the stack with the resolved function. 2910 // Touch up the stack with the resolved function.
2868 __ Poke(x0, (arg_count + 1) * kPointerSize); 2911 __ Poke(x0, (arg_count + 1) * kPointerSize);
2869 2912
2870 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS); 2913 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS);
2871 } 2914 }
2872 2915
2873 // Record source position for debugger. 2916 // Record source position for debugger.
2874 SetSourcePosition(expr->position()); 2917 SetSourcePosition(expr->position());
2875 2918
2876 // Call the evaluated function. 2919 // Call the evaluated function.
2877 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); 2920 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS);
2878 __ Peek(x1, (arg_count + 1) * kXRegSize); 2921 __ Peek(x1, (arg_count + 1) * kXRegSize);
2879 __ CallStub(&stub); 2922 __ CallStub(&stub);
2880 RecordJSReturnSite(expr); 2923 RecordJSReturnSite(expr);
2881 // Restore context register. 2924 // Restore context register.
2882 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); 2925 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
2883 context()->DropAndPlug(1, x0); 2926 context()->DropAndPlug(1, x0);
2884 2927
2885 } else if (call_type == Call::GLOBAL_CALL) { 2928 } else if (call_type == Call::GLOBAL_CALL) {
2886 EmitCallWithLoadIC(expr); 2929 EmitCallWithLoadIC(expr);
2887 2930
2888 } else if (call_type == Call::LOOKUP_SLOT_CALL) { 2931 } else if (call_type == Call::LOOKUP_SLOT_CALL) {
2889 // Call to a lookup slot (dynamically introduced variable). 2932 // Call to a lookup slot (dynamically introduced variable).
2890 VariableProxy* proxy = callee->AsVariableProxy(); 2933 PushCalleeAndWithBaseObject(expr);
2891 Label slow, done;
2892
2893 { PreservePositionScope scope(masm()->positions_recorder());
2894 // Generate code for loading from variables potentially shadowed
2895 // by eval-introduced variables.
2896 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done);
2897 }
2898
2899 __ Bind(&slow);
2900 // Call the runtime to find the function to call (returned in x0)
2901 // and the object holding it (returned in x1).
2902 __ Mov(x10, Operand(proxy->name()));
2903 __ Push(context_register(), x10);
2904 __ CallRuntime(Runtime::kLoadLookupSlot, 2);
2905 __ Push(x0, x1); // Receiver, function.
2906 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS);
2907
2908 // If fast case code has been generated, emit code to push the
2909 // function and receiver and have the slow path jump around this
2910 // code.
2911 if (done.is_linked()) {
2912 Label call;
2913 __ B(&call);
2914 __ Bind(&done);
2915 // Push function.
2916 // The receiver is implicitly the global receiver. Indicate this
2917 // by passing the undefined to the call function stub.
2918 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex);
2919 __ Push(x0, x1);
2920 __ Bind(&call);
2921 }
2922
2923 // The receiver is either the global receiver or an object found
2924 // by LoadContextSlot.
2925 EmitCall(expr); 2934 EmitCall(expr);
2926 } else if (call_type == Call::PROPERTY_CALL) { 2935 } else if (call_type == Call::PROPERTY_CALL) {
2927 Property* property = callee->AsProperty(); 2936 Property* property = callee->AsProperty();
2928 bool is_named_call = property->key()->IsPropertyName(); 2937 bool is_named_call = property->key()->IsPropertyName();
2929 if (property->IsSuperAccess()) { 2938 if (property->IsSuperAccess()) {
2930 if (is_named_call) { 2939 if (is_named_call) {
2931 EmitSuperCallWithLoadIC(expr); 2940 EmitSuperCallWithLoadIC(expr);
2932 } else { 2941 } else {
2933 EmitKeyedSuperCallWithLoadIC(expr); 2942 EmitKeyedSuperCallWithLoadIC(expr);
2934 } 2943 }
(...skipping 2651 matching lines...) Expand 10 before | Expand all | Expand 10 after
5586 } 5595 }
5587 5596
5588 return INTERRUPT; 5597 return INTERRUPT;
5589 } 5598 }
5590 5599
5591 5600
5592 } // namespace internal 5601 } // namespace internal
5593 } // namespace v8 5602 } // namespace v8
5594 5603
5595 #endif // V8_TARGET_ARCH_ARM64 5604 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698