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

Side by Side Diff: src/collection.js

Issue 1142493002: Use a private own symbol instead of a hidden property for hash codes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | src/factory.h » ('j') | src/isolate.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, shared, exports) { 5 (function(global, shared, exports) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; 63 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1;
64 hash = hash ^ (hash >>> 12); 64 hash = hash ^ (hash >>> 12);
65 hash = hash + (hash << 2); 65 hash = hash + (hash << 2);
66 hash = hash ^ (hash >>> 4); 66 hash = hash ^ (hash >>> 4);
67 hash = (hash * 2057) | 0; // hash = (hash + (hash << 3)) + (hash << 11); 67 hash = (hash * 2057) | 0; // hash = (hash + (hash << 3)) + (hash << 11);
68 hash = hash ^ (hash >>> 16); 68 hash = hash ^ (hash >>> 16);
69 return hash; 69 return hash;
70 } 70 }
71 %SetInlineBuiltinFlag(ComputeIntegerHash); 71 %SetInlineBuiltinFlag(ComputeIntegerHash);
72 72
73 var hash_code_symbol = GLOBAL_PRIVATE("hash_code_symbol");
73 74
74 function GetHash(key) { 75 function GetHash(key) {
75 if (%_IsSmi(key)) { 76 if (%_IsSmi(key)) {
76 return ComputeIntegerHash(key, 0); 77 return ComputeIntegerHash(key, 0);
77 } 78 }
78 if (IS_STRING(key)) { 79 if (IS_STRING(key)) {
79 var field = %_StringGetRawHashField(key); 80 var field = %_StringGetRawHashField(key);
80 if ((field & 1 /* Name::kHashNotComputedMask */) === 0) { 81 if ((field & 1 /* Name::kHashNotComputedMask */) === 0) {
81 return field >>> 2 /* Name::kHashShift */; 82 return field >>> 2 /* Name::kHashShift */;
82 } 83 }
83 } 84 }
85 if (IS_SPEC_OBJECT(key)) {
adamk 2015/05/14 15:01:27 You might need a TODO here for handling proxies ap
Erik Corry 2015/05/14 15:42:19 Probably. What's the deal with the JSGlobalProxy?
Toon Verwaest 2015/05/15 12:24:10 Due to split-object the global proxy points to the
86 var hash = key[hash_code_symbol];
adamk 2015/05/14 15:01:27 We've been using a GET_PRIVATE() for this as a mat
87 if (hash == void 0) {
adamk 2015/05/14 15:01:27 IS_UNDEFINED(hash)
88 hash = $intrandom() | 0;
89 key[hash_code_symbol] = hash;
adamk 2015/05/14 15:01:27 SET_PRIVATE()
90 }
91 return hash;
92 }
84 return %GenericHash(key); 93 return %GenericHash(key);
85 } 94 }
86 %SetInlineBuiltinFlag(GetHash); 95 %SetInlineBuiltinFlag(GetHash);
87 96
88 97
89 // ------------------------------------------------------------------- 98 // -------------------------------------------------------------------
90 // Harmony Set 99 // Harmony Set
91 100
92 function SetConstructor(iterable) { 101 function SetConstructor(iterable) {
93 if (!%_IsConstructCall()) { 102 if (!%_IsConstructCall()) {
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 $installFunctions(GlobalMap.prototype, DONT_ENUM, [ 440 $installFunctions(GlobalMap.prototype, DONT_ENUM, [
432 "get", MapGet, 441 "get", MapGet,
433 "set", MapSet, 442 "set", MapSet,
434 "has", MapHas, 443 "has", MapHas,
435 "delete", MapDelete, 444 "delete", MapDelete,
436 "clear", MapClearJS, 445 "clear", MapClearJS,
437 "forEach", MapForEach 446 "forEach", MapForEach
438 ]); 447 ]);
439 448
440 }) 449 })
OLDNEW
« no previous file with comments | « no previous file | src/factory.h » ('j') | src/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698