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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 ParameterCount expected(0); | 709 ParameterCount expected(0); |
710 GetBuiltinEntry(rdx, native_context_index); | 710 GetBuiltinEntry(rdx, native_context_index); |
711 InvokeCode(rdx, expected, expected, flag, call_wrapper); | 711 InvokeCode(rdx, 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, GlobalObject::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 } |
722 | 722 |
723 | 723 |
724 void MacroAssembler::GetBuiltinEntry(Register target, | 724 void MacroAssembler::GetBuiltinEntry(Register target, |
725 int native_context_index) { | 725 int native_context_index) { |
726 DCHECK(!target.is(rdi)); | 726 DCHECK(!target.is(rdi)); |
727 // Load the JavaScript builtin function from the builtins object. | 727 // Load the JavaScript builtin function from the builtins object. |
728 GetBuiltinFunction(rdi, native_context_index); | 728 GetBuiltinFunction(rdi, native_context_index); |
729 movp(target, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 729 movp(target, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
(...skipping 3469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4199 | 4199 |
4200 // When generating debug code, make sure the lexical context is set. | 4200 // When generating debug code, make sure the lexical context is set. |
4201 if (emit_debug_code()) { | 4201 if (emit_debug_code()) { |
4202 cmpp(scratch, Immediate(0)); | 4202 cmpp(scratch, Immediate(0)); |
4203 Check(not_equal, kWeShouldNotHaveAnEmptyLexicalContext); | 4203 Check(not_equal, kWeShouldNotHaveAnEmptyLexicalContext); |
4204 } | 4204 } |
4205 // Load the native context of the current context. | 4205 // Load the native context of the current context. |
4206 int offset = | 4206 int offset = |
4207 Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize; | 4207 Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize; |
4208 movp(scratch, FieldOperand(scratch, offset)); | 4208 movp(scratch, FieldOperand(scratch, offset)); |
4209 movp(scratch, FieldOperand(scratch, GlobalObject::kNativeContextOffset)); | 4209 movp(scratch, FieldOperand(scratch, JSGlobalObject::kNativeContextOffset)); |
4210 | 4210 |
4211 // Check the context is a native context. | 4211 // Check the context is a native context. |
4212 if (emit_debug_code()) { | 4212 if (emit_debug_code()) { |
4213 Cmp(FieldOperand(scratch, HeapObject::kMapOffset), | 4213 Cmp(FieldOperand(scratch, HeapObject::kMapOffset), |
4214 isolate()->factory()->native_context_map()); | 4214 isolate()->factory()->native_context_map()); |
4215 Check(equal, kJSGlobalObjectNativeContextShouldBeANativeContext); | 4215 Check(equal, kJSGlobalObjectNativeContextShouldBeANativeContext); |
4216 } | 4216 } |
4217 | 4217 |
4218 // Check if both contexts are the same. | 4218 // Check if both contexts are the same. |
4219 cmpp(scratch, FieldOperand(holder_reg, JSGlobalProxy::kNativeContextOffset)); | 4219 cmpp(scratch, FieldOperand(holder_reg, JSGlobalProxy::kNativeContextOffset)); |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4857 if (emit_debug_code()) { | 4857 if (emit_debug_code()) { |
4858 CompareRoot(FieldOperand(dst, HeapObject::kMapOffset), | 4858 CompareRoot(FieldOperand(dst, HeapObject::kMapOffset), |
4859 Heap::kWithContextMapRootIndex); | 4859 Heap::kWithContextMapRootIndex); |
4860 Check(not_equal, kVariableResolvedToWithContext); | 4860 Check(not_equal, kVariableResolvedToWithContext); |
4861 } | 4861 } |
4862 } | 4862 } |
4863 | 4863 |
4864 | 4864 |
4865 void MacroAssembler::LoadGlobalProxy(Register dst) { | 4865 void MacroAssembler::LoadGlobalProxy(Register dst) { |
4866 movp(dst, GlobalObjectOperand()); | 4866 movp(dst, GlobalObjectOperand()); |
4867 movp(dst, FieldOperand(dst, GlobalObject::kGlobalProxyOffset)); | 4867 movp(dst, FieldOperand(dst, JSGlobalObject::kGlobalProxyOffset)); |
4868 } | 4868 } |
4869 | 4869 |
4870 | 4870 |
4871 void MacroAssembler::LoadTransitionedArrayMapConditional( | 4871 void MacroAssembler::LoadTransitionedArrayMapConditional( |
4872 ElementsKind expected_kind, | 4872 ElementsKind expected_kind, |
4873 ElementsKind transitioned_kind, | 4873 ElementsKind transitioned_kind, |
4874 Register map_in_out, | 4874 Register map_in_out, |
4875 Register scratch, | 4875 Register scratch, |
4876 Label* no_map_match) { | 4876 Label* no_map_match) { |
4877 // Load the global or builtins object from the current context. | 4877 // Load the global or builtins object from the current context. |
4878 movp(scratch, | 4878 movp(scratch, |
4879 Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 4879 Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
4880 movp(scratch, FieldOperand(scratch, GlobalObject::kNativeContextOffset)); | 4880 movp(scratch, FieldOperand(scratch, JSGlobalObject::kNativeContextOffset)); |
4881 | 4881 |
4882 // Check that the function's map is the same as the expected cached map. | 4882 // Check that the function's map is the same as the expected cached map. |
4883 movp(scratch, Operand(scratch, | 4883 movp(scratch, Operand(scratch, |
4884 Context::SlotOffset(Context::JS_ARRAY_MAPS_INDEX))); | 4884 Context::SlotOffset(Context::JS_ARRAY_MAPS_INDEX))); |
4885 | 4885 |
4886 int offset = expected_kind * kPointerSize + | 4886 int offset = expected_kind * kPointerSize + |
4887 FixedArrayBase::kHeaderSize; | 4887 FixedArrayBase::kHeaderSize; |
4888 cmpp(map_in_out, FieldOperand(scratch, offset)); | 4888 cmpp(map_in_out, FieldOperand(scratch, offset)); |
4889 j(not_equal, no_map_match); | 4889 j(not_equal, no_map_match); |
4890 | 4890 |
4891 // Use the transitioned cached map. | 4891 // Use the transitioned cached map. |
4892 offset = transitioned_kind * kPointerSize + | 4892 offset = transitioned_kind * kPointerSize + |
4893 FixedArrayBase::kHeaderSize; | 4893 FixedArrayBase::kHeaderSize; |
4894 movp(map_in_out, FieldOperand(scratch, offset)); | 4894 movp(map_in_out, FieldOperand(scratch, offset)); |
4895 } | 4895 } |
4896 | 4896 |
4897 | 4897 |
4898 #ifdef _WIN64 | 4898 #ifdef _WIN64 |
4899 static const int kRegisterPassedArguments = 4; | 4899 static const int kRegisterPassedArguments = 4; |
4900 #else | 4900 #else |
4901 static const int kRegisterPassedArguments = 6; | 4901 static const int kRegisterPassedArguments = 6; |
4902 #endif | 4902 #endif |
4903 | 4903 |
4904 void MacroAssembler::LoadGlobalFunction(int index, Register function) { | 4904 void MacroAssembler::LoadGlobalFunction(int index, Register function) { |
4905 // Load the global or builtins object from the current context. | 4905 // Load the global or builtins object from the current context. |
4906 movp(function, | 4906 movp(function, |
4907 Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 4907 Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
4908 // Load the native context from the global or builtins object. | 4908 // Load the native context from the global or builtins object. |
4909 movp(function, FieldOperand(function, GlobalObject::kNativeContextOffset)); | 4909 movp(function, FieldOperand(function, JSGlobalObject::kNativeContextOffset)); |
4910 // Load the function from the native context. | 4910 // Load the function from the native context. |
4911 movp(function, Operand(function, Context::SlotOffset(index))); | 4911 movp(function, Operand(function, Context::SlotOffset(index))); |
4912 } | 4912 } |
4913 | 4913 |
4914 | 4914 |
4915 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, | 4915 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, |
4916 Register map) { | 4916 Register map) { |
4917 // Load the initial map. The global functions all have initial maps. | 4917 // Load the initial map. The global functions all have initial maps. |
4918 movp(map, FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 4918 movp(map, FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
4919 if (emit_debug_code()) { | 4919 if (emit_debug_code()) { |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5372 movl(rax, dividend); | 5372 movl(rax, dividend); |
5373 shrl(rax, Immediate(31)); | 5373 shrl(rax, Immediate(31)); |
5374 addl(rdx, rax); | 5374 addl(rdx, rax); |
5375 } | 5375 } |
5376 | 5376 |
5377 | 5377 |
5378 } // namespace internal | 5378 } // namespace internal |
5379 } // namespace v8 | 5379 } // namespace v8 |
5380 | 5380 |
5381 #endif // V8_TARGET_ARCH_X64 | 5381 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |