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

Unified Diff: test/mjsunit/global-hash.js

Issue 1149863005: Move hash code from hidden string to a private symbol (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix global object hash code. This eated about 5% of weak collection performance 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
« src/objects.cc ('K') | « test/cctest/test-weaksets.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/global-hash.js
diff --git a/test/mjsunit/string-search.js b/test/mjsunit/global-hash.js
similarity index 77%
copy from test/mjsunit/string-search.js
copy to test/mjsunit/global-hash.js
index 037725b95eb99ee843dc9e3cb511292e05bedaf4..18ea9f9e7786e865f9d550231dd4be3f1f1d16c1 100644
--- a/test/mjsunit/string-search.js
+++ b/test/mjsunit/global-hash.js
@@ -1,4 +1,4 @@
-// Copyright 2008 the V8 project authors. All rights reserved.
+// Copyright 2015 the V8 project authors. All rights reserved.
adamk 2015/05/21 19:11:32 Please use the short license header for new tests.
Erik Corry 2015/05/22 06:20:25 Done.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -25,15 +25,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-var str="ABC abc";
-var r = str.search('a');
-assertEquals(r, 4);
+var global = this;
-// Test for a lot of different string.
+assertTrue(typeof(global) === "object"); // Global object.
-var s = "";
+var s = new Set();
+s.add(global); // Puts a hash code on the global object.
+assertTrue(s.has(global));
for (var i = 0; i < 100; i++) {
- s += i;
- var r = s.search(s);
- assertEquals(0, r);
+ // Force rehash. Global object is placed according to the hash code that it
+ // gets in the C++ runtime.
+ s.add(i);
}
+
+// Hopefully still findable using the JS hash code.
adamk 2015/05/21 19:11:32 This test is good, but can you also add a cctest t
Erik Corry 2015/05/22 06:20:25 We already had this in test-api.cc, but it added t
+assertTrue(s.has(global));
« src/objects.cc ('K') | « test/cctest/test-weaksets.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698