| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 3472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3483 void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) { | 3483 void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) { |
| 3484 DCHECK(ToRegister(instr->context()).is(rsi)); | 3484 DCHECK(ToRegister(instr->context()).is(rsi)); |
| 3485 __ Push(rsi); // The context is the first argument. | 3485 __ Push(rsi); // The context is the first argument. |
| 3486 __ Push(instr->hydrogen()->pairs()); | 3486 __ Push(instr->hydrogen()->pairs()); |
| 3487 __ Push(Smi::FromInt(instr->hydrogen()->flags())); | 3487 __ Push(Smi::FromInt(instr->hydrogen()->flags())); |
| 3488 CallRuntime(Runtime::kDeclareGlobals, 3, instr); | 3488 CallRuntime(Runtime::kDeclareGlobals, 3, instr); |
| 3489 } | 3489 } |
| 3490 | 3490 |
| 3491 | 3491 |
| 3492 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, | 3492 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
| 3493 int formal_parameter_count, | 3493 int formal_parameter_count, int arity, |
| 3494 int arity, | 3494 LInstruction* instr) { |
| 3495 LInstruction* instr, | |
| 3496 RDIState rdi_state) { | |
| 3497 bool dont_adapt_arguments = | 3495 bool dont_adapt_arguments = |
| 3498 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; | 3496 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; |
| 3499 bool can_invoke_directly = | 3497 bool can_invoke_directly = |
| 3500 dont_adapt_arguments || formal_parameter_count == arity; | 3498 dont_adapt_arguments || formal_parameter_count == arity; |
| 3501 | 3499 |
| 3500 Register function_reg = rdi; |
| 3502 LPointerMap* pointers = instr->pointer_map(); | 3501 LPointerMap* pointers = instr->pointer_map(); |
| 3503 | 3502 |
| 3504 if (can_invoke_directly) { | 3503 if (can_invoke_directly) { |
| 3505 if (rdi_state == RDI_UNINITIALIZED) { | |
| 3506 __ Move(rdi, function); | |
| 3507 } | |
| 3508 | |
| 3509 // Change context. | 3504 // Change context. |
| 3510 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 3505 __ movp(rsi, FieldOperand(function_reg, JSFunction::kContextOffset)); |
| 3511 | 3506 |
| 3512 // Set rax to arguments count if adaption is not needed. Assumes that rax | 3507 // Set rax to arguments count if adaption is not needed. Assumes that rax |
| 3513 // is available to write to at this point. | 3508 // is available to write to at this point. |
| 3514 if (dont_adapt_arguments) { | 3509 if (dont_adapt_arguments) { |
| 3515 __ Set(rax, arity); | 3510 __ Set(rax, arity); |
| 3516 } | 3511 } |
| 3517 | 3512 |
| 3518 // Invoke function. | 3513 // Invoke function. |
| 3519 if (function.is_identical_to(info()->closure())) { | 3514 if (function.is_identical_to(info()->closure())) { |
| 3520 __ CallSelf(); | 3515 __ CallSelf(); |
| 3521 } else { | 3516 } else { |
| 3522 __ Call(FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 3517 __ Call(FieldOperand(function_reg, JSFunction::kCodeEntryOffset)); |
| 3523 } | 3518 } |
| 3524 | 3519 |
| 3525 // Set up deoptimization. | 3520 // Set up deoptimization. |
| 3526 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT, 0); | 3521 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT, 0); |
| 3527 } else { | 3522 } else { |
| 3528 // We need to adapt arguments. | 3523 // We need to adapt arguments. |
| 3529 SafepointGenerator generator( | 3524 SafepointGenerator generator( |
| 3530 this, pointers, Safepoint::kLazyDeopt); | 3525 this, pointers, Safepoint::kLazyDeopt); |
| 3531 ParameterCount count(arity); | 3526 ParameterCount count(arity); |
| 3532 ParameterCount expected(formal_parameter_count); | 3527 ParameterCount expected(formal_parameter_count); |
| 3533 __ InvokeFunction(function, expected, count, CALL_FUNCTION, generator); | 3528 __ InvokeFunction(function_reg, expected, count, CALL_FUNCTION, generator); |
| 3534 } | 3529 } |
| 3535 } | 3530 } |
| 3536 | 3531 |
| 3537 | 3532 |
| 3538 void LCodeGen::DoTailCallThroughMegamorphicCache( | 3533 void LCodeGen::DoTailCallThroughMegamorphicCache( |
| 3539 LTailCallThroughMegamorphicCache* instr) { | 3534 LTailCallThroughMegamorphicCache* instr) { |
| 3540 Register receiver = ToRegister(instr->receiver()); | 3535 Register receiver = ToRegister(instr->receiver()); |
| 3541 Register name = ToRegister(instr->name()); | 3536 Register name = ToRegister(instr->name()); |
| 3542 DCHECK(receiver.is(LoadDescriptor::ReceiverRegister())); | 3537 DCHECK(receiver.is(LoadDescriptor::ReceiverRegister())); |
| 3543 DCHECK(name.is(LoadDescriptor::NameRegister())); | 3538 DCHECK(name.is(LoadDescriptor::NameRegister())); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4013 | 4008 |
| 4014 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); | 4009 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); |
| 4015 if (known_function.is_null()) { | 4010 if (known_function.is_null()) { |
| 4016 LPointerMap* pointers = instr->pointer_map(); | 4011 LPointerMap* pointers = instr->pointer_map(); |
| 4017 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); | 4012 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
| 4018 ParameterCount count(instr->arity()); | 4013 ParameterCount count(instr->arity()); |
| 4019 __ InvokeFunction(rdi, count, CALL_FUNCTION, generator); | 4014 __ InvokeFunction(rdi, count, CALL_FUNCTION, generator); |
| 4020 } else { | 4015 } else { |
| 4021 CallKnownFunction(known_function, | 4016 CallKnownFunction(known_function, |
| 4022 instr->hydrogen()->formal_parameter_count(), | 4017 instr->hydrogen()->formal_parameter_count(), |
| 4023 instr->arity(), | 4018 instr->arity(), instr); |
| 4024 instr, | |
| 4025 RDI_CONTAINS_TARGET); | |
| 4026 } | 4019 } |
| 4027 } | 4020 } |
| 4028 | 4021 |
| 4029 | 4022 |
| 4030 void LCodeGen::DoCallFunction(LCallFunction* instr) { | 4023 void LCodeGen::DoCallFunction(LCallFunction* instr) { |
| 4031 DCHECK(ToRegister(instr->context()).is(rsi)); | 4024 DCHECK(ToRegister(instr->context()).is(rsi)); |
| 4032 DCHECK(ToRegister(instr->function()).is(rdi)); | 4025 DCHECK(ToRegister(instr->function()).is(rdi)); |
| 4033 DCHECK(ToRegister(instr->result()).is(rax)); | 4026 DCHECK(ToRegister(instr->result()).is(rax)); |
| 4034 | 4027 |
| 4035 int arity = instr->arity(); | 4028 int arity = instr->arity(); |
| (...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5916 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5909 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 5917 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5910 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 5918 } | 5911 } |
| 5919 | 5912 |
| 5920 | 5913 |
| 5921 #undef __ | 5914 #undef __ |
| 5922 | 5915 |
| 5923 } } // namespace v8::internal | 5916 } } // namespace v8::internal |
| 5924 | 5917 |
| 5925 #endif // V8_TARGET_ARCH_X64 | 5918 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |