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

Issue 1149863005: Move hash code from hidden string to a private symbol (Closed)

Created:
5 years, 7 months ago by Erik Corry Chromium.org
Modified:
5 years, 7 months ago
CC:
v8-dev, v8-mips-ports_googlegroups.com
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Move hash code from hidden string to a private symbol * Hash code is now just done with a private own symbol instead of the hidden string, which predates symbols. * In the long run we should do all hidden properties this way and get rid of the hidden magic 0-length string with the zero hash code. The advantages include less complexity and being able to do things from JS in a natural way. * Initially, the performance of weak set regressed, because it's a little harder to do the lookup in C++. Instead of heroics in C++ to make things faster I moved some functionality into JS and got the performance back. JS is supposed to be good at looking up named properties on objects. * This also changes hash codes of Smis so that they are always Smis. Performance figures are in the comments to the code review. Summary: Most of js-perf-test/Collections is neutral. Set and Map with object keys are 40-50% better. WeakMap is -5% and WeakSet is +9%. After the measurements, I fixed global proxies, which cost 1% on most tests and 5% on the weak ones :-(. In the code review comments is a patch with an example of the heroics we could do in C++ to make lookup faster (I hope we don't have to do this. Instead of checking for the property, then doing a new lookup to insert it, we could do one lookup and handle the addition immediately). With the current benchmarks above this buys us nothing, but if we go back to doing more lookups in C++ instead of in stubs and JS then it's a win. In a similar vein we could give the magic zero hash code to the hash code symbol. Then when we look up the hash code we would sometimes see the table with all the hidden properties. This dual use of the field for either the hash code or the table with all hidden properties and the hash code is rather ugly, and this CL gets rid of it. I'd be loath to bring it back. On the benchmarks quoted above it's slightly slower than moving the hash code lookup to JS like in this CL. One worry is that the benchmark results above are more monomorphic than real world code, so may be overstating the performance benefits of moving to JS. I think this is part of a general issue we have with handling polymorphic code in JS and any solutions there will benefit this solution, which boils down to regular property access. Any improvement there will lift all boats. R=adamk@chromium.org, verwaest@chromium.org BUG= Committed: https://crrev.com/eca5b5d7abc0a9028cb9832087fbf2ed59dadf92 Cr-Commit-Position: refs/heads/master@{#28622}

Patch Set 1 #

Patch Set 2 : Fix tests and remove ugly strcmp in isolate.cc #

Patch Set 3 : Fix global object hash code. This eated about 5% of weak collection performance #

Total comments: 31

Patch Set 4 : CR feedback #

Patch Set 5 : Merge up with import/export in natives #

Patch Set 6 : Fix smi hash code to be a smi in ASM on x64,ia32,arm,arm64,mips #

Patch Set 7 : Fix MIPS #

Total comments: 19

Patch Set 8 : Feedback from Toon #

Patch Set 9 : Merge up #

Patch Set 10 : Fix merge #

Unified diffs Side-by-side diffs Delta from patch set Stats (+340 lines, -181 lines) Patch
M src/api.cc View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -1 line 0 comments Download
M src/arm/macro-assembler-arm.cc View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M src/arm64/macro-assembler-arm64.cc View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M src/collection.js View 1 2 3 4 5 6 7 8 9 10 chunks +54 lines, -20 lines 0 comments Download
M src/factory.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download
M src/factory.cc View 1 2 3 4 5 6 7 8 1 chunk +6 lines, -1 line 0 comments Download
M src/heap/heap.h View 1 2 3 4 5 6 7 8 3 chunks +3 lines, -1 line 0 comments Download
M src/heap/heap.cc View 1 2 3 4 5 6 7 8 2 chunks +19 lines, -3 lines 0 comments Download
M src/ia32/macro-assembler-ia32.cc View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M src/isolate.h View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -0 lines 0 comments Download
M src/isolate.cc View 1 2 3 4 5 6 7 1 chunk +17 lines, -9 lines 0 comments Download
M src/math.js View 1 2 3 4 5 6 7 8 3 chunks +10 lines, -1 line 0 comments Download
M src/mips/macro-assembler-mips.cc View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M src/mips64/macro-assembler-mips64.cc View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M src/object-observe.js View 1 2 3 4 5 6 7 8 2 chunks +10 lines, -7 lines 0 comments Download
M src/objects.h View 1 2 3 4 5 6 7 8 3 chunks +14 lines, -0 lines 0 comments Download
M src/objects.cc View 1 2 3 4 5 6 7 8 15 chunks +71 lines, -52 lines 0 comments Download
M src/objects-inl.h View 1 2 3 4 5 6 7 8 1 chunk +9 lines, -2 lines 0 comments Download
M src/runtime/runtime.h View 1 2 3 4 5 6 7 8 2 chunks +8 lines, -5 lines 0 comments Download
M src/runtime/runtime-collections.cc View 3 chunks +25 lines, -11 lines 0 comments Download
M src/runtime/runtime-symbol.cc View 1 2 3 4 5 6 7 2 chunks +7 lines, -12 lines 0 comments Download
M src/utils.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M src/weak-collection.js View 1 2 3 4 5 6 7 8 7 chunks +17 lines, -7 lines 0 comments Download
M src/x64/macro-assembler-x64.cc View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M test/cctest/test-api.cc View 1 2 3 4 5 6 7 8 2 chunks +20 lines, -2 lines 0 comments Download
M test/cctest/test-hashing.cc View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M test/cctest/test-heap.cc View 1 2 3 4 5 6 7 8 1 chunk +0 lines, -35 lines 0 comments Download
M test/cctest/test-weakmaps.cc View 1 4 chunks +10 lines, -5 lines 0 comments Download
M test/cctest/test-weaksets.cc View 1 4 chunks +8 lines, -4 lines 0 comments Download
A test/mjsunit/global-hash.js View 1 2 3 4 5 6 7 1 chunk +19 lines, -0 lines 0 comments Download

Messages

Total messages: 42 (17 generated)
Erik Corry Chromium.org
5 years, 7 months ago (2015-05-21 10:56:36 UTC) #1
Erik Corry Chromium.org
Here is a new attempt, based on the previous one. Summary: Global proxy is still ...
5 years, 7 months ago (2015-05-21 11:13:09 UTC) #3
adamk
Thanks for the detailed writeup, can you move the important bits of that into the ...
5 years, 7 months ago (2015-05-21 19:11:33 UTC) #4
Erik Corry
https://codereview.chromium.org/1149863005/diff/40001/src/collection.js File src/collection.js (left): https://codereview.chromium.org/1149863005/diff/40001/src/collection.js#oldcode26 src/collection.js:26: for (var entry = HashToEntry(table, hash, numBuckets); On 2015/05/21 ...
5 years, 7 months ago (2015-05-21 20:19:02 UTC) #6
Erik Corry
https://codereview.chromium.org/1149863005/diff/40001/src/collection.js File src/collection.js (right): https://codereview.chromium.org/1149863005/diff/40001/src/collection.js#newcode5 src/collection.js:5: var $gethash; On 2015/05/21 19:11:32, adamk wrote: > Rename ...
5 years, 7 months ago (2015-05-22 06:20:25 UTC) #7
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1149863005/80001
5 years, 7 months ago (2015-05-22 07:37:52 UTC) #9
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux_nodcheck_rel on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_nodcheck_rel/builds/2933)
5 years, 7 months ago (2015-05-22 07:50:22 UTC) #11
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1149863005/100001
5 years, 7 months ago (2015-05-22 09:54:37 UTC) #13
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years, 7 months ago (2015-05-22 10:25:19 UTC) #15
adamk
lgtm Still think it'd be good for Toon to sign off as well.
5 years, 7 months ago (2015-05-22 17:58:49 UTC) #16
paul.l...
MIPS code lgtm, can be written using macro-asm as And(reg0, reg0, Operand(0x3fffffff)); for clarity. Same ...
5 years, 7 months ago (2015-05-25 05:42:07 UTC) #18
paul.l...
adding v8-mips-ports group, since i am out of office.
5 years, 7 months ago (2015-05-25 05:45:00 UTC) #19
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1149863005/120001
5 years, 7 months ago (2015-05-26 07:36:28 UTC) #22
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux64_avx2_rel on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_avx2_rel/builds/709)
5 years, 7 months ago (2015-05-26 07:38:22 UTC) #24
Toon Verwaest
https://codereview.chromium.org/1149863005/diff/120001/src/collection.js File src/collection.js (right): https://codereview.chromium.org/1149863005/diff/120001/src/collection.js#newcode86 src/collection.js:86: function GetExistingHash(key) { That's a pretty deceiving name since ...
5 years, 7 months ago (2015-05-26 09:06:27 UTC) #25
Erik Corry
5 years, 7 months ago (2015-05-26 09:50:25 UTC) #26
Erik Corry Chromium.org
https://codereview.chromium.org/1149863005/diff/120001/src/collection.js File src/collection.js (right): https://codereview.chromium.org/1149863005/diff/120001/src/collection.js#newcode86 src/collection.js:86: function GetExistingHash(key) { On 2015/05/26 09:06:26, Toon Verwaest wrote: ...
5 years, 7 months ago (2015-05-26 09:51:32 UTC) #27
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1149863005/140001
5 years, 7 months ago (2015-05-26 10:00:13 UTC) #30
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux64_avx2_rel on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_avx2_rel/builds/721)
5 years, 7 months ago (2015-05-26 10:01:56 UTC) #32
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1149863005/180001
5 years, 7 months ago (2015-05-26 10:26:21 UTC) #35
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years, 7 months ago (2015-05-26 10:53:26 UTC) #37
Toon Verwaest
lgtm
5 years, 7 months ago (2015-05-26 11:22:54 UTC) #38
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1149863005/180001
5 years, 7 months ago (2015-05-26 11:24:14 UTC) #40
commit-bot: I haz the power
Committed patchset #10 (id:180001)
5 years, 7 months ago (2015-05-26 11:26:35 UTC) #41
commit-bot: I haz the power
5 years, 7 months ago (2015-05-26 11:26:49 UTC) #42
Message was sent while issue was closed.
Patchset 10 (id:??) landed as
https://crrev.com/eca5b5d7abc0a9028cb9832087fbf2ed59dadf92
Cr-Commit-Position: refs/heads/master@{#28622}

Powered by Google App Engine
This is Rietveld 408576698