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

Unified Diff: runtime/vm/megamorphic_cache_table.cc

Issue 1420433004: Move selector and arguments descriptor into MegamorphicCache. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: parne Created 5 years, 2 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
« no previous file with comments | « runtime/vm/megamorphic_cache_table.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/megamorphic_cache_table.cc
diff --git a/runtime/vm/megamorphic_cache_table.cc b/runtime/vm/megamorphic_cache_table.cc
index 7f98d3b73d4af2faf95661298da99769cbc585aa..6393c3fecedbd544d06613f56cf6e31ad0be44b9 100644
--- a/runtime/vm/megamorphic_cache_table.cc
+++ b/runtime/vm/megamorphic_cache_table.cc
@@ -21,25 +21,22 @@ RawMegamorphicCache* MegamorphicCacheTable::Lookup(Isolate* isolate,
// TODO(rmacnak): Make a proper hashtable a la symbol table.
GrowableObjectArray& table = GrowableObjectArray::Handle(
isolate->object_store()->megamorphic_cache_table());
+ MegamorphicCache& cache = MegamorphicCache::Handle();
if (table.IsNull()) {
table = GrowableObjectArray::New(Heap::kOld);
- ASSERT((table.Length() % kEntrySize) == 0);
isolate->object_store()->set_megamorphic_cache_table(table);
} else {
- for (intptr_t i = 0; i < table.Length(); i += kEntrySize) {
- if ((table.At(i + kEntryNameOffset) == name.raw()) &&
- (table.At(i + kEntryDescriptorOffset) == descriptor.raw())) {
- return MegamorphicCache::RawCast(table.At(i + kEntryCacheOffset));
+ for (intptr_t i = 0; i < table.Length(); i++) {
+ cache ^= table.At(i);
+ if ((cache.target_name() == name.raw()) &&
+ (cache.arguments_descriptor() == descriptor.raw())) {
+ return cache.raw();
}
}
}
- const MegamorphicCache& cache =
- MegamorphicCache::Handle(MegamorphicCache::New());
- table.Add(name, Heap::kOld);
- table.Add(descriptor, Heap::kOld);
+ cache = MegamorphicCache::New(name, descriptor);
table.Add(cache, Heap::kOld);
- ASSERT((table.Length() % kEntrySize) == 0);
return cache.raw();
}
@@ -89,14 +86,14 @@ void MegamorphicCacheTable::PrintSizes(Isolate* isolate) {
const GrowableObjectArray& table = GrowableObjectArray::Handle(
isolate->object_store()->megamorphic_cache_table());
if (table.IsNull()) return;
- for (intptr_t i = 0; i < table.Length(); i += kEntrySize) {
- cache ^= table.At(i + kEntryCacheOffset);
+ for (intptr_t i = 0; i < table.Length(); i++) {
+ cache ^= table.At(i);
buckets = cache.buckets();
size += MegamorphicCache::InstanceSize();
size += Array::InstanceSize(buckets.Length());
}
OS::Print("%" Pd " megamorphic caches using %" Pd "KB.\n",
- table.Length() / kEntrySize, size / 1024);
+ table.Length(), size / 1024);
}
} // namespace dart
« no previous file with comments | « runtime/vm/megamorphic_cache_table.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698