Chromium Code Reviews

Issue 2351763002: [Interpreter] Optimize BytecodeArrayBuilder and BytecodeArrayWriter. (Closed)

Created:
4 years, 3 months ago by rmcilroy
Modified:
4 years, 3 months ago
Reviewers:
mythria, Leszek Swirski
CC:
v8-reviews_googlegroups.com, rmcilroy
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

[Interpreter] Optimize BytecodeArrayBuilder and BytecodeArrayWriter. This CL optimizes the code in BytecodeArrayBuilder and BytecodeArrayWriter by making the following main changes: - Move operand scale calculation out of BytecodeArrayWriter to the BytecodeNode constructor, where the decision on which operands are scalable can generally be statically decided by the compiler. - Move the maximum register calculation out of BytecodeArrayWriter and into BytecodeRegisterOptimizer (which is the only place outside BytecodeGenerator which updates which registers are used). This avoids the BytecodeArrayWriter needing to know the operand types of a node as it writes it. - Modify EmitBytecodes to use individual push_backs rather than building a buffer and calling insert, since this turns out to be faster. - Initialize BytecodeArrayWriter's bytecode vector by reserving 512 bytes, - Make common functions in Bytecodes constexpr so that they can be statically calculated by the compiler. - Move common functions and constructors in Bytecodes and BytecodeNode to the header so that they can be inlined. - Change large static switch statements in Bytecodes to const array lookups, and move to the header to allow inlining. I also took the opportunity to remove a number of unused helper functions, and rework some others for consistency. This reduces the percentage of time spent in making BytecodeArrays in CodeLoad from ~15% to ~11% according to perf. The CoadLoad score increase by around 2%. BUG=v8:4280 Committed: https://crrev.com/b11a8b4d41bf09d6b3d6cf214fe3fb61faf01a64 Committed: https://crrev.com/e5ac75c6354f6dbe0fbe217f857750ab9fb0bd45 Cr-Original-Commit-Position: refs/heads/master@{#39599} Cr-Commit-Position: refs/heads/master@{#39637}

Patch Set 1 #

Patch Set 2 : [Interpreter] Optimize BytecodeArrayBuilder and BytecodeArrayWriter. #

Total comments: 8

Patch Set 3 : Parameter pack BytecodeTraits #

Patch Set 4 : Rebase and fix Windows #

Patch Set 5 : No zero length constant arrays... #

Patch Set 6 : Mythri's comments #

Patch Set 7 : Fix Chromium Windows bots. #

Unified diffs Side-by-side diffs Stats (+1319 lines, -1595 lines)
M BUILD.gn View 2 chunks +5 lines, -0 lines 0 comments
M src/interpreter/bytecode-array-builder.h View 2 chunks +29 lines, -27 lines 0 comments
M src/interpreter/bytecode-array-builder.cc View 14 chunks +199 lines, -291 lines 0 comments
M src/interpreter/bytecode-array-writer.h View 2 chunks +1 line, -3 lines 0 comments
M src/interpreter/bytecode-array-writer.cc View 5 chunks +39 lines, -105 lines 0 comments
M src/interpreter/bytecode-dead-code-optimizer.h View 1 chunk +1 line, -1 line 0 comments
M src/interpreter/bytecode-dead-code-optimizer.cc View 1 chunk +3 lines, -3 lines 0 comments
A src/interpreter/bytecode-operands.h View 1 chunk +126 lines, -0 lines 0 comments
A src/interpreter/bytecode-operands.cc View 1 chunk +89 lines, -0 lines 0 comments
M src/interpreter/bytecode-peephole-optimizer.h View 1 chunk +1 line, -1 line 0 comments
M src/interpreter/bytecode-peephole-optimizer.cc View 5 chunks +8 lines, -8 lines 0 comments
M src/interpreter/bytecode-pipeline.h View 5 chunks +144 lines, -21 lines 0 comments
M src/interpreter/bytecode-pipeline.cc View 2 chunks +0 lines, -56 lines 0 comments
M src/interpreter/bytecode-register-optimizer.h View 3 chunks +9 lines, -12 lines 0 comments
M src/interpreter/bytecode-register-optimizer.cc View 8 chunks +33 lines, -40 lines 0 comments
M src/interpreter/bytecode-traits.h View 2 chunks +70 lines, -190 lines 0 comments
M src/interpreter/bytecodes.h View 8 chunks +359 lines, -232 lines 0 comments
M src/interpreter/bytecodes.cc View 10 chunks +70 lines, -466 lines 0 comments
M src/v8.gyp View 2 chunks +5 lines, -0 lines 0 comments
M test/unittests/interpreter/bytecode-array-writer-unittest.cc View 5 chunks +32 lines, -59 lines 0 comments
M test/unittests/interpreter/bytecode-dead-code-optimizer-unittest.cc View 4 chunks +5 lines, -4 lines 0 comments
M test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc View 13 chunks +30 lines, -28 lines 0 comments
M test/unittests/interpreter/bytecode-pipeline-unittest.cc View 3 chunks +16 lines, -24 lines 0 comments
M test/unittests/interpreter/bytecode-register-optimizer-unittest.cc View 3 chunks +4 lines, -4 lines 0 comments
M test/unittests/interpreter/bytecodes-unittest.cc View 2 chunks +41 lines, -20 lines 0 comments

Depends on Patchset:

Messages

Total messages: 82 (67 generated)
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2351763002/20001
4 years, 3 months ago (2016-09-19 17:25:51 UTC) #6
commit-bot: I haz the power
No L-G-T-M from a valid reviewer yet. CQ run can only be started by full ...
4 years, 3 months ago (2016-09-19 17:25:53 UTC) #8
rmcilroy
Mythri / Leszek, PTAL. This is a big change, but mostly fairly mechanical. I need ...
4 years, 3 months ago (2016-09-20 08:30:55 UTC) #31
Leszek Swirski
https://codereview.chromium.org/2351763002/diff/80001/src/interpreter/bytecode-array-builder.cc File src/interpreter/bytecode-array-builder.cc (right): https://codereview.chromium.org/2351763002/diff/80001/src/interpreter/bytecode-array-builder.cc#newcode381 src/interpreter/bytecode-array-builder.cc:381: } else { DCHECK for strict https://codereview.chromium.org/2351763002/diff/80001/src/interpreter/bytecode-traits.h File src/interpreter/bytecode-traits.h ...
4 years, 3 months ago (2016-09-20 10:37:56 UTC) #32
rmcilroy
https://codereview.chromium.org/2351763002/diff/80001/src/interpreter/bytecode-array-builder.cc File src/interpreter/bytecode-array-builder.cc (right): https://codereview.chromium.org/2351763002/diff/80001/src/interpreter/bytecode-array-builder.cc#newcode381 src/interpreter/bytecode-array-builder.cc:381: } else { On 2016/09/20 10:37:56, Leszek Swirski wrote: ...
4 years, 3 months ago (2016-09-20 16:57:25 UTC) #33
mythria
Nice. lgtm. Thanks, Mythri. https://codereview.chromium.org/2351763002/diff/80001/src/interpreter/bytecode-pipeline.h File src/interpreter/bytecode-pipeline.h (right): https://codereview.chromium.org/2351763002/diff/80001/src/interpreter/bytecode-pipeline.h#newcode277 src/interpreter/bytecode-pipeline.h:277: ResetScale(); may be use UpdateScale(). ...
4 years, 3 months ago (2016-09-21 08:12:45 UTC) #56
Leszek Swirski
lgtm from me too
4 years, 3 months ago (2016-09-21 14:11:50 UTC) #57
rmcilroy
https://codereview.chromium.org/2351763002/diff/80001/src/interpreter/bytecode-pipeline.h File src/interpreter/bytecode-pipeline.h (right): https://codereview.chromium.org/2351763002/diff/80001/src/interpreter/bytecode-pipeline.h#newcode277 src/interpreter/bytecode-pipeline.h:277: ResetScale(); On 2016/09/21 08:12:45, mythria wrote: > may be ...
4 years, 3 months ago (2016-09-21 14:12:34 UTC) #58
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2351763002/200001
4 years, 3 months ago (2016-09-21 14:54:03 UTC) #65
commit-bot: I haz the power
Committed patchset #6 (id:200001)
4 years, 3 months ago (2016-09-21 15:02:41 UTC) #67
commit-bot: I haz the power
Patchset 6 (id:??) landed as https://crrev.com/b11a8b4d41bf09d6b3d6cf214fe3fb61faf01a64 Cr-Commit-Position: refs/heads/master@{#39599}
4 years, 3 months ago (2016-09-21 15:03:14 UTC) #69
Michael Hablich
A revert of this CL (patchset #6 id:200001) has been created in https://codereview.chromium.org/2360193003/ by hablich@chromium.org. ...
4 years, 3 months ago (2016-09-22 05:53:02 UTC) #70
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2351763002/220001
4 years, 3 months ago (2016-09-22 16:31:12 UTC) #78
commit-bot: I haz the power
Committed patchset #7 (id:220001)
4 years, 3 months ago (2016-09-22 16:34:23 UTC) #80
commit-bot: I haz the power
4 years, 3 months ago (2016-09-22 16:34:42 UTC) #82
Message was sent while issue was closed.
Patchset 7 (id:??) landed as
https://crrev.com/e5ac75c6354f6dbe0fbe217f857750ab9fb0bd45
Cr-Commit-Position: refs/heads/master@{#39637}

Powered by Google App Engine