| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 7 #if V8_TARGET_ARCH_PPC |
| 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 3107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3118 __ beq(&uninitialized_this); | 3118 __ beq(&uninitialized_this); |
| 3119 __ mov(r4, Operand(this_var->name())); | 3119 __ mov(r4, Operand(this_var->name())); |
| 3120 __ push(r4); | 3120 __ push(r4); |
| 3121 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 3121 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 3122 __ bind(&uninitialized_this); | 3122 __ bind(&uninitialized_this); |
| 3123 | 3123 |
| 3124 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); | 3124 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); |
| 3125 } | 3125 } |
| 3126 | 3126 |
| 3127 | 3127 |
| 3128 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. | |
| 3129 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { | |
| 3130 VariableProxy* callee = expr->expression()->AsVariableProxy(); | |
| 3131 if (callee->var()->IsLookupSlot()) { | |
| 3132 Label slow, done; | |
| 3133 | |
| 3134 { | |
| 3135 PreservePositionScope scope(masm()->positions_recorder()); | |
| 3136 // Generate code for loading from variables potentially shadowed by | |
| 3137 // eval-introduced variables. | |
| 3138 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); | |
| 3139 } | |
| 3140 __ bind(&slow); | |
| 3141 // Call the runtime to find the function to call (returned in rax) and | |
| 3142 // the object holding it (returned in rdx). | |
| 3143 __ Push(context_register()); | |
| 3144 __ Push(callee->name()); | |
| 3145 __ CallRuntime(Runtime::kLoadLookupSlot, 2); | |
| 3146 __ Push(rax); // Function. | |
| 3147 __ Push(rdx); // Receiver. | |
| 3148 PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS); | |
| 3149 | |
| 3150 // If fast case code has been generated, emit code to push the function | |
| 3151 // and receiver and have the slow path jump around this code. | |
| 3152 if (done.is_linked()) { | |
| 3153 Label call; | |
| 3154 __ jmp(&call, Label::kNear); | |
| 3155 __ bind(&done); | |
| 3156 // Push function. | |
| 3157 __ Push(rax); | |
| 3158 // Pass undefined as the receiver, which is the WithBaseObject of a | |
| 3159 // non-object environment record. If the callee is sloppy, it will patch | |
| 3160 // it up to be the global receiver. | |
| 3161 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
| 3162 __ bind(&call); | |
| 3163 } | |
| 3164 } else { | |
| 3165 VisitForStackValue(callee); | |
| 3166 // refEnv.WithBaseObject() | |
| 3167 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); | |
| 3168 __ push(r5); | |
| 3169 } | |
| 3170 } | |
| 3171 | |
| 3172 | |
| 3173 void FullCodeGenerator::VisitCall(Call* expr) { | 3128 void FullCodeGenerator::VisitCall(Call* expr) { |
| 3174 #ifdef DEBUG | 3129 #ifdef DEBUG |
| 3175 // We want to verify that RecordJSReturnSite gets called on all paths | 3130 // We want to verify that RecordJSReturnSite gets called on all paths |
| 3176 // through this function. Avoid early returns. | 3131 // through this function. Avoid early returns. |
| 3177 expr->return_is_recorded_ = false; | 3132 expr->return_is_recorded_ = false; |
| 3178 #endif | 3133 #endif |
| 3179 | 3134 |
| 3180 Comment cmnt(masm_, "[ Call"); | 3135 Comment cmnt(masm_, "[ Call"); |
| 3181 Expression* callee = expr->expression(); | 3136 Expression* callee = expr->expression(); |
| 3182 Call::CallType call_type = expr->GetCallType(isolate()); | 3137 Call::CallType call_type = expr->GetCallType(isolate()); |
| 3183 | 3138 |
| 3184 if (call_type == Call::POSSIBLY_EVAL_CALL) { | 3139 if (call_type == Call::POSSIBLY_EVAL_CALL) { |
| 3185 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval | 3140 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval |
| 3186 // to resolve the function we need to call. Then we call the resolved | 3141 // to resolve the function we need to call. Then we call the resolved |
| 3187 // function using the given arguments. | 3142 // function using the given arguments. |
| 3188 ZoneList<Expression*>* args = expr->arguments(); | 3143 ZoneList<Expression*>* args = expr->arguments(); |
| 3189 int arg_count = args->length(); | 3144 int arg_count = args->length(); |
| 3190 | 3145 |
| 3191 { | 3146 { |
| 3192 PreservePositionScope pos_scope(masm()->positions_recorder()); | 3147 PreservePositionScope pos_scope(masm()->positions_recorder()); |
| 3193 PushCalleeAndWithBaseObject(expr); | 3148 VisitForStackValue(callee); |
| 3149 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
| 3150 __ push(r5); // Reserved receiver slot. |
| 3194 | 3151 |
| 3195 // Push the arguments. | 3152 // Push the arguments. |
| 3196 for (int i = 0; i < arg_count; i++) { | 3153 for (int i = 0; i < arg_count; i++) { |
| 3197 VisitForStackValue(args->at(i)); | 3154 VisitForStackValue(args->at(i)); |
| 3198 } | 3155 } |
| 3199 | 3156 |
| 3200 // Push a copy of the function (found below the arguments) and | 3157 // Push a copy of the function (found below the arguments) and |
| 3201 // resolve eval. | 3158 // resolve eval. |
| 3202 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); | 3159 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
| 3203 __ push(r4); | 3160 __ push(r4); |
| 3204 EmitResolvePossiblyDirectEval(arg_count); | 3161 EmitResolvePossiblyDirectEval(arg_count); |
| 3205 | 3162 |
| 3206 // Touch up the stack with the resolved function. | 3163 // Touch up the stack with the resolved function. |
| 3207 __ StoreP(r3, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); | 3164 __ StoreP(r3, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
| 3208 | 3165 |
| 3209 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 3166 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS); |
| 3210 } | 3167 } |
| 3211 | 3168 |
| 3212 // Record source position for debugger. | 3169 // Record source position for debugger. |
| 3213 SetSourcePosition(expr->position()); | 3170 SetSourcePosition(expr->position()); |
| 3214 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 3171 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
| 3215 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); | 3172 __ LoadP(r4, MemOperand(sp, (arg_count + 1) * kPointerSize), r0); |
| 3216 __ CallStub(&stub); | 3173 __ CallStub(&stub); |
| 3217 RecordJSReturnSite(expr); | 3174 RecordJSReturnSite(expr); |
| 3218 // Restore context register. | 3175 // Restore context register. |
| 3219 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 3176 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 3220 context()->DropAndPlug(1, r3); | 3177 context()->DropAndPlug(1, r3); |
| 3221 } else if (call_type == Call::GLOBAL_CALL) { | 3178 } else if (call_type == Call::GLOBAL_CALL) { |
| 3222 EmitCallWithLoadIC(expr); | 3179 EmitCallWithLoadIC(expr); |
| 3223 | 3180 |
| 3224 } else if (call_type == Call::LOOKUP_SLOT_CALL) { | 3181 } else if (call_type == Call::LOOKUP_SLOT_CALL) { |
| 3225 // Call to a lookup slot (dynamically introduced variable). | 3182 // Call to a lookup slot (dynamically introduced variable). |
| 3226 PushCalleeAndWithBaseObject(expr); | 3183 VariableProxy* proxy = callee->AsVariableProxy(); |
| 3184 Label slow, done; |
| 3185 |
| 3186 { |
| 3187 PreservePositionScope scope(masm()->positions_recorder()); |
| 3188 // Generate code for loading from variables potentially shadowed |
| 3189 // by eval-introduced variables. |
| 3190 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); |
| 3191 } |
| 3192 |
| 3193 __ bind(&slow); |
| 3194 // Call the runtime to find the function to call (returned in r3) |
| 3195 // and the object holding it (returned in edx). |
| 3196 DCHECK(!context_register().is(r5)); |
| 3197 __ mov(r5, Operand(proxy->name())); |
| 3198 __ Push(context_register(), r5); |
| 3199 __ CallRuntime(Runtime::kLoadLookupSlot, 2); |
| 3200 __ Push(r3, r4); // Function, receiver. |
| 3201 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS); |
| 3202 |
| 3203 // If fast case code has been generated, emit code to push the |
| 3204 // function and receiver and have the slow path jump around this |
| 3205 // code. |
| 3206 if (done.is_linked()) { |
| 3207 Label call; |
| 3208 __ b(&call); |
| 3209 __ bind(&done); |
| 3210 // Push function. |
| 3211 __ push(r3); |
| 3212 // The receiver is implicitly the global receiver. Indicate this |
| 3213 // by passing the hole to the call function stub. |
| 3214 __ LoadRoot(r4, Heap::kUndefinedValueRootIndex); |
| 3215 __ push(r4); |
| 3216 __ bind(&call); |
| 3217 } |
| 3218 |
| 3219 // The receiver is either the global receiver or an object found |
| 3220 // by LoadContextSlot. |
| 3227 EmitCall(expr); | 3221 EmitCall(expr); |
| 3228 } else if (call_type == Call::PROPERTY_CALL) { | 3222 } else if (call_type == Call::PROPERTY_CALL) { |
| 3229 Property* property = callee->AsProperty(); | 3223 Property* property = callee->AsProperty(); |
| 3230 bool is_named_call = property->key()->IsPropertyName(); | 3224 bool is_named_call = property->key()->IsPropertyName(); |
| 3231 if (property->IsSuperAccess()) { | 3225 if (property->IsSuperAccess()) { |
| 3232 if (is_named_call) { | 3226 if (is_named_call) { |
| 3233 EmitSuperCallWithLoadIC(expr); | 3227 EmitSuperCallWithLoadIC(expr); |
| 3234 } else { | 3228 } else { |
| 3235 EmitKeyedSuperCallWithLoadIC(expr); | 3229 EmitKeyedSuperCallWithLoadIC(expr); |
| 3236 } | 3230 } |
| (...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5566 return ON_STACK_REPLACEMENT; | 5560 return ON_STACK_REPLACEMENT; |
| 5567 } | 5561 } |
| 5568 | 5562 |
| 5569 DCHECK(interrupt_address == | 5563 DCHECK(interrupt_address == |
| 5570 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5564 isolate->builtins()->OsrAfterStackCheck()->entry()); |
| 5571 return OSR_AFTER_STACK_CHECK; | 5565 return OSR_AFTER_STACK_CHECK; |
| 5572 } | 5566 } |
| 5573 } // namespace internal | 5567 } // namespace internal |
| 5574 } // namespace v8 | 5568 } // namespace v8 |
| 5575 #endif // V8_TARGET_ARCH_PPC | 5569 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |