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

Unified Diff: runtime/lib/object.cc

Issue 2965723002: VM: Reland Inline instance object hash code into object header on 64bit. (Closed)
Patch Set: Fix snapshot incompatibility that sank Flutter Gallery Created 3 years, 6 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/lib/object.cc
diff --git a/runtime/lib/object.cc b/runtime/lib/object.cc
index b7dcea3a2088351939f96dbb7ef5d1c8b07932bf..f0739adc3acdfdebdf0a6430ee4fdc9d0bbde187 100644
--- a/runtime/lib/object.cc
+++ b/runtime/lib/object.cc
@@ -42,17 +42,25 @@ DEFINE_NATIVE_ENTRY(Object_getHash, 1) {
// Please note that no handle is created for the argument.
// This is safe since the argument is only used in a tail call.
// The performance benefit is more than 5% when using hashCode.
+#if defined(HASH_IN_OBJECT_HEADER)
+ return Smi::New(Object::GetCachedHash(arguments->NativeArgAt(0)));
+#else
Heap* heap = isolate->heap();
ASSERT(arguments->NativeArgAt(0)->IsDartInstance());
return Smi::New(heap->GetHash(arguments->NativeArgAt(0)));
+#endif
}
DEFINE_NATIVE_ENTRY(Object_setHash, 2) {
- const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Smi, hash, arguments->NativeArgAt(1));
+#if defined(HASH_IN_OBJECT_HEADER)
+ Object::SetCachedHash(arguments->NativeArgAt(0), hash.Value());
+#else
+ const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
Heap* heap = isolate->heap();
heap->SetHash(instance.raw(), hash.Value());
+#endif
return Object::null();
}

Powered by Google App Engine
This is Rietveld 408576698