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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/assembler_x64.cc
===================================================================
--- runtime/vm/assembler_x64.cc (revision 27479)
+++ runtime/vm/assembler_x64.cc (working copy)
@@ -83,13 +83,14 @@
object_pool_.Add(Bool::True(), Heap::kOld);
patchable_pool_entries_.Add(kNotPatchable);
+ object_pool_index_table_.Insert(ObjIndexPair(Bool::True().raw(), 1));
object_pool_.Add(Bool::False(), Heap::kOld);
patchable_pool_entries_.Add(kNotPatchable);
+ object_pool_index_table_.Insert(ObjIndexPair(Bool::False().raw(), 2));
if (StubCode::UpdateStoreBuffer_entry() != NULL) {
FindExternalLabel(&StubCode::UpdateStoreBufferLabel(), kNotPatchable);
- patchable_pool_entries_.Add(kNotPatchable);
} else {
object_pool_.Add(Object::Handle(), Heap::kOld);
patchable_pool_entries_.Add(kNotPatchable);
@@ -97,7 +98,6 @@
if (StubCode::CallToRuntime_entry() != NULL) {
FindExternalLabel(&StubCode::CallToRuntimeLabel(), kNotPatchable);
- patchable_pool_entries_.Add(kNotPatchable);
} else {
object_pool_.Add(Object::Handle(), Heap::kOld);
patchable_pool_entries_.Add(kNotPatchable);
@@ -2172,16 +2172,30 @@
ASSERT(Isolate::Current() != Dart::vm_isolate());
ASSERT(!object_pool_.IsNull());
- // TODO(zra): This can be slow. Add a hash map from obj.raw() to
- // object pool indexes to speed lookup.
- for (int i = 0; i < object_pool_.Length(); i++) {
- if ((object_pool_.At(i) == obj.raw()) &&
- (patchable_pool_entries_[i] != kPatchable)) {
- return i;
+ // Special case for Object::null(), which is always at object_pool_ index 0
+ // because Lookup() below returns 0 when the object is not mapped in the
+ // table.
+ if (obj.raw() == Object::null()) {
+ return 0;
+ }
+
+ // If the object is not patchable, check if we've already got it in the
+ // object pool.
+ if (patchable == kNotPatchable) {
+ intptr_t idx = object_pool_index_table_.Lookup(obj.raw());
+ if (idx != 0) {
+ ASSERT(patchable_pool_entries_[idx] == kNotPatchable);
+ return idx;
}
}
+
object_pool_.Add(obj, Heap::kOld);
patchable_pool_entries_.Add(patchable);
+ if (patchable == kNotPatchable) {
+ // The object isn't patchable. Record the index for fast lookup.
+ object_pool_index_table_.Insert(
+ ObjIndexPair(obj.raw(), object_pool_.Length() - 1));
+ }
return object_pool_.Length() - 1;
}
@@ -2196,6 +2210,8 @@
// The address is stored in the object array as a RawSmi.
const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(address));
if (patchable == kNotPatchable) {
+ // If the call site is not patchable, we can try to re-use an existing
+ // entry.
return FindObject(smi, kNotPatchable);
}
// If the call is patchable, do not reuse an existing entry since each
« 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