| 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 691 |
| 692 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext, | 692 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext, |
| 693 int result_size) { | 693 int result_size) { |
| 694 // Set the entry point and jump to the C entry runtime stub. | 694 // Set the entry point and jump to the C entry runtime stub. |
| 695 LoadAddress(rbx, ext); | 695 LoadAddress(rbx, ext); |
| 696 CEntryStub ces(isolate(), result_size); | 696 CEntryStub ces(isolate(), result_size); |
| 697 jmp(ces.GetCode(), RelocInfo::CODE_TARGET); | 697 jmp(ces.GetCode(), RelocInfo::CODE_TARGET); |
| 698 } | 698 } |
| 699 | 699 |
| 700 | 700 |
| 701 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, | 701 void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag, |
| 702 InvokeFlag flag, | |
| 703 const CallWrapper& call_wrapper) { | 702 const CallWrapper& call_wrapper) { |
| 704 // You can't call a builtin without a valid frame. | 703 // You can't call a builtin without a valid frame. |
| 705 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 704 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
| 706 | 705 |
| 707 // Rely on the assertion to check that the number of provided | 706 // Rely on the assertion to check that the number of provided |
| 708 // arguments match the expected number of arguments. Fake a | 707 // arguments match the expected number of arguments. Fake a |
| 709 // parameter count to avoid emitting code to do the check. | 708 // parameter count to avoid emitting code to do the check. |
| 710 ParameterCount expected(0); | 709 ParameterCount expected(0); |
| 711 GetBuiltinEntry(rdx, id); | 710 GetBuiltinEntry(rdx, native_context_index); |
| 712 InvokeCode(rdx, expected, expected, flag, call_wrapper); | 711 InvokeCode(rdx, expected, expected, flag, call_wrapper); |
| 713 } | 712 } |
| 714 | 713 |
| 715 | 714 |
| 716 void MacroAssembler::GetBuiltinFunction(Register target, | 715 void MacroAssembler::GetBuiltinFunction(Register target, |
| 717 Builtins::JavaScript id) { | 716 int native_context_index) { |
| 718 // Load the builtins object into target register. | 717 // Load the builtins object into target register. |
| 719 movp(target, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 718 movp(target, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 720 movp(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); | 719 movp(target, FieldOperand(target, GlobalObject::kNativeContextOffset)); |
| 721 movp(target, FieldOperand(target, | 720 movp(target, ContextOperand(target, native_context_index)); |
| 722 JSBuiltinsObject::OffsetOfFunctionWithId(id))); | |
| 723 } | 721 } |
| 724 | 722 |
| 725 | 723 |
| 726 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { | 724 void MacroAssembler::GetBuiltinEntry(Register target, |
| 725 int native_context_index) { |
| 727 DCHECK(!target.is(rdi)); | 726 DCHECK(!target.is(rdi)); |
| 728 // Load the JavaScript builtin function from the builtins object. | 727 // Load the JavaScript builtin function from the builtins object. |
| 729 GetBuiltinFunction(rdi, id); | 728 GetBuiltinFunction(rdi, native_context_index); |
| 730 movp(target, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 729 movp(target, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
| 731 } | 730 } |
| 732 | 731 |
| 733 | 732 |
| 734 #define REG(Name) { kRegister_ ## Name ## _Code } | 733 #define REG(Name) { kRegister_ ## Name ## _Code } |
| 735 | 734 |
| 736 static const Register saved_regs[] = { | 735 static const Register saved_regs[] = { |
| 737 REG(rax), REG(rcx), REG(rdx), REG(rbx), REG(rbp), REG(rsi), REG(rdi), REG(r8), | 736 REG(rax), REG(rcx), REG(rdx), REG(rbx), REG(rbp), REG(rsi), REG(rdi), REG(r8), |
| 738 REG(r9), REG(r10), REG(r11) | 737 REG(r9), REG(r10), REG(r11) |
| 739 }; | 738 }; |
| (...skipping 4308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5048 movl(rax, dividend); | 5047 movl(rax, dividend); |
| 5049 shrl(rax, Immediate(31)); | 5048 shrl(rax, Immediate(31)); |
| 5050 addl(rdx, rax); | 5049 addl(rdx, rax); |
| 5051 } | 5050 } |
| 5052 | 5051 |
| 5053 | 5052 |
| 5054 } // namespace internal | 5053 } // namespace internal |
| 5055 } // namespace v8 | 5054 } // namespace v8 |
| 5056 | 5055 |
| 5057 #endif // V8_TARGET_ARCH_X64 | 5056 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |