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

Unified Diff: runtime/lib/object_patch.dart

Issue 2137673002: Sped up hashCode by removing megamorphic call to _identityHashCode. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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
« runtime/lib/object.cc ('K') | « runtime/lib/object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/object_patch.dart
diff --git a/runtime/lib/object_patch.dart b/runtime/lib/object_patch.dart
index 7c4f5f54f629029e3f120ac9cbc7f0eb33071990..69723b38039f46b3eec4b1f5770768a6eea5b6eb 100644
--- a/runtime/lib/object_patch.dart
+++ b/runtime/lib/object_patch.dart
@@ -15,21 +15,23 @@ patch class Object {
static _getHash(obj) native "Object_getHash";
static _setHash(obj, hash) native "Object_setHash";
- /* patch */ int get hashCode => _identityHashCode;
-
- int get _identityHashCode {
- var result = _getHash(this);
+ // Shared static implentation for hashCode and _identityHashCode.
+ static int _objectHashCode(obj) {
+ var result = _getHash(obj);
if (result == 0) {
// We want the hash to be a Smi value greater than 0.
result = _hashCodeRnd.nextInt(0x40000000);
while (result == 0) {
result = _hashCodeRnd.nextInt(0x40000000);
}
- _setHash(this, result);
+ _setHash(obj, result);
}
return result;
}
+ /* patch */ int get hashCode => _objectHashCode(this);
+ int get _identityHashCode => _objectHashCode(this);
+
/* patch */ String toString() native "Object_toString";
// A statically dispatched version of Object.toString.
static String _toString(obj) native "Object_toString";
« runtime/lib/object.cc ('K') | « runtime/lib/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698