Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: runtime/vm/assembler_x64.cc

Issue 1229283002: VM: Share some stub code between isolates. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/assembler_arm64.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 ASSERT(allow_constant_pool()); 86 ASSERT(allow_constant_pool());
87 intptr_t call_start = buffer_.GetPosition(); 87 intptr_t call_start = buffer_.GetPosition();
88 const int32_t offset = ObjectPool::element_offset( 88 const int32_t offset = ObjectPool::element_offset(
89 object_pool_wrapper_.FindExternalLabel(label, kPatchable)); 89 object_pool_wrapper_.FindExternalLabel(label, kPatchable));
90 call(Address::AddressBaseImm32(PP, offset - kHeapObjectTag)); 90 call(Address::AddressBaseImm32(PP, offset - kHeapObjectTag));
91 ASSERT((buffer_.GetPosition() - call_start) == kCallExternalLabelSize); 91 ASSERT((buffer_.GetPosition() - call_start) == kCallExternalLabelSize);
92 } 92 }
93 93
94 94
95 void Assembler::Call(const ExternalLabel* label, Register pp) { 95 void Assembler::Call(const ExternalLabel* label, Register pp) {
96 if (Isolate::Current() == Dart::vm_isolate()) { 96 const int32_t offset = ObjectPool::element_offset(
97 call(label); 97 object_pool_wrapper_.FindExternalLabel(label, kNotPatchable));
98 } else { 98 call(Address::AddressBaseImm32(pp, offset - kHeapObjectTag));
99 const int32_t offset = ObjectPool::element_offset(
100 object_pool_wrapper_.FindExternalLabel(label, kNotPatchable));
101 call(Address::AddressBaseImm32(pp, offset - kHeapObjectTag));
102 }
103 } 99 }
104 100
105 101
106 void Assembler::pushq(Register reg) { 102 void Assembler::pushq(Register reg) {
107 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 103 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
108 EmitRegisterREX(reg, REX_NONE); 104 EmitRegisterREX(reg, REX_NONE);
109 EmitUint8(0x50 | (reg & 7)); 105 EmitUint8(0x50 | (reg & 7));
110 } 106 }
111 107
112 108
(...skipping 2667 matching lines...) Expand 10 before | Expand all | Expand 10 after
2780 2776
2781 // TODO(zra, kmillikin): Also load other large immediates from the object 2777 // TODO(zra, kmillikin): Also load other large immediates from the object
2782 // pool 2778 // pool
2783 if (object.IsSmi()) { 2779 if (object.IsSmi()) {
2784 // If the raw smi does not fit into a 32-bit signed int, then we'll keep 2780 // If the raw smi does not fit into a 32-bit signed int, then we'll keep
2785 // the raw value in the object pool. 2781 // the raw value in the object pool.
2786 return !Utils::IsInt(32, reinterpret_cast<int64_t>(object.raw())); 2782 return !Utils::IsInt(32, reinterpret_cast<int64_t>(object.raw()));
2787 } 2783 }
2788 ASSERT(object.IsNotTemporaryScopedHandle()); 2784 ASSERT(object.IsNotTemporaryScopedHandle());
2789 ASSERT(object.IsOld()); 2785 ASSERT(object.IsOld());
2790 return (Isolate::Current() != Dart::vm_isolate()); 2786 return true;
2791 } 2787 }
2792 2788
2793 2789
2794 void Assembler::LoadWordFromPoolOffset(Register dst, Register pp, 2790 void Assembler::LoadWordFromPoolOffset(Register dst, Register pp,
2795 int32_t offset) { 2791 int32_t offset) {
2796 // This sequence must be of fixed size. AddressBaseImm32 2792 // This sequence must be of fixed size. AddressBaseImm32
2797 // forces the address operand to use a fixed-size imm32 encoding. 2793 // forces the address operand to use a fixed-size imm32 encoding.
2798 movq(dst, Address::AddressBaseImm32(pp, offset)); 2794 movq(dst, Address::AddressBaseImm32(pp, offset));
2799 } 2795 }
2800 2796
2801 2797
2802 void Assembler::LoadIsolate(Register dst) { 2798 void Assembler::LoadIsolate(Register dst) {
2803 movq(dst, Address(THR, Thread::isolate_offset())); 2799 movq(dst, Address(THR, Thread::isolate_offset()));
2804 } 2800 }
2805 2801
2806 2802
2807 void Assembler::LoadObjectHelper(Register dst, 2803 void Assembler::LoadObjectHelper(Register dst,
2808 const Object& object, 2804 const Object& object,
2809 Register pp, 2805 Register pp,
2810 bool is_unique) { 2806 bool is_unique) {
2811 if (Thread::CanLoadFromThread(object)) { 2807 if (Thread::CanLoadFromThread(object)) {
2812 movq(dst, Address(THR, Thread::OffsetFromThread(object))); 2808 movq(dst, Address(THR, Thread::OffsetFromThread(object)));
2813 } else if (CanLoadFromObjectPool(object)) { 2809 } else if (CanLoadFromObjectPool(object)) {
2814 const int32_t offset = ObjectPool::element_offset( 2810 const int32_t offset = ObjectPool::element_offset(
2815 is_unique ? object_pool_wrapper_.AddObject(object) 2811 is_unique ? object_pool_wrapper_.AddObject(object)
2816 : object_pool_wrapper_.FindObject(object)); 2812 : object_pool_wrapper_.FindObject(object));
2817 LoadWordFromPoolOffset(dst, pp, offset - kHeapObjectTag); 2813 LoadWordFromPoolOffset(dst, pp, offset - kHeapObjectTag);
2818 } else { 2814 } else {
2819 ASSERT((Isolate::Current() == Dart::vm_isolate()) || 2815 ASSERT(object.IsSmi() || object.InVMHeap());
2820 object.IsSmi() ||
2821 object.InVMHeap());
2822 LoadImmediate(dst, Immediate(reinterpret_cast<int64_t>(object.raw())), pp); 2816 LoadImmediate(dst, Immediate(reinterpret_cast<int64_t>(object.raw())), pp);
2823 } 2817 }
2824 } 2818 }
2825 2819
2826 2820
2827 void Assembler::LoadObject(Register dst, const Object& object, Register pp) { 2821 void Assembler::LoadObject(Register dst, const Object& object, Register pp) {
2828 LoadObjectHelper(dst, object, pp, false); 2822 LoadObjectHelper(dst, object, pp, false);
2829 } 2823 }
2830 2824
2831 2825
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2870 ObjectPool::element_offset(object_pool_wrapper_.FindObject(object)); 2864 ObjectPool::element_offset(object_pool_wrapper_.FindObject(object));
2871 cmpq(reg, Address(pp, offset-kHeapObjectTag)); 2865 cmpq(reg, Address(pp, offset-kHeapObjectTag));
2872 } else { 2866 } else {
2873 CompareImmediate( 2867 CompareImmediate(
2874 reg, Immediate(reinterpret_cast<int64_t>(object.raw())), pp); 2868 reg, Immediate(reinterpret_cast<int64_t>(object.raw())), pp);
2875 } 2869 }
2876 } 2870 }
2877 2871
2878 2872
2879 intptr_t Assembler::FindImmediate(int64_t imm) { 2873 intptr_t Assembler::FindImmediate(int64_t imm) {
2880 ASSERT(Isolate::Current() != Dart::vm_isolate());
2881 return object_pool_wrapper_.FindImmediate(imm); 2874 return object_pool_wrapper_.FindImmediate(imm);
2882 } 2875 }
2883 2876
2884 2877
2885 bool Assembler::CanLoadImmediateFromPool(const Immediate& imm, Register pp) { 2878 bool Assembler::CanLoadImmediateFromPool(const Immediate& imm, Register pp) {
2886 if (!allow_constant_pool()) { 2879 if (!allow_constant_pool()) {
2887 return false; 2880 return false;
2888 } 2881 }
2889 return !imm.is_int32() && 2882 return !imm.is_int32() && (pp != kNoRegister);
2890 (pp != kNoRegister) &&
2891 (Isolate::Current() != Dart::vm_isolate());
2892 } 2883 }
2893 2884
2894 2885
2895 void Assembler::LoadImmediate(Register reg, const Immediate& imm, Register pp) { 2886 void Assembler::LoadImmediate(Register reg, const Immediate& imm, Register pp) {
2896 if (CanLoadImmediateFromPool(imm, pp)) { 2887 if (CanLoadImmediateFromPool(imm, pp)) {
2897 // It's a 64-bit constant and we're not in the VM isolate, so load from 2888 // It's a 64-bit constant and we're not in the VM isolate, so load from
2898 // object pool. 2889 // object pool.
2899 int32_t offset = ObjectPool::element_offset(FindImmediate(imm.value())); 2890 int32_t offset = ObjectPool::element_offset(FindImmediate(imm.value()));
2900 LoadWordFromPoolOffset(reg, pp, offset - kHeapObjectTag); 2891 LoadWordFromPoolOffset(reg, pp, offset - kHeapObjectTag);
2901 } else { 2892 } else {
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
3919 3910
3920 3911
3921 const char* Assembler::FpuRegisterName(FpuRegister reg) { 3912 const char* Assembler::FpuRegisterName(FpuRegister reg) {
3922 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); 3913 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters));
3923 return xmm_reg_names[reg]; 3914 return xmm_reg_names[reg];
3924 } 3915 }
3925 3916
3926 } // namespace dart 3917 } // namespace dart
3927 3918
3928 #endif // defined TARGET_ARCH_X64 3919 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_arm64.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698