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

Side by Side Diff: src/mips64/full-codegen-mips64.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, 5 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/mips/full-codegen-mips.cc ('k') | src/ppc/full-codegen-ppc.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_MIPS64 7 #if V8_TARGET_ARCH_MIPS64
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 3104 matching lines...) Expand 10 before | Expand all | Expand 10 after
3115 __ Branch(&uninitialized_this, eq, a1, Operand(at)); 3115 __ Branch(&uninitialized_this, eq, a1, Operand(at));
3116 __ li(a0, Operand(this_var->name())); 3116 __ li(a0, Operand(this_var->name()));
3117 __ Push(a0); 3117 __ Push(a0);
3118 __ CallRuntime(Runtime::kThrowReferenceError, 1); 3118 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3119 __ bind(&uninitialized_this); 3119 __ bind(&uninitialized_this);
3120 3120
3121 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); 3121 EmitVariableAssignment(this_var, Token::INIT_CONST, slot);
3122 } 3122 }
3123 3123
3124 3124
3125 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls.
3126 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
3127 VariableProxy* callee = expr->expression()->AsVariableProxy();
3128 if (callee->var()->IsLookupSlot()) {
3129 Label slow, done;
3130
3131 {
3132 PreservePositionScope scope(masm()->positions_recorder());
3133 // Generate code for loading from variables potentially shadowed
3134 // by eval-introduced variables.
3135 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done);
3136 }
3137
3138 __ bind(&slow);
3139 // Call the runtime to find the function to call (returned in v0)
3140 // and the object holding it (returned in v1).
3141 DCHECK(!context_register().is(a2));
3142 __ li(a2, Operand(callee->name()));
3143 __ Push(context_register(), a2);
3144 __ CallRuntime(Runtime::kLoadLookupSlot, 2);
3145 __ Push(v0, v1); // Function, receiver.
3146 PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS);
3147
3148 // If fast case code has been generated, emit code to push the
3149 // function and receiver and have the slow path jump around this
3150 // code.
3151 if (done.is_linked()) {
3152 Label call;
3153 __ Branch(&call);
3154 __ bind(&done);
3155 // Push function.
3156 __ push(v0);
3157 // The receiver is implicitly the global receiver. Indicate this
3158 // by passing the hole to the call function stub.
3159 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex);
3160 __ push(a1);
3161 __ bind(&call);
3162 }
3163 } else {
3164 VisitForStackValue(callee);
3165 // refEnv.WithBaseObject()
3166 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
3167 __ push(a2); // Reserved receiver slot.
3168 }
3169 }
3170
3171
3125 void FullCodeGenerator::VisitCall(Call* expr) { 3172 void FullCodeGenerator::VisitCall(Call* expr) {
3126 #ifdef DEBUG 3173 #ifdef DEBUG
3127 // We want to verify that RecordJSReturnSite gets called on all paths 3174 // We want to verify that RecordJSReturnSite gets called on all paths
3128 // through this function. Avoid early returns. 3175 // through this function. Avoid early returns.
3129 expr->return_is_recorded_ = false; 3176 expr->return_is_recorded_ = false;
3130 #endif 3177 #endif
3131 3178
3132 Comment cmnt(masm_, "[ Call"); 3179 Comment cmnt(masm_, "[ Call");
3133 Expression* callee = expr->expression(); 3180 Expression* callee = expr->expression();
3134 Call::CallType call_type = expr->GetCallType(isolate()); 3181 Call::CallType call_type = expr->GetCallType(isolate());
3135 3182
3136 if (call_type == Call::POSSIBLY_EVAL_CALL) { 3183 if (call_type == Call::POSSIBLY_EVAL_CALL) {
3137 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval 3184 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
3138 // to resolve the function we need to call. Then we call the resolved 3185 // to resolve the function we need to call. Then we call the resolved
3139 // function using the given arguments. 3186 // function using the given arguments.
3140 ZoneList<Expression*>* args = expr->arguments(); 3187 ZoneList<Expression*>* args = expr->arguments();
3141 int arg_count = args->length(); 3188 int arg_count = args->length();
3142 3189
3143 { PreservePositionScope pos_scope(masm()->positions_recorder()); 3190 { PreservePositionScope pos_scope(masm()->positions_recorder());
3144 VisitForStackValue(callee); 3191 PushCalleeAndWithBaseObject(expr);
3145 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
3146 __ push(a2); // Reserved receiver slot.
3147 3192
3148 // Push the arguments. 3193 // Push the arguments.
3149 for (int i = 0; i < arg_count; i++) { 3194 for (int i = 0; i < arg_count; i++) {
3150 VisitForStackValue(args->at(i)); 3195 VisitForStackValue(args->at(i));
3151 } 3196 }
3152 3197
3153 // Push a copy of the function (found below the arguments) and 3198 // Push a copy of the function (found below the arguments) and
3154 // resolve eval. 3199 // resolve eval.
3155 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); 3200 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
3156 __ push(a1); 3201 __ push(a1);
3157 EmitResolvePossiblyDirectEval(arg_count); 3202 EmitResolvePossiblyDirectEval(arg_count);
3158 3203
3159 // Touch up the stack with the resolved function. 3204 // Touch up the stack with the resolved function.
3160 __ sd(v0, MemOperand(sp, (arg_count + 1) * kPointerSize)); 3205 __ sd(v0, MemOperand(sp, (arg_count + 1) * kPointerSize));
3161 3206
3162 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS); 3207 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS);
3163 } 3208 }
3164 // Record source position for debugger. 3209 // Record source position for debugger.
3165 SetSourcePosition(expr->position()); 3210 SetSourcePosition(expr->position());
3166 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); 3211 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS);
3167 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); 3212 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
3168 __ CallStub(&stub); 3213 __ CallStub(&stub);
3169 RecordJSReturnSite(expr); 3214 RecordJSReturnSite(expr);
3170 // Restore context register. 3215 // Restore context register.
3171 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); 3216 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
3172 context()->DropAndPlug(1, v0); 3217 context()->DropAndPlug(1, v0);
3173 } else if (call_type == Call::GLOBAL_CALL) { 3218 } else if (call_type == Call::GLOBAL_CALL) {
3174 EmitCallWithLoadIC(expr); 3219 EmitCallWithLoadIC(expr);
3175 } else if (call_type == Call::LOOKUP_SLOT_CALL) { 3220 } else if (call_type == Call::LOOKUP_SLOT_CALL) {
3176 // Call to a lookup slot (dynamically introduced variable). 3221 // Call to a lookup slot (dynamically introduced variable).
3177 VariableProxy* proxy = callee->AsVariableProxy(); 3222 PushCalleeAndWithBaseObject(expr);
3178 Label slow, done;
3179
3180 { PreservePositionScope scope(masm()->positions_recorder());
3181 // Generate code for loading from variables potentially shadowed
3182 // by eval-introduced variables.
3183 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done);
3184 }
3185
3186 __ bind(&slow);
3187 // Call the runtime to find the function to call (returned in v0)
3188 // and the object holding it (returned in v1).
3189 DCHECK(!context_register().is(a2));
3190 __ li(a2, Operand(proxy->name()));
3191 __ Push(context_register(), a2);
3192 __ CallRuntime(Runtime::kLoadLookupSlot, 2);
3193 __ Push(v0, v1); // Function, receiver.
3194 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS);
3195
3196 // If fast case code has been generated, emit code to push the
3197 // function and receiver and have the slow path jump around this
3198 // code.
3199 if (done.is_linked()) {
3200 Label call;
3201 __ Branch(&call);
3202 __ bind(&done);
3203 // Push function.
3204 __ push(v0);
3205 // The receiver is implicitly the global receiver. Indicate this
3206 // by passing the hole to the call function stub.
3207 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex);
3208 __ push(a1);
3209 __ bind(&call);
3210 }
3211
3212 // The receiver is either the global receiver or an object found
3213 // by LoadContextSlot.
3214 EmitCall(expr); 3223 EmitCall(expr);
3215 } else if (call_type == Call::PROPERTY_CALL) { 3224 } else if (call_type == Call::PROPERTY_CALL) {
3216 Property* property = callee->AsProperty(); 3225 Property* property = callee->AsProperty();
3217 bool is_named_call = property->key()->IsPropertyName(); 3226 bool is_named_call = property->key()->IsPropertyName();
3218 if (property->IsSuperAccess()) { 3227 if (property->IsSuperAccess()) {
3219 if (is_named_call) { 3228 if (is_named_call) {
3220 EmitSuperCallWithLoadIC(expr); 3229 EmitSuperCallWithLoadIC(expr);
3221 } else { 3230 } else {
3222 EmitKeyedSuperCallWithLoadIC(expr); 3231 EmitKeyedSuperCallWithLoadIC(expr);
3223 } 3232 }
(...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after
5568 reinterpret_cast<uint64_t>( 5577 reinterpret_cast<uint64_t>(
5569 isolate->builtins()->OsrAfterStackCheck()->entry())); 5578 isolate->builtins()->OsrAfterStackCheck()->entry()));
5570 return OSR_AFTER_STACK_CHECK; 5579 return OSR_AFTER_STACK_CHECK;
5571 } 5580 }
5572 5581
5573 5582
5574 } // namespace internal 5583 } // namespace internal
5575 } // namespace v8 5584 } // namespace v8
5576 5585
5577 #endif // V8_TARGET_ARCH_MIPS64 5586 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | src/ppc/full-codegen-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698