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

Side by Side Diff: runtime/lib/object_patch.dart

Issue 2962543002: Revert "VM: Reland Inline instance object hash code into object header on 64bit." (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « runtime/lib/object.cc ('k') | runtime/vm/assembler_arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 int _getHash(obj) native "Object_getHash";
6 int _setHash(obj, hash) native "Object_setHash";
7
8 @patch 5 @patch
9 class Object { 6 class Object {
10 // The VM has its own implementation of equals. 7 // The VM has its own implementation of equals.
11 @patch 8 @patch
12 bool operator ==(other) native "Object_equals"; 9 bool operator ==(other) native "Object_equals";
13 10
14 // Helpers used to implement hashCode. If a hashCode is used, we remember it 11 // Helpers used to implement hashCode. If a hashCode is used, we remember it
15 // in a weak table in the VM (32 bit) or in the header of the object (64 12 // in a weak table in the VM. A new hashCode value is calculated using a
16 // bit). A new hashCode value is calculated using a random number generator. 13 // number generator.
17 static final _hashCodeRnd = new Random(); 14 static final _hashCodeRnd = new Random();
18 15
19 // Shared static implementation for hashCode and _identityHashCode. 16 // Shared static implementation for hashCode and _identityHashCode.
17 static _getHash(obj) native "Object_getHash";
18 static _setHash(obj, hash) native "Object_setHash";
19
20 static int _objectHashCode(obj) { 20 static int _objectHashCode(obj) {
21 var result = _getHash(obj); 21 var result = _getHash(obj);
22 if (result == 0) { 22 if (result == 0) {
23 // We want the hash to be a Smi value greater than 0. 23 // We want the hash to be a Smi value greater than 0.
24 do { 24 result = _hashCodeRnd.nextInt(0x40000000);
25 while (result == 0) {
25 result = _hashCodeRnd.nextInt(0x40000000); 26 result = _hashCodeRnd.nextInt(0x40000000);
26 } while (result == 0); 27 }
27 _setHash(obj, result); 28 _setHash(obj, result);
28 } 29 }
29 return result; 30 return result;
30 } 31 }
31 32
32 @patch 33 @patch
33 int get hashCode => _objectHashCode(this); 34 int get hashCode => _objectHashCode(this);
34 int get _identityHashCode => _objectHashCode(this); 35 int get _identityHashCode => _objectHashCode(this);
35 36
36 @patch 37 @patch
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 native "Object_as"; 73 native "Object_as";
73 74
74 static _symbolMapToStringMap(Map<Symbol, dynamic> map) { 75 static _symbolMapToStringMap(Map<Symbol, dynamic> map) {
75 var result = new Map<String, dynamic>(); 76 var result = new Map<String, dynamic>();
76 map.forEach((Symbol key, value) { 77 map.forEach((Symbol key, value) {
77 result[internal.Symbol.getName(key)] = value; 78 result[internal.Symbol.getName(key)] = value;
78 }); 79 });
79 return result; 80 return result;
80 } 81 }
81 } 82 }
OLDNEW
« no previous file with comments | « runtime/lib/object.cc ('k') | runtime/vm/assembler_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698