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

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

Issue 23723008: Fixes slow object pool search on x64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
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" 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 83
84 object_pool_.Add(Bool::True(), Heap::kOld); 84 object_pool_.Add(Bool::True(), Heap::kOld);
85 patchable_pool_entries_.Add(kNotPatchable); 85 patchable_pool_entries_.Add(kNotPatchable);
86 object_pool_index_table_.Insert(ObjIndexPair(Bool::True().raw(), 1));
86 87
87 object_pool_.Add(Bool::False(), Heap::kOld); 88 object_pool_.Add(Bool::False(), Heap::kOld);
88 patchable_pool_entries_.Add(kNotPatchable); 89 patchable_pool_entries_.Add(kNotPatchable);
90 object_pool_index_table_.Insert(ObjIndexPair(Bool::False().raw(), 2));
89 91
90 if (StubCode::UpdateStoreBuffer_entry() != NULL) { 92 if (StubCode::UpdateStoreBuffer_entry() != NULL) {
91 FindExternalLabel(&StubCode::UpdateStoreBufferLabel(), kNotPatchable); 93 FindExternalLabel(&StubCode::UpdateStoreBufferLabel(), kNotPatchable);
92 patchable_pool_entries_.Add(kNotPatchable);
93 } else { 94 } else {
94 object_pool_.Add(Object::Handle(), Heap::kOld); 95 object_pool_.Add(Object::Handle(), Heap::kOld);
95 patchable_pool_entries_.Add(kNotPatchable); 96 patchable_pool_entries_.Add(kNotPatchable);
96 } 97 }
97 98
98 if (StubCode::CallToRuntime_entry() != NULL) { 99 if (StubCode::CallToRuntime_entry() != NULL) {
99 FindExternalLabel(&StubCode::CallToRuntimeLabel(), kNotPatchable); 100 FindExternalLabel(&StubCode::CallToRuntimeLabel(), kNotPatchable);
100 patchable_pool_entries_.Add(kNotPatchable);
101 } else { 101 } else {
102 object_pool_.Add(Object::Handle(), Heap::kOld); 102 object_pool_.Add(Object::Handle(), Heap::kOld);
103 patchable_pool_entries_.Add(kNotPatchable); 103 patchable_pool_entries_.Add(kNotPatchable);
104 } 104 }
105 } 105 }
106 } 106 }
107 107
108 108
109 void Assembler::InitializeMemoryWithBreakpoints(uword data, int length) { 109 void Assembler::InitializeMemoryWithBreakpoints(uword data, int length) {
110 memset(reinterpret_cast<void*>(data), Instr::kBreakPointInstruction, length); 110 memset(reinterpret_cast<void*>(data), Instr::kBreakPointInstruction, length);
(...skipping 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 } 2165 }
2166 addq(RSP, Immediate(stack_elements * kWordSize)); 2166 addq(RSP, Immediate(stack_elements * kWordSize));
2167 } 2167 }
2168 2168
2169 2169
2170 intptr_t Assembler::FindObject(const Object& obj, Patchability patchable) { 2170 intptr_t Assembler::FindObject(const Object& obj, Patchability patchable) {
2171 // The object pool cannot be used in the vm isolate. 2171 // The object pool cannot be used in the vm isolate.
2172 ASSERT(Isolate::Current() != Dart::vm_isolate()); 2172 ASSERT(Isolate::Current() != Dart::vm_isolate());
2173 ASSERT(!object_pool_.IsNull()); 2173 ASSERT(!object_pool_.IsNull());
2174 2174
2175 // TODO(zra): This can be slow. Add a hash map from obj.raw() to 2175 // Special case for Object::null(), which is always at object_pool_ index 0
2176 // object pool indexes to speed lookup. 2176 // because Lookup() below returns 0 when the object is not mapped in the
2177 for (int i = 0; i < object_pool_.Length(); i++) { 2177 // table.
2178 if ((object_pool_.At(i) == obj.raw()) && 2178 if (obj.raw() == Object::null()) {
2179 (patchable_pool_entries_[i] != kPatchable)) { 2179 return 0;
2180 return i; 2180 }
2181
2182 // If the object is not patchable, check if we've already got it in the
2183 // object pool.
2184 if (patchable == kNotPatchable) {
2185 intptr_t idx = object_pool_index_table_.Lookup(obj.raw());
2186 if (idx != 0) {
2187 ASSERT(patchable_pool_entries_[idx] == kNotPatchable);
2188 return idx;
2181 } 2189 }
2182 } 2190 }
2191
2183 object_pool_.Add(obj, Heap::kOld); 2192 object_pool_.Add(obj, Heap::kOld);
2184 patchable_pool_entries_.Add(patchable); 2193 patchable_pool_entries_.Add(patchable);
2194 if (patchable == kNotPatchable) {
2195 // The object isn't patchable. Record the index for fast lookup.
2196 object_pool_index_table_.Insert(
2197 ObjIndexPair(obj.raw(), object_pool_.Length() - 1));
2198 }
2185 return object_pool_.Length() - 1; 2199 return object_pool_.Length() - 1;
2186 } 2200 }
2187 2201
2188 2202
2189 intptr_t Assembler::FindExternalLabel(const ExternalLabel* label, 2203 intptr_t Assembler::FindExternalLabel(const ExternalLabel* label,
2190 Patchability patchable) { 2204 Patchability patchable) {
2191 // The object pool cannot be used in the vm isolate. 2205 // The object pool cannot be used in the vm isolate.
2192 ASSERT(Isolate::Current() != Dart::vm_isolate()); 2206 ASSERT(Isolate::Current() != Dart::vm_isolate());
2193 ASSERT(!object_pool_.IsNull()); 2207 ASSERT(!object_pool_.IsNull());
2194 const uword address = label->address(); 2208 const uword address = label->address();
2195 ASSERT(Utils::IsAligned(address, 4)); 2209 ASSERT(Utils::IsAligned(address, 4));
2196 // The address is stored in the object array as a RawSmi. 2210 // The address is stored in the object array as a RawSmi.
2197 const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(address)); 2211 const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(address));
2198 if (patchable == kNotPatchable) { 2212 if (patchable == kNotPatchable) {
2213 // If the call site is not patchable, we can try to re-use an existing
2214 // entry.
2199 return FindObject(smi, kNotPatchable); 2215 return FindObject(smi, kNotPatchable);
2200 } 2216 }
2201 // If the call is patchable, do not reuse an existing entry since each 2217 // If the call is patchable, do not reuse an existing entry since each
2202 // reference may be patched independently. 2218 // reference may be patched independently.
2203 object_pool_.Add(smi, Heap::kOld); 2219 object_pool_.Add(smi, Heap::kOld);
2204 patchable_pool_entries_.Add(patchable); 2220 patchable_pool_entries_.Add(patchable);
2205 return object_pool_.Length() - 1; 2221 return object_pool_.Length() - 1;
2206 } 2222 }
2207 2223
2208 2224
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2861 2877
2862 2878
2863 const char* Assembler::FpuRegisterName(FpuRegister reg) { 2879 const char* Assembler::FpuRegisterName(FpuRegister reg) {
2864 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); 2880 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters));
2865 return xmm_reg_names[reg]; 2881 return xmm_reg_names[reg];
2866 } 2882 }
2867 2883
2868 } // namespace dart 2884 } // namespace dart
2869 2885
2870 #endif // defined TARGET_ARCH_X64 2886 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_x64.h ('k') | runtime/vm/object.h » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698