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

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

Issue 1201273004: Revert of Fix receiver when calling eval() bound by with scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: 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 | « no previous file | src/arm64/full-codegen-arm64.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_ARM 7 #if V8_TARGET_ARCH_ARM
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 3119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3130 __ b(eq, &uninitialized_this); 3130 __ b(eq, &uninitialized_this);
3131 __ mov(r0, Operand(this_var->name())); 3131 __ mov(r0, Operand(this_var->name()));
3132 __ Push(r0); 3132 __ Push(r0);
3133 __ CallRuntime(Runtime::kThrowReferenceError, 1); 3133 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3134 __ bind(&uninitialized_this); 3134 __ bind(&uninitialized_this);
3135 3135
3136 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); 3136 EmitVariableAssignment(this_var, Token::INIT_CONST, slot);
3137 } 3137 }
3138 3138
3139 3139
3140 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. 3140 void FullCodeGenerator::VisitCall(Call* expr) {
3141 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { 3141 #ifdef DEBUG
3142 VariableProxy* callee = expr->expression()->AsVariableProxy(); 3142 // We want to verify that RecordJSReturnSite gets called on all paths
3143 if (callee->var()->IsLookupSlot()) { 3143 // through this function. Avoid early returns.
3144 expr->return_is_recorded_ = false;
3145 #endif
3146
3147 Comment cmnt(masm_, "[ Call");
3148 Expression* callee = expr->expression();
3149 Call::CallType call_type = expr->GetCallType(isolate());
3150
3151 if (call_type == Call::POSSIBLY_EVAL_CALL) {
3152 // In a call to eval, we first call
3153 // RuntimeHidden_asResolvePossiblyDirectEval to resolve the function we need
3154 // to call. Then we call the resolved function using the given arguments.
3155 ZoneList<Expression*>* args = expr->arguments();
3156 int arg_count = args->length();
3157
3158 { PreservePositionScope pos_scope(masm()->positions_recorder());
3159 VisitForStackValue(callee);
3160 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
3161 __ push(r2); // Reserved receiver slot.
3162
3163 // Push the arguments.
3164 for (int i = 0; i < arg_count; i++) {
3165 VisitForStackValue(args->at(i));
3166 }
3167
3168 // Push a copy of the function (found below the arguments) and
3169 // resolve eval.
3170 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
3171 __ push(r1);
3172 EmitResolvePossiblyDirectEval(arg_count);
3173
3174 // Touch up the stack with the resolved function.
3175 __ str(r0, MemOperand(sp, (arg_count + 1) * kPointerSize));
3176
3177 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS);
3178 }
3179
3180 // Record source position for debugger.
3181 SetSourcePosition(expr->position());
3182 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS);
3183 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
3184 __ CallStub(&stub);
3185 RecordJSReturnSite(expr);
3186 // Restore context register.
3187 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
3188 context()->DropAndPlug(1, r0);
3189 } else if (call_type == Call::GLOBAL_CALL) {
3190 EmitCallWithLoadIC(expr);
3191
3192 } else if (call_type == Call::LOOKUP_SLOT_CALL) {
3193 // Call to a lookup slot (dynamically introduced variable).
3194 VariableProxy* proxy = callee->AsVariableProxy();
3144 Label slow, done; 3195 Label slow, done;
3145 3196
3146 { 3197 { PreservePositionScope scope(masm()->positions_recorder());
3147 PreservePositionScope scope(masm()->positions_recorder());
3148 // Generate code for loading from variables potentially shadowed 3198 // Generate code for loading from variables potentially shadowed
3149 // by eval-introduced variables. 3199 // by eval-introduced variables.
3150 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); 3200 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done);
3151 } 3201 }
3152 3202
3153 __ bind(&slow); 3203 __ bind(&slow);
3154 // Call the runtime to find the function to call (returned in r0) 3204 // Call the runtime to find the function to call (returned in r0)
3155 // and the object holding it (returned in edx). 3205 // and the object holding it (returned in edx).
3156 DCHECK(!context_register().is(r2)); 3206 DCHECK(!context_register().is(r2));
3157 __ mov(r2, Operand(callee->name())); 3207 __ mov(r2, Operand(proxy->name()));
3158 __ Push(context_register(), r2); 3208 __ Push(context_register(), r2);
3159 __ CallRuntime(Runtime::kLoadLookupSlot, 2); 3209 __ CallRuntime(Runtime::kLoadLookupSlot, 2);
3160 __ Push(r0, r1); // Function, receiver. 3210 __ Push(r0, r1); // Function, receiver.
3161 PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS); 3211 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS);
3162 3212
3163 // If fast case code has been generated, emit code to push the 3213 // If fast case code has been generated, emit code to push the
3164 // function and receiver and have the slow path jump around this 3214 // function and receiver and have the slow path jump around this
3165 // code. 3215 // code.
3166 if (done.is_linked()) { 3216 if (done.is_linked()) {
3167 Label call; 3217 Label call;
3168 __ b(&call); 3218 __ b(&call);
3169 __ bind(&done); 3219 __ bind(&done);
3170 // Push function. 3220 // Push function.
3171 __ push(r0); 3221 __ push(r0);
3172 // The receiver is implicitly the global receiver. Indicate this 3222 // The receiver is implicitly the global receiver. Indicate this
3173 // by passing the hole to the call function stub. 3223 // by passing the hole to the call function stub.
3174 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); 3224 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex);
3175 __ push(r1); 3225 __ push(r1);
3176 __ bind(&call); 3226 __ bind(&call);
3177 } 3227 }
3178 } else {
3179 VisitForStackValue(callee);
3180 // refEnv.WithBaseObject()
3181 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
3182 __ push(r2); // Reserved receiver slot.
3183 }
3184 }
3185 3228
3186 3229 // The receiver is either the global receiver or an object found
3187 void FullCodeGenerator::VisitCall(Call* expr) { 3230 // by LoadContextSlot.
3188 #ifdef DEBUG
3189 // We want to verify that RecordJSReturnSite gets called on all paths
3190 // through this function. Avoid early returns.
3191 expr->return_is_recorded_ = false;
3192 #endif
3193
3194 Comment cmnt(masm_, "[ Call");
3195 Expression* callee = expr->expression();
3196 Call::CallType call_type = expr->GetCallType(isolate());
3197
3198 if (call_type == Call::POSSIBLY_EVAL_CALL) {
3199 // In a call to eval, we first call
3200 // RuntimeHidden_asResolvePossiblyDirectEval to resolve the function we need
3201 // to call. Then we call the resolved function using the given arguments.
3202 ZoneList<Expression*>* args = expr->arguments();
3203 int arg_count = args->length();
3204
3205 { PreservePositionScope pos_scope(masm()->positions_recorder());
3206 PushCalleeAndWithBaseObject(expr);
3207
3208 // Push the arguments.
3209 for (int i = 0; i < arg_count; i++) {
3210 VisitForStackValue(args->at(i));
3211 }
3212
3213 // Push a copy of the function (found below the arguments) and
3214 // resolve eval.
3215 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
3216 __ push(r1);
3217 EmitResolvePossiblyDirectEval(arg_count);
3218
3219 // Touch up the stack with the resolved function.
3220 __ str(r0, MemOperand(sp, (arg_count + 1) * kPointerSize));
3221
3222 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS);
3223 }
3224
3225 // Record source position for debugger.
3226 SetSourcePosition(expr->position());
3227 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS);
3228 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
3229 __ CallStub(&stub);
3230 RecordJSReturnSite(expr);
3231 // Restore context register.
3232 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
3233 context()->DropAndPlug(1, r0);
3234 } else if (call_type == Call::GLOBAL_CALL) {
3235 EmitCallWithLoadIC(expr);
3236
3237 } else if (call_type == Call::LOOKUP_SLOT_CALL) {
3238 // Call to a lookup slot (dynamically introduced variable).
3239 PushCalleeAndWithBaseObject(expr);
3240 EmitCall(expr); 3231 EmitCall(expr);
3241 } else if (call_type == Call::PROPERTY_CALL) { 3232 } else if (call_type == Call::PROPERTY_CALL) {
3242 Property* property = callee->AsProperty(); 3233 Property* property = callee->AsProperty();
3243 bool is_named_call = property->key()->IsPropertyName(); 3234 bool is_named_call = property->key()->IsPropertyName();
3244 if (property->IsSuperAccess()) { 3235 if (property->IsSuperAccess()) {
3245 if (is_named_call) { 3236 if (is_named_call) {
3246 EmitSuperCallWithLoadIC(expr); 3237 EmitSuperCallWithLoadIC(expr);
3247 } else { 3238 } else {
3248 EmitKeyedSuperCallWithLoadIC(expr); 3239 EmitKeyedSuperCallWithLoadIC(expr);
3249 } 3240 }
(...skipping 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after
5617 DCHECK(interrupt_address == 5608 DCHECK(interrupt_address ==
5618 isolate->builtins()->OsrAfterStackCheck()->entry()); 5609 isolate->builtins()->OsrAfterStackCheck()->entry());
5619 return OSR_AFTER_STACK_CHECK; 5610 return OSR_AFTER_STACK_CHECK;
5620 } 5611 }
5621 5612
5622 5613
5623 } // namespace internal 5614 } // namespace internal
5624 } // namespace v8 5615 } // namespace v8
5625 5616
5626 #endif // V8_TARGET_ARCH_ARM 5617 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/full-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698