OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // NOLINT | 5 #include "vm/globals.h" // NOLINT |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
(...skipping 2731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2742 popq(tmp); | 2742 popq(tmp); |
2743 } | 2743 } |
2744 return; | 2744 return; |
2745 } | 2745 } |
2746 addq(RSP, Immediate(stack_elements * kWordSize)); | 2746 addq(RSP, Immediate(stack_elements * kWordSize)); |
2747 } | 2747 } |
2748 | 2748 |
2749 | 2749 |
2750 bool Assembler::CanLoadFromObjectPool(const Object& object) const { | 2750 bool Assembler::CanLoadFromObjectPool(const Object& object) const { |
2751 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); | 2751 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); |
| 2752 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal()); |
2752 ASSERT(!Thread::CanLoadFromThread(object)); | 2753 ASSERT(!Thread::CanLoadFromThread(object)); |
2753 if (!constant_pool_allowed()) { | 2754 if (!constant_pool_allowed()) { |
2754 return false; | 2755 return false; |
2755 } | 2756 } |
2756 | 2757 |
2757 // TODO(zra, kmillikin): Also load other large immediates from the object | 2758 // TODO(zra, kmillikin): Also load other large immediates from the object |
2758 // pool | 2759 // pool |
2759 if (object.IsSmi()) { | 2760 if (object.IsSmi()) { |
2760 // If the raw smi does not fit into a 32-bit signed int, then we'll keep | 2761 // If the raw smi does not fit into a 32-bit signed int, then we'll keep |
2761 // the raw value in the object pool. | 2762 // the raw value in the object pool. |
(...skipping 16 matching lines...) Expand all Loading... |
2778 | 2779 |
2779 void Assembler::LoadIsolate(Register dst) { | 2780 void Assembler::LoadIsolate(Register dst) { |
2780 movq(dst, Address(THR, Thread::isolate_offset())); | 2781 movq(dst, Address(THR, Thread::isolate_offset())); |
2781 } | 2782 } |
2782 | 2783 |
2783 | 2784 |
2784 void Assembler::LoadObjectHelper(Register dst, | 2785 void Assembler::LoadObjectHelper(Register dst, |
2785 const Object& object, | 2786 const Object& object, |
2786 bool is_unique) { | 2787 bool is_unique) { |
2787 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); | 2788 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); |
| 2789 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal()); |
2788 if (Thread::CanLoadFromThread(object)) { | 2790 if (Thread::CanLoadFromThread(object)) { |
2789 movq(dst, Address(THR, Thread::OffsetFromThread(object))); | 2791 movq(dst, Address(THR, Thread::OffsetFromThread(object))); |
2790 } else if (CanLoadFromObjectPool(object)) { | 2792 } else if (CanLoadFromObjectPool(object)) { |
2791 const int32_t offset = ObjectPool::element_offset( | 2793 const int32_t offset = ObjectPool::element_offset( |
2792 is_unique ? object_pool_wrapper_.AddObject(object) | 2794 is_unique ? object_pool_wrapper_.AddObject(object) |
2793 : object_pool_wrapper_.FindObject(object)); | 2795 : object_pool_wrapper_.FindObject(object)); |
2794 LoadWordFromPoolOffset(dst, offset - kHeapObjectTag); | 2796 LoadWordFromPoolOffset(dst, offset - kHeapObjectTag); |
2795 } else { | 2797 } else { |
2796 ASSERT(object.IsSmi() || object.InVMHeap()); | 2798 ASSERT(object.IsSmi() || object.InVMHeap()); |
2797 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); | 2799 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); |
(...skipping 18 matching lines...) Expand all Loading... |
2816 } | 2818 } |
2817 | 2819 |
2818 | 2820 |
2819 void Assembler::LoadUniqueObject(Register dst, const Object& object) { | 2821 void Assembler::LoadUniqueObject(Register dst, const Object& object) { |
2820 LoadObjectHelper(dst, object, true); | 2822 LoadObjectHelper(dst, object, true); |
2821 } | 2823 } |
2822 | 2824 |
2823 | 2825 |
2824 void Assembler::StoreObject(const Address& dst, const Object& object) { | 2826 void Assembler::StoreObject(const Address& dst, const Object& object) { |
2825 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); | 2827 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); |
| 2828 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal()); |
2826 if (Thread::CanLoadFromThread(object)) { | 2829 if (Thread::CanLoadFromThread(object)) { |
2827 movq(TMP, Address(THR, Thread::OffsetFromThread(object))); | 2830 movq(TMP, Address(THR, Thread::OffsetFromThread(object))); |
2828 movq(dst, TMP); | 2831 movq(dst, TMP); |
2829 } else if (CanLoadFromObjectPool(object)) { | 2832 } else if (CanLoadFromObjectPool(object)) { |
2830 LoadObject(TMP, object); | 2833 LoadObject(TMP, object); |
2831 movq(dst, TMP); | 2834 movq(dst, TMP); |
2832 } else { | 2835 } else { |
2833 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); | 2836 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); |
2834 MoveImmediate(dst, Immediate(reinterpret_cast<int64_t>(object.raw()))); | 2837 MoveImmediate(dst, Immediate(reinterpret_cast<int64_t>(object.raw()))); |
2835 } | 2838 } |
2836 } | 2839 } |
2837 | 2840 |
2838 | 2841 |
2839 void Assembler::PushObject(const Object& object) { | 2842 void Assembler::PushObject(const Object& object) { |
2840 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); | 2843 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); |
| 2844 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal()); |
2841 if (Thread::CanLoadFromThread(object)) { | 2845 if (Thread::CanLoadFromThread(object)) { |
2842 pushq(Address(THR, Thread::OffsetFromThread(object))); | 2846 pushq(Address(THR, Thread::OffsetFromThread(object))); |
2843 } else if (CanLoadFromObjectPool(object)) { | 2847 } else if (CanLoadFromObjectPool(object)) { |
2844 LoadObject(TMP, object); | 2848 LoadObject(TMP, object); |
2845 pushq(TMP); | 2849 pushq(TMP); |
2846 } else { | 2850 } else { |
2847 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); | 2851 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); |
2848 PushImmediate(Immediate(reinterpret_cast<int64_t>(object.raw()))); | 2852 PushImmediate(Immediate(reinterpret_cast<int64_t>(object.raw()))); |
2849 } | 2853 } |
2850 } | 2854 } |
2851 | 2855 |
2852 | 2856 |
2853 void Assembler::CompareObject(Register reg, const Object& object) { | 2857 void Assembler::CompareObject(Register reg, const Object& object) { |
2854 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); | 2858 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); |
| 2859 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal()); |
2855 if (Thread::CanLoadFromThread(object)) { | 2860 if (Thread::CanLoadFromThread(object)) { |
2856 cmpq(reg, Address(THR, Thread::OffsetFromThread(object))); | 2861 cmpq(reg, Address(THR, Thread::OffsetFromThread(object))); |
2857 } else if (CanLoadFromObjectPool(object)) { | 2862 } else if (CanLoadFromObjectPool(object)) { |
2858 const int32_t offset = | 2863 const int32_t offset = |
2859 ObjectPool::element_offset(object_pool_wrapper_.FindObject(object)); | 2864 ObjectPool::element_offset(object_pool_wrapper_.FindObject(object)); |
2860 cmpq(reg, Address(PP, offset-kHeapObjectTag)); | 2865 cmpq(reg, Address(PP, offset-kHeapObjectTag)); |
2861 } else { | 2866 } else { |
2862 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); | 2867 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); |
2863 CompareImmediate( | 2868 CompareImmediate( |
2864 reg, Immediate(reinterpret_cast<int64_t>(object.raw()))); | 2869 reg, Immediate(reinterpret_cast<int64_t>(object.raw()))); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3072 #endif // defined(DEBUG) | 3077 #endif // defined(DEBUG) |
3073 // No store buffer update. | 3078 // No store buffer update. |
3074 } | 3079 } |
3075 | 3080 |
3076 | 3081 |
3077 void Assembler::StoreIntoObjectNoBarrier(Register object, | 3082 void Assembler::StoreIntoObjectNoBarrier(Register object, |
3078 const Address& dest, | 3083 const Address& dest, |
3079 const Object& value, | 3084 const Object& value, |
3080 FieldContent old_content) { | 3085 FieldContent old_content) { |
3081 ASSERT(!value.IsICData() || ICData::Cast(value).IsOriginal()); | 3086 ASSERT(!value.IsICData() || ICData::Cast(value).IsOriginal()); |
| 3087 ASSERT(!value.IsField() || Field::Cast(value).IsOriginal()); |
3082 VerifyHeapWord(dest, old_content); | 3088 VerifyHeapWord(dest, old_content); |
3083 if (VerifiedMemory::enabled()) { | 3089 if (VerifiedMemory::enabled()) { |
3084 const Register temp = RCX; | 3090 const Register temp = RCX; |
3085 pushq(temp); | 3091 pushq(temp); |
3086 leaq(temp, dest); | 3092 leaq(temp, dest); |
3087 StoreObject(Address(temp, 0), value); | 3093 StoreObject(Address(temp, 0), value); |
3088 StoreObject(Address(temp, VerifiedMemory::offset()), value); | 3094 StoreObject(Address(temp, VerifiedMemory::offset()), value); |
3089 popq(temp); | 3095 popq(temp); |
3090 } else { | 3096 } else { |
3091 StoreObject(dest, value); | 3097 StoreObject(dest, value); |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3935 | 3941 |
3936 | 3942 |
3937 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3943 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3938 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3944 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3939 return xmm_reg_names[reg]; | 3945 return xmm_reg_names[reg]; |
3940 } | 3946 } |
3941 | 3947 |
3942 } // namespace dart | 3948 } // namespace dart |
3943 | 3949 |
3944 #endif // defined TARGET_ARCH_X64 | 3950 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |