OLD | NEW |
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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 3212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3223 | 3223 |
3224 __ bind(&runtime); | 3224 __ bind(&runtime); |
3225 CallRuntimeWithOperands(Runtime::kCreateIterResultObject); | 3225 CallRuntimeWithOperands(Runtime::kCreateIterResultObject); |
3226 | 3226 |
3227 __ bind(&done); | 3227 __ bind(&done); |
3228 context()->Plug(rax); | 3228 context()->Plug(rax); |
3229 } | 3229 } |
3230 | 3230 |
3231 | 3231 |
3232 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 3232 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
3233 // Push the builtins object as receiver. | 3233 // Push function. |
| 3234 __ LoadNativeContextSlot(expr->context_index(), rax); |
| 3235 PushOperand(rax); |
| 3236 |
| 3237 // Push undefined as receiver. |
3234 OperandStackDepthIncrement(1); | 3238 OperandStackDepthIncrement(1); |
3235 __ PushRoot(Heap::kUndefinedValueRootIndex); | 3239 __ PushRoot(Heap::kUndefinedValueRootIndex); |
3236 | |
3237 __ LoadNativeContextSlot(expr->context_index(), rax); | |
3238 } | 3240 } |
3239 | 3241 |
3240 | 3242 |
3241 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 3243 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
3242 ZoneList<Expression*>* args = expr->arguments(); | 3244 ZoneList<Expression*>* args = expr->arguments(); |
3243 int arg_count = args->length(); | 3245 int arg_count = args->length(); |
3244 | 3246 |
3245 SetCallPosition(expr); | 3247 SetCallPosition(expr); |
3246 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 3248 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
3247 __ Set(rax, arg_count); | 3249 __ Set(rax, arg_count); |
3248 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined), | 3250 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined), |
3249 RelocInfo::CODE_TARGET); | 3251 RelocInfo::CODE_TARGET); |
3250 OperandStackDepthDecrement(arg_count + 1); | 3252 OperandStackDepthDecrement(arg_count + 1); |
3251 } | 3253 } |
3252 | 3254 |
3253 | 3255 |
3254 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 3256 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
3255 ZoneList<Expression*>* args = expr->arguments(); | 3257 ZoneList<Expression*>* args = expr->arguments(); |
3256 int arg_count = args->length(); | 3258 int arg_count = args->length(); |
3257 | 3259 |
3258 if (expr->is_jsruntime()) { | 3260 if (expr->is_jsruntime()) { |
3259 Comment cmnt(masm_, "[ CallRuntime"); | 3261 Comment cmnt(masm_, "[ CallRuntime"); |
3260 | |
3261 EmitLoadJSRuntimeFunction(expr); | 3262 EmitLoadJSRuntimeFunction(expr); |
3262 | 3263 |
3263 // Push the target function under the receiver. | |
3264 PushOperand(Operand(rsp, 0)); | |
3265 __ movp(Operand(rsp, kPointerSize), rax); | |
3266 | |
3267 // Push the arguments ("left-to-right"). | 3264 // Push the arguments ("left-to-right"). |
3268 for (int i = 0; i < arg_count; i++) { | 3265 for (int i = 0; i < arg_count; i++) { |
3269 VisitForStackValue(args->at(i)); | 3266 VisitForStackValue(args->at(i)); |
3270 } | 3267 } |
3271 | 3268 |
3272 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 3269 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); |
3273 EmitCallJSRuntimeFunction(expr); | 3270 EmitCallJSRuntimeFunction(expr); |
3274 | 3271 |
3275 // Restore context register. | 3272 // Restore context register. |
3276 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 3273 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4030 DCHECK_EQ( | 4027 DCHECK_EQ( |
4031 isolate->builtins()->OnStackReplacement()->entry(), | 4028 isolate->builtins()->OnStackReplacement()->entry(), |
4032 Assembler::target_address_at(call_target_address, unoptimized_code)); | 4029 Assembler::target_address_at(call_target_address, unoptimized_code)); |
4033 return ON_STACK_REPLACEMENT; | 4030 return ON_STACK_REPLACEMENT; |
4034 } | 4031 } |
4035 | 4032 |
4036 } // namespace internal | 4033 } // namespace internal |
4037 } // namespace v8 | 4034 } // namespace v8 |
4038 | 4035 |
4039 #endif // V8_TARGET_ARCH_X64 | 4036 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |