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

Issue 1392933002: [Interpreter] Reduce temporary register usage in generated bytecode. (Closed)

Created:
5 years, 2 months ago by oth
Modified:
5 years, 2 months ago
CC:
v8-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

[Interpreter] Reduce temporary register usage in generated bytecode. This change adds new flavors of Visit() methods for obtaining expression results: - VisitForAccumulatorValue() which places result in the accumulator. - VisitForRegisterValue() which places the result in a register. - VisitForEffect() which evaluates the expression and discards the result. The targets of these calls place the expression result with result_scope()->SetResultInRegister() or result_scope()->SetResultInAccumulator(). By being smarter about result locations, there's less temporary register usage. However, we now have a hazard with assignments in binary expressions that didn't exist before. This change detects and DCHECK's when a hazard is detected. A follow on CL will address this. There are consequential changes to test-bytecode-generator.cc and this change also adds new bytecode macros A(x, n) and THIS(n) for register file entries for arguments and this. BUG=v8:4280 LOG=NO Committed: https://crrev.com/339e0c804ec60347d401a09bb62182dabb7ee54c Cr-Commit-Position: refs/heads/master@{#31445}

Patch Set 1 #

Patch Set 2 : Rebase. #

Patch Set 3 : Rebase. #

Total comments: 22

Patch Set 4 : Incorporate majority of the review comments in https://codereview.chromium.org/1392933002/ #

Patch Set 5 : VisitForEffect. #

Patch Set 6 : Update comment in BytecodeGenerator::VisitCall(). #

Total comments: 2

Patch Set 7 : No default. #

Patch Set 8 : nop. #

Patch Set 9 : Remove result_register_ from BytecodeGenerator. #

Patch Set 10 : Detect and correct for assignments in binary expressions. #

Patch Set 11 : Additional comments, unbreak test. #

Patch Set 12 : Introduce top-level result scope and simplify allocation/free. #

Patch Set 13 : Rebase and switch to detection of bad assignments only. #

Patch Set 14 : Remove dead code. #

Total comments: 81

Patch Set 15 : Incorporate review comments. #

Patch Set 16 : Missed comments. #

Total comments: 22

Patch Set 17 : Incorporate comments from rmcilroy on patch set 16. #

Patch Set 18 : Rebase and additional check in LoadLiteral for effect. #

Patch Set 19 : Remove an unnecessary TemporaryRegisterScope. #

Patch Set 20 : Fix signed-unsigned comparison. #

Total comments: 8

Patch Set 21 : Another signed-unsigned nit. #

Patch Set 22 : Undo some git cl formatting of test-bytecode-generator.cc #

Patch Set 23 : Incorporate comments from mstarzinger. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+993 lines, -680 lines) Patch
M src/interpreter/bytecode-array-builder.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 7 chunks +30 lines, -10 lines 0 comments Download
M src/interpreter/bytecode-array-builder.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 7 chunks +122 lines, -19 lines 0 comments Download
M src/interpreter/bytecode-generator.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 4 chunks +27 lines, -2 lines 0 comments Download
M src/interpreter/bytecode-generator.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 45 chunks +370 lines, -149 lines 0 comments Download
M src/interpreter/bytecodes.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +12 lines, -2 lines 0 comments Download
M test/cctest/interpreter/test-bytecode-generator.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 44 chunks +404 lines, -496 lines 0 comments Download
M test/unittests/interpreter/bytecode-array-builder-unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 2 chunks +28 lines, -2 lines 0 comments Download

Messages

Total messages: 34 (9 generated)
oth
mstarzinger@chromium.org, : Please review changes in interpreter. rmcilroy@chromium.org: Please review changes in interpreter and test. ...
5 years, 2 months ago (2015-10-08 09:00:52 UTC) #2
rmcilroy
https://codereview.chromium.org/1392933002/diff/40001/src/interpreter/bytecode-generator.cc File src/interpreter/bytecode-generator.cc (right): https://codereview.chromium.org/1392933002/diff/40001/src/interpreter/bytecode-generator.cc#newcode104 src/interpreter/bytecode-generator.cc:104: virtual void RegisterSet(Register reg) = 0; Not sure I ...
5 years, 2 months ago (2015-10-08 16:54:26 UTC) #3
rmcilroy
https://codereview.chromium.org/1392933002/diff/40001/src/interpreter/bytecode-generator.cc File src/interpreter/bytecode-generator.cc (right): https://codereview.chromium.org/1392933002/diff/40001/src/interpreter/bytecode-generator.cc#newcode567 src/interpreter/bytecode-generator.cc:567: builder()->StoreAccumulatorInRegister(destination); On 2015/10/08 16:54:25, rmcilroy wrote: > I was ...
5 years, 2 months ago (2015-10-08 17:00:09 UTC) #4
oth
Thanks, comments incorporated with a couple of exceptions discussed. Will progress the mid-expression register mutation ...
5 years, 2 months ago (2015-10-09 12:50:48 UTC) #5
rmcilroy
https://codereview.chromium.org/1392933002/diff/40001/src/interpreter/bytecode-generator.h File src/interpreter/bytecode-generator.h (right): https://codereview.chromium.org/1392933002/diff/40001/src/interpreter/bytecode-generator.h#newcode50 src/interpreter/bytecode-generator.h:50: void VisitForRegisterValue(Expression* expression, On 2015/10/09 12:50:48, oth wrote: > ...
5 years, 2 months ago (2015-10-09 13:02:56 UTC) #6
oth
RegisterResultScope? Yep! It falls into the same bucket we discussed this morning in the guise ...
5 years, 2 months ago (2015-10-09 13:27:39 UTC) #7
oth
On 2015/10/09 13:27:39, oth wrote: > RegisterResultScope? Yep! It falls into the same bucket we ...
5 years, 2 months ago (2015-10-11 21:18:13 UTC) #8
oth
We're putting this on ice for the time being. Please don't spend time looking at ...
5 years, 2 months ago (2015-10-12 11:34:00 UTC) #9
oth
Ross, PTAL. The latest patch switches to simply detecting assignments in expressions rather than correcting ...
5 years, 2 months ago (2015-10-19 08:55:22 UTC) #10
rmcilroy
Overall looking much cleaner, I like it! A bunch of comments but the main ones ...
5 years, 2 months ago (2015-10-19 12:56:23 UTC) #11
oth
Thanks, most of these are incorporated. There's a couple I'd like to see us leave ...
5 years, 2 months ago (2015-10-20 15:28:53 UTC) #12
rmcilroy
Please remove the "(NOT FOR REVIEW)" from the title. Also check if Michi wants to ...
5 years, 2 months ago (2015-10-20 16:39:20 UTC) #13
oth
Thanks Ross, all incorporated. Michi, do you have time to take look? https://codereview.chromium.org/1392933002/diff/290001/src/interpreter/bytecode-array-builder.cc File src/interpreter/bytecode-array-builder.cc ...
5 years, 2 months ago (2015-10-20 20:58:42 UTC) #16
rmcilroy
All still LGTM, thanks.
5 years, 2 months ago (2015-10-21 07:47:29 UTC) #17
oth
On 2015/10/21 07:47:29, rmcilroy wrote: > All still LGTM, thanks. Thanks. Will wait on test262 ...
5 years, 2 months ago (2015-10-21 08:59:22 UTC) #18
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1392933002/350001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1392933002/350001
5 years, 2 months ago (2015-10-21 13:31:36 UTC) #20
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_win_rel on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_win_rel/builds/10885)
5 years, 2 months ago (2015-10-21 13:38:21 UTC) #23
Michael Starzinger
I don't want to block this, so go ahead and land this to unblock other ...
5 years, 2 months ago (2015-10-21 14:34:04 UTC) #24
Michael Starzinger
LGTM once the one concrete comment is addressed.
5 years, 2 months ago (2015-10-21 15:04:29 UTC) #25
oth
Thanks Michael. Comments incorporated. https://codereview.chromium.org/1392933002/diff/370001/src/interpreter/bytecode-generator.cc File src/interpreter/bytecode-generator.cc (right): https://codereview.chromium.org/1392933002/diff/370001/src/interpreter/bytecode-generator.cc#newcode151 src/interpreter/bytecode-generator.cc:151: explicit ExpressionResultScope(BytecodeGenerator* generator, On 2015/10/21 ...
5 years, 2 months ago (2015-10-21 15:10:12 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1392933002/420001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1392933002/420001
5 years, 2 months ago (2015-10-21 15:10:38 UTC) #29
commit-bot: I haz the power
Committed patchset #23 (id:420001)
5 years, 2 months ago (2015-10-21 15:29:01 UTC) #30
commit-bot: I haz the power
Patchset 23 (id:??) landed as https://crrev.com/339e0c804ec60347d401a09bb62182dabb7ee54c Cr-Commit-Position: refs/heads/master@{#31445}
5 years, 2 months ago (2015-10-21 15:29:32 UTC) #31
Toon Verwaest
I just zigzagged through this CL, but one comment. Don't forget to handle the following ...
5 years, 2 months ago (2015-10-21 19:33:20 UTC) #33
rmcilroy
5 years, 2 months ago (2015-10-21 21:46:24 UTC) #34
Message was sent while issue was closed.
On 2015/10/21 19:33:20, Toon Verwaest wrote:
> I just zigzagged through this CL, but one comment. Don't forget to handle the
> following "hazard":
> 
> (function(a) { return a + (arguments[0] = 10) })(1)

I *think* this should be fine because sloppy mode parameters are context
allocated when the function loads from the arguments object (so won't be
accessed directly from interpreter registers), but this is a very good point and
we should make sure to have a test for this when we handle these "hazards"

Powered by Google App Engine
This is Rietveld 408576698