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

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

Powered by Google App Engine
This is Rietveld 408576698