| 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" | 5 #include "vm/globals.h" |
| 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/heap.h" | 9 #include "vm/heap.h" |
| 10 #include "vm/memory_region.h" | 10 #include "vm/memory_region.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 comments_() { | 73 comments_() { |
| 74 // Far branching mode is only needed and implemented for MIPS and ARM. | 74 // Far branching mode is only needed and implemented for MIPS and ARM. |
| 75 ASSERT(!use_far_branches); | 75 ASSERT(!use_far_branches); |
| 76 if (Isolate::Current() != Dart::vm_isolate()) { | 76 if (Isolate::Current() != Dart::vm_isolate()) { |
| 77 object_pool_ = GrowableObjectArray::New(Heap::kOld); | 77 object_pool_ = GrowableObjectArray::New(Heap::kOld); |
| 78 | 78 |
| 79 // These objects and labels need to be accessible through every pool-pointer | 79 // These objects and labels need to be accessible through every pool-pointer |
| 80 // at the same index. | 80 // at the same index. |
| 81 object_pool_.Add(Object::Handle(), Heap::kOld); | 81 object_pool_.Add(Object::Handle(), Heap::kOld); |
| 82 patchable_pool_entries_.Add(kNotPatchable); | 82 patchable_pool_entries_.Add(kNotPatchable); |
| 83 // Not adding Object::null() to the index table. It is at index 0 in the |
| 84 // object pool, but the HashMap uses 0 to indicate not found. |
| 83 | 85 |
| 84 object_pool_.Add(Bool::True(), Heap::kOld); | 86 object_pool_.Add(Bool::True(), Heap::kOld); |
| 85 patchable_pool_entries_.Add(kNotPatchable); | 87 patchable_pool_entries_.Add(kNotPatchable); |
| 88 object_pool_index_table_.Insert(ObjIndexPair(Bool::True().raw(), 1)); |
| 86 | 89 |
| 87 object_pool_.Add(Bool::False(), Heap::kOld); | 90 object_pool_.Add(Bool::False(), Heap::kOld); |
| 88 patchable_pool_entries_.Add(kNotPatchable); | 91 patchable_pool_entries_.Add(kNotPatchable); |
| 92 object_pool_index_table_.Insert(ObjIndexPair(Bool::False().raw(), 2)); |
| 89 | 93 |
| 90 if (StubCode::UpdateStoreBuffer_entry() != NULL) { | 94 if (StubCode::UpdateStoreBuffer_entry() != NULL) { |
| 91 FindExternalLabel(&StubCode::UpdateStoreBufferLabel(), kNotPatchable); | 95 FindExternalLabel(&StubCode::UpdateStoreBufferLabel(), kNotPatchable); |
| 92 patchable_pool_entries_.Add(kNotPatchable); | |
| 93 } else { | 96 } else { |
| 94 object_pool_.Add(Object::Handle(), Heap::kOld); | 97 object_pool_.Add(Object::Handle(), Heap::kOld); |
| 95 patchable_pool_entries_.Add(kNotPatchable); | 98 patchable_pool_entries_.Add(kNotPatchable); |
| 96 } | 99 } |
| 97 | 100 |
| 98 if (StubCode::CallToRuntime_entry() != NULL) { | 101 if (StubCode::CallToRuntime_entry() != NULL) { |
| 99 FindExternalLabel(&StubCode::CallToRuntimeLabel(), kNotPatchable); | 102 FindExternalLabel(&StubCode::CallToRuntimeLabel(), kNotPatchable); |
| 100 patchable_pool_entries_.Add(kNotPatchable); | |
| 101 } else { | 103 } else { |
| 102 object_pool_.Add(Object::Handle(), Heap::kOld); | 104 object_pool_.Add(Object::Handle(), Heap::kOld); |
| 103 patchable_pool_entries_.Add(kNotPatchable); | 105 patchable_pool_entries_.Add(kNotPatchable); |
| 104 } | 106 } |
| 105 } | 107 } |
| 106 } | 108 } |
| 107 | 109 |
| 108 | 110 |
| 109 void Assembler::InitializeMemoryWithBreakpoints(uword data, int length) { | 111 void Assembler::InitializeMemoryWithBreakpoints(uword data, int length) { |
| 110 memset(reinterpret_cast<void*>(data), Instr::kBreakPointInstruction, length); | 112 memset(reinterpret_cast<void*>(data), Instr::kBreakPointInstruction, length); |
| (...skipping 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2165 } | 2167 } |
| 2166 addq(RSP, Immediate(stack_elements * kWordSize)); | 2168 addq(RSP, Immediate(stack_elements * kWordSize)); |
| 2167 } | 2169 } |
| 2168 | 2170 |
| 2169 | 2171 |
| 2170 intptr_t Assembler::FindObject(const Object& obj, Patchability patchable) { | 2172 intptr_t Assembler::FindObject(const Object& obj, Patchability patchable) { |
| 2171 // The object pool cannot be used in the vm isolate. | 2173 // The object pool cannot be used in the vm isolate. |
| 2172 ASSERT(Isolate::Current() != Dart::vm_isolate()); | 2174 ASSERT(Isolate::Current() != Dart::vm_isolate()); |
| 2173 ASSERT(!object_pool_.IsNull()); | 2175 ASSERT(!object_pool_.IsNull()); |
| 2174 | 2176 |
| 2175 // TODO(zra): This can be slow. Add a hash map from obj.raw() to | 2177 // If the object is not patchable, check if we've already got it in the |
| 2176 // object pool indexes to speed lookup. | 2178 // object pool. |
| 2177 for (int i = 0; i < object_pool_.Length(); i++) { | 2179 if (patchable == kNotPatchable) { |
| 2178 if ((object_pool_.At(i) == obj.raw()) && | 2180 // Special case for Object::null(), which is always at object_pool_ index 0 |
| 2179 (patchable_pool_entries_[i] != kPatchable)) { | 2181 // because Lookup() below returns 0 when the object is not mapped in the |
| 2180 return i; | 2182 // table. |
| 2183 if (obj.raw() == Object::null()) { |
| 2184 return 0; |
| 2185 } |
| 2186 |
| 2187 intptr_t idx = object_pool_index_table_.Lookup(obj.raw()); |
| 2188 if (idx != 0) { |
| 2189 ASSERT(patchable_pool_entries_[idx] == kNotPatchable); |
| 2190 return idx; |
| 2181 } | 2191 } |
| 2182 } | 2192 } |
| 2193 |
| 2183 object_pool_.Add(obj, Heap::kOld); | 2194 object_pool_.Add(obj, Heap::kOld); |
| 2184 patchable_pool_entries_.Add(patchable); | 2195 patchable_pool_entries_.Add(patchable); |
| 2196 if (patchable == kNotPatchable) { |
| 2197 // The object isn't patchable. Record the index for fast lookup. |
| 2198 object_pool_index_table_.Insert( |
| 2199 ObjIndexPair(obj.raw(), object_pool_.Length() - 1)); |
| 2200 } |
| 2185 return object_pool_.Length() - 1; | 2201 return object_pool_.Length() - 1; |
| 2186 } | 2202 } |
| 2187 | 2203 |
| 2188 | 2204 |
| 2189 intptr_t Assembler::FindExternalLabel(const ExternalLabel* label, | 2205 intptr_t Assembler::FindExternalLabel(const ExternalLabel* label, |
| 2190 Patchability patchable) { | 2206 Patchability patchable) { |
| 2191 // The object pool cannot be used in the vm isolate. | 2207 // The object pool cannot be used in the vm isolate. |
| 2192 ASSERT(Isolate::Current() != Dart::vm_isolate()); | 2208 ASSERT(Isolate::Current() != Dart::vm_isolate()); |
| 2193 ASSERT(!object_pool_.IsNull()); | 2209 ASSERT(!object_pool_.IsNull()); |
| 2194 const uword address = label->address(); | 2210 const uword address = label->address(); |
| 2195 ASSERT(Utils::IsAligned(address, 4)); | 2211 ASSERT(Utils::IsAligned(address, 4)); |
| 2196 // The address is stored in the object array as a RawSmi. | 2212 // The address is stored in the object array as a RawSmi. |
| 2197 const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(address)); | 2213 const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(address)); |
| 2198 if (patchable == kNotPatchable) { | 2214 if (patchable == kNotPatchable) { |
| 2215 // If the call site is not patchable, we can try to re-use an existing |
| 2216 // entry. |
| 2199 return FindObject(smi, kNotPatchable); | 2217 return FindObject(smi, kNotPatchable); |
| 2200 } | 2218 } |
| 2201 // If the call is patchable, do not reuse an existing entry since each | 2219 // If the call is patchable, do not reuse an existing entry since each |
| 2202 // reference may be patched independently. | 2220 // reference may be patched independently. |
| 2203 object_pool_.Add(smi, Heap::kOld); | 2221 object_pool_.Add(smi, Heap::kOld); |
| 2204 patchable_pool_entries_.Add(patchable); | 2222 patchable_pool_entries_.Add(patchable); |
| 2205 return object_pool_.Length() - 1; | 2223 return object_pool_.Length() - 1; |
| 2206 } | 2224 } |
| 2207 | 2225 |
| 2208 | 2226 |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2861 | 2879 |
| 2862 | 2880 |
| 2863 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 2881 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
| 2864 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 2882 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
| 2865 return xmm_reg_names[reg]; | 2883 return xmm_reg_names[reg]; |
| 2866 } | 2884 } |
| 2867 | 2885 |
| 2868 } // namespace dart | 2886 } // namespace dart |
| 2869 | 2887 |
| 2870 #endif // defined TARGET_ARCH_X64 | 2888 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |