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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/factory.h » ('j') | src/isolate.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/collection.js
diff --git a/src/collection.js b/src/collection.js
index db30546165119e53f0c4e03a1b5e856259927f10..97669d9161ba65a145f93e6cf01facd400d35a61 100644
--- a/src/collection.js
+++ b/src/collection.js
@@ -70,6 +70,7 @@ function ComputeIntegerHash(key, seed) {
}
%SetInlineBuiltinFlag(ComputeIntegerHash);
+var hash_code_symbol = GLOBAL_PRIVATE("hash_code_symbol");
function GetHash(key) {
if (%_IsSmi(key)) {
@@ -81,6 +82,14 @@ function GetHash(key) {
return field >>> 2 /* Name::kHashShift */;
}
}
+ 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
+ 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
+ if (hash == void 0) {
adamk 2015/05/14 15:01:27 IS_UNDEFINED(hash)
+ hash = $intrandom() | 0;
+ key[hash_code_symbol] = hash;
adamk 2015/05/14 15:01:27 SET_PRIVATE()
+ }
+ return hash;
+ }
return %GenericHash(key);
}
%SetInlineBuiltinFlag(GetHash);
« 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