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/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 700 |
701 void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag, | 701 void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag, |
702 const CallWrapper& call_wrapper) { | 702 const CallWrapper& call_wrapper) { |
703 // You can't call a builtin without a valid frame. | 703 // You can't call a builtin without a valid frame. |
704 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 704 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
705 | 705 |
706 // Rely on the assertion to check that the number of provided | 706 // Rely on the assertion to check that the number of provided |
707 // arguments match the expected number of arguments. Fake a | 707 // arguments match the expected number of arguments. Fake a |
708 // parameter count to avoid emitting code to do the check. | 708 // parameter count to avoid emitting code to do the check. |
709 ParameterCount expected(0); | 709 ParameterCount expected(0); |
710 GetBuiltinEntry(rdx, native_context_index); | 710 GetBuiltinEntry(r8, native_context_index); |
711 InvokeCode(rdx, expected, expected, flag, call_wrapper); | 711 InvokeCode(r8, no_reg, expected, expected, flag, call_wrapper); |
712 } | 712 } |
713 | 713 |
714 | 714 |
715 void MacroAssembler::GetBuiltinFunction(Register target, | 715 void MacroAssembler::GetBuiltinFunction(Register target, |
716 int native_context_index) { | 716 int native_context_index) { |
717 // Load the builtins object into target register. | 717 // Load the builtins object into target register. |
718 movp(target, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 718 movp(target, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
719 movp(target, FieldOperand(target, JSGlobalObject::kNativeContextOffset)); | 719 movp(target, FieldOperand(target, JSGlobalObject::kNativeContextOffset)); |
720 movp(target, ContextOperand(target, native_context_index)); | 720 movp(target, ContextOperand(target, native_context_index)); |
721 } | 721 } |
(...skipping 3247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3969 Set(rax, 0); // No arguments. | 3969 Set(rax, 0); // No arguments. |
3970 LoadAddress(rbx, | 3970 LoadAddress(rbx, |
3971 ExternalReference(Runtime::kHandleDebuggerStatement, isolate())); | 3971 ExternalReference(Runtime::kHandleDebuggerStatement, isolate())); |
3972 CEntryStub ces(isolate(), 1); | 3972 CEntryStub ces(isolate(), 1); |
3973 DCHECK(AllowThisStubCall(&ces)); | 3973 DCHECK(AllowThisStubCall(&ces)); |
3974 Call(ces.GetCode(), RelocInfo::DEBUGGER_STATEMENT); | 3974 Call(ces.GetCode(), RelocInfo::DEBUGGER_STATEMENT); |
3975 } | 3975 } |
3976 | 3976 |
3977 | 3977 |
3978 void MacroAssembler::InvokeFunction(Register function, | 3978 void MacroAssembler::InvokeFunction(Register function, |
| 3979 Register new_target, |
3979 const ParameterCount& actual, | 3980 const ParameterCount& actual, |
3980 InvokeFlag flag, | 3981 InvokeFlag flag, |
3981 const CallWrapper& call_wrapper) { | 3982 const CallWrapper& call_wrapper) { |
3982 movp(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); | 3983 movp(rbx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
3983 LoadSharedFunctionInfoSpecialField( | 3984 LoadSharedFunctionInfoSpecialField( |
3984 rbx, rdx, SharedFunctionInfo::kFormalParameterCountOffset); | 3985 rbx, rbx, SharedFunctionInfo::kFormalParameterCountOffset); |
3985 | 3986 |
3986 ParameterCount expected(rbx); | 3987 ParameterCount expected(rbx); |
3987 InvokeFunction(function, expected, actual, flag, call_wrapper); | 3988 InvokeFunction(function, new_target, expected, actual, flag, call_wrapper); |
3988 } | 3989 } |
3989 | 3990 |
3990 | 3991 |
3991 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, | 3992 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, |
3992 const ParameterCount& expected, | 3993 const ParameterCount& expected, |
3993 const ParameterCount& actual, | 3994 const ParameterCount& actual, |
3994 InvokeFlag flag, | 3995 InvokeFlag flag, |
3995 const CallWrapper& call_wrapper) { | 3996 const CallWrapper& call_wrapper) { |
3996 Move(rdi, function); | 3997 Move(rdi, function); |
3997 InvokeFunction(rdi, expected, actual, flag, call_wrapper); | 3998 InvokeFunction(rdi, no_reg, expected, actual, flag, call_wrapper); |
3998 } | 3999 } |
3999 | 4000 |
4000 | 4001 |
4001 void MacroAssembler::InvokeFunction(Register function, | 4002 void MacroAssembler::InvokeFunction(Register function, |
| 4003 Register new_target, |
4002 const ParameterCount& expected, | 4004 const ParameterCount& expected, |
4003 const ParameterCount& actual, | 4005 const ParameterCount& actual, |
4004 InvokeFlag flag, | 4006 InvokeFlag flag, |
4005 const CallWrapper& call_wrapper) { | 4007 const CallWrapper& call_wrapper) { |
4006 DCHECK(function.is(rdi)); | 4008 DCHECK(function.is(rdi)); |
4007 movp(rsi, FieldOperand(function, JSFunction::kContextOffset)); | 4009 movp(rsi, FieldOperand(function, JSFunction::kContextOffset)); |
4008 // Advances rdx to the end of the Code object header, to the start of | 4010 // Advances r8 to the end of the Code object header, to the start of |
4009 // the executable code. | 4011 // the executable code. |
4010 movp(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 4012 movp(r8, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
4011 InvokeCode(rdx, expected, actual, flag, call_wrapper); | 4013 InvokeCode(r8, new_target, expected, actual, flag, call_wrapper); |
4012 } | 4014 } |
4013 | 4015 |
4014 | 4016 |
4015 void MacroAssembler::InvokeCode(Register code, | 4017 void MacroAssembler::InvokeCode(Register code, |
| 4018 Register new_target, |
4016 const ParameterCount& expected, | 4019 const ParameterCount& expected, |
4017 const ParameterCount& actual, | 4020 const ParameterCount& actual, |
4018 InvokeFlag flag, | 4021 InvokeFlag flag, |
4019 const CallWrapper& call_wrapper) { | 4022 const CallWrapper& call_wrapper) { |
4020 // You can't call a function without a valid frame. | 4023 // You can't call a function without a valid frame. |
4021 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 4024 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
4022 | 4025 |
| 4026 // Ensure new target is passed in the correct register. Otherwise clear the |
| 4027 // appropriate register in case new target is not given. |
| 4028 DCHECK_IMPLIES(new_target.is_valid(), new_target.is(rdx)); |
| 4029 if (!new_target.is_valid()) { |
| 4030 LoadRoot(rdx, Heap::kUndefinedValueRootIndex); |
| 4031 } |
| 4032 |
4023 Label done; | 4033 Label done; |
4024 bool definitely_mismatches = false; | 4034 bool definitely_mismatches = false; |
4025 InvokePrologue(expected, | 4035 InvokePrologue(expected, |
4026 actual, | 4036 actual, |
4027 &done, | 4037 &done, |
4028 &definitely_mismatches, | 4038 &definitely_mismatches, |
4029 flag, | 4039 flag, |
4030 Label::kNear, | 4040 Label::kNear, |
4031 call_wrapper); | 4041 call_wrapper); |
4032 if (!definitely_mismatches) { | 4042 if (!definitely_mismatches) { |
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5502 movl(rax, dividend); | 5512 movl(rax, dividend); |
5503 shrl(rax, Immediate(31)); | 5513 shrl(rax, Immediate(31)); |
5504 addl(rdx, rax); | 5514 addl(rdx, rax); |
5505 } | 5515 } |
5506 | 5516 |
5507 | 5517 |
5508 } // namespace internal | 5518 } // namespace internal |
5509 } // namespace v8 | 5519 } // namespace v8 |
5510 | 5520 |
5511 #endif // V8_TARGET_ARCH_X64 | 5521 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |