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

Issue 1092353002: [strong] Disallow implicit conversions for binary arithmetic operations (Closed)

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

Description

[strong] Disallow implicit conversions for binary arithmetic operations Implements the strong mode proposal's restrictions on implicit conversions for binary arithmetic operations, not including the + special case. Adds some infrastructure for future implementation of the restrictions for other operators. BUG=v8:3956 LOG=N Committed: https://crrev.com/ae7ce701aef2356424bb35ace91cd0ca595fe047 Cr-Commit-Position: refs/heads/master@{#28045}

Patch Set 1 : Reimplement based on offline discussions #

Patch Set 2 : Check correct behaviour when non-throw #

Patch Set 3 : Fix minor formatting nit #

Patch Set 4 : rebase :( #

Total comments: 41

Patch Set 5 : cl feedback #

Total comments: 4

Patch Set 6 : cl feedback 2 #

Total comments: 4

Patch Set 7 : cl feedback 3 #

Total comments: 2

Patch Set 8 : cl feedback 4, rebase #

Total comments: 4

Patch Set 9 : cl feedback 5 #

Total comments: 21
Unified diffs Side-by-side diffs Delta from patch set Stats (+815 lines, -346 lines) Patch
M src/arm/full-codegen-arm.cc View 3 chunks +6 lines, -3 lines 0 comments Download
M src/arm/lithium-codegen-arm.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/arm64/full-codegen-arm64.cc View 3 chunks +6 lines, -3 lines 0 comments Download
M src/arm64/lithium-codegen-arm64.cc View 2 chunks +3 lines, -2 lines 0 comments Download
M src/builtins.h View 1 chunk +4 lines, -0 lines 0 comments Download
M src/code-factory.h View 1 chunk +2 lines, -1 line 0 comments Download
M src/code-factory.cc View 1 chunk +3 lines, -2 lines 0 comments Download
M src/code-stubs.h View 2 chunks +5 lines, -4 lines 0 comments Download
M src/code-stubs.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/compiler/ast-graph-builder.cc View 1 2 3 4 5 6 7 5 chunks +21 lines, -18 lines 0 comments Download
M src/compiler/js-generic-lowering.cc View 1 2 3 1 chunk +2 lines, -1 line 0 comments Download
M src/compiler/js-operator.h View 1 2 3 4 5 6 7 1 chunk +15 lines, -15 lines 0 comments Download
M src/compiler/js-operator.cc View 1 2 3 4 5 6 7 4 chunks +51 lines, -15 lines 0 comments Download
M src/compiler/js-typed-lowering.cc View 1 2 3 4 1 chunk +7 lines, -0 lines 0 comments Download
M src/hydrogen.h View 1 chunk +2 lines, -1 line 0 comments Download
M src/hydrogen.cc View 5 chunks +7 lines, -5 lines 0 comments Download
M src/ia32/full-codegen-ia32.cc View 3 chunks +6 lines, -3 lines 0 comments Download
M src/ia32/lithium-codegen-ia32.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/ic/ic.h View 1 chunk +2 lines, -1 line 0 comments Download
M src/ic/ic.cc View 1 2 3 4 5 6 2 chunks +33 lines, -38 lines 2 comments Download
M src/ic/ic-state.h View 1 2 3 4 3 chunks +11 lines, -5 lines 1 comment Download
M src/ic/ic-state.cc View 1 2 3 4 4 chunks +11 lines, -9 lines 0 comments Download
M src/messages.js View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M src/mips/full-codegen-mips.cc View 3 chunks +6 lines, -3 lines 0 comments Download
M src/mips/lithium-codegen-mips.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/mips64/full-codegen-mips64.cc View 3 chunks +6 lines, -3 lines 0 comments Download
M src/mips64/lithium-codegen-mips64.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/ppc/full-codegen-ppc.cc View 3 chunks +6 lines, -3 lines 0 comments Download
M src/ppc/lithium-codegen-ppc.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/runtime.js View 1 2 3 4 4 chunks +35 lines, -0 lines 0 comments Download
M src/x64/full-codegen-x64.cc View 3 chunks +6 lines, -4 lines 0 comments Download
M src/x64/lithium-codegen-x64.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/x87/full-codegen-x87.cc View 3 chunks +6 lines, -3 lines 0 comments Download
M src/x87/lithium-codegen-x87.cc View 1 chunk +2 lines, -1 line 0 comments Download
M test/cctest/compiler/test-js-context-specialization.cc View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M test/cctest/compiler/test-js-typed-lowering.cc View 1 2 3 4 5 6 7 8 25 chunks +112 lines, -79 lines 0 comments Download
A test/mjsunit/strong/implicit-conversions.js View 1 2 3 4 1 chunk +164 lines, -0 lines 16 comments Download
M test/unittests/compiler/js-operator-unittest.cc View 1 2 3 4 5 6 7 7 chunks +140 lines, -45 lines 2 comments Download
M test/unittests/compiler/js-typed-lowering-unittest.cc View 1 2 3 4 5 6 7 8 6 chunks +22 lines, -13 lines 0 comments Download
M test/unittests/compiler/scheduler-unittest.cc View 1 2 3 22 chunks +28 lines, -28 lines 0 comments Download
M test/unittests/compiler/typer-unittest.cc View 1 2 3 4 3 chunks +68 lines, -29 lines 0 comments Download

Messages

Total messages: 36 (15 generated)
conradw
On 2015/04/20 15:29:38, conradw wrote: > mailto:conradw@chromium.org changed reviewers: > + mailto:rossberg@chromium.org PTAL
5 years, 8 months ago (2015-04-20 16:36:17 UTC) #2
Sven Panne
Tiny DBC... https://codereview.chromium.org/1092353002/diff/40001/src/code-stubs.h File src/code-stubs.h (right): https://codereview.chromium.org/1092353002/diff/40001/src/code-stubs.h#newcode1251 src/code-stubs.h:1251: BinaryOpICStub(Isolate* isolate, Token::Value op, bool strong) Boolean ...
5 years, 8 months ago (2015-04-21 07:00:37 UTC) #4
conradw
PTAL I've got rid of the previous patchsets since this attempt is mostly a new ...
5 years, 8 months ago (2015-04-22 19:14:50 UTC) #13
rossberg
Looks pretty good! Adding mstarzinger to sign off the TF changes. Sven, see my first ...
5 years, 8 months ago (2015-04-23 13:29:37 UTC) #16
Michael Starzinger
https://codereview.chromium.org/1092353002/diff/240001/src/compiler/ast-graph-builder.cc File src/compiler/ast-graph-builder.cc (right): https://codereview.chromium.org/1092353002/diff/240001/src/compiler/ast-graph-builder.cc#newcode1272 src/compiler/ast-graph-builder.cc:1272: Node* exit_cond = NewNode(javascript()->LessThan(language_mode()), The index used here is ...
5 years, 8 months ago (2015-04-23 13:47:52 UTC) #17
conradw
https://codereview.chromium.org/1092353002/diff/240001/src/code-stubs.h File src/code-stubs.h (right): https://codereview.chromium.org/1092353002/diff/240001/src/code-stubs.h#newcode1253 src/code-stubs.h:1253: BinaryOpICState state(isolate, op, language_mode); On 2015/04/23 13:29:37, rossberg wrote: ...
5 years, 8 months ago (2015-04-23 14:51:55 UTC) #18
Michael Starzinger
https://codereview.chromium.org/1092353002/diff/240001/src/compiler/js-operator.cc File src/compiler/js-operator.cc (right): https://codereview.chromium.org/1092353002/diff/240001/src/compiler/js-operator.cc#newcode233 src/compiler/js-operator.cc:233: #define CACHED_OP_LIST_WITH_STRONG(V) \ On 2015/04/23 14:51:54, conradw wrote: > ...
5 years, 8 months ago (2015-04-23 15:20:54 UTC) #19
rossberg
https://codereview.chromium.org/1092353002/diff/240001/test/unittests/compiler/js-operator-unittest.cc File test/unittests/compiler/js-operator-unittest.cc (right): https://codereview.chromium.org/1092353002/diff/240001/test/unittests/compiler/js-operator-unittest.cc#newcode33 test/unittests/compiler/js-operator-unittest.cc:33: SharedOperator(const Operator* (JSOperatorBuilder::*cached)(), On 2015/04/23 14:51:55, conradw wrote: > ...
5 years, 8 months ago (2015-04-23 15:36:58 UTC) #20
conradw
https://codereview.chromium.org/1092353002/diff/240001/src/compiler/js-operator.cc File src/compiler/js-operator.cc (right): https://codereview.chromium.org/1092353002/diff/240001/src/compiler/js-operator.cc#newcode233 src/compiler/js-operator.cc:233: #define CACHED_OP_LIST_WITH_STRONG(V) \ On 2015/04/23 15:20:53, Michael Starzinger wrote: ...
5 years, 8 months ago (2015-04-23 16:08:02 UTC) #21
rossberg
LGTM modulo nits https://codereview.chromium.org/1092353002/diff/280001/src/ic/ic.cc File src/ic/ic.cc (right): https://codereview.chromium.org/1092353002/diff/280001/src/ic/ic.cc#newcode2811 src/ic/ic.cc:2811: switch (op) { Nit: to compress ...
5 years, 8 months ago (2015-04-24 09:50:21 UTC) #22
conradw
@mstarzinger: everything looks ok? https://codereview.chromium.org/1092353002/diff/280001/src/ic/ic.cc File src/ic/ic.cc (right): https://codereview.chromium.org/1092353002/diff/280001/src/ic/ic.cc#newcode2811 src/ic/ic.cc:2811: switch (op) { On 2015/04/24 ...
5 years, 8 months ago (2015-04-24 10:55:16 UTC) #23
rossberg
https://codereview.chromium.org/1092353002/diff/260001/src/compiler/js-operator.h File src/compiler/js-operator.h (right): https://codereview.chromium.org/1092353002/diff/260001/src/compiler/js-operator.h#newcode236 src/compiler/js-operator.h:236: const Operator* UnaryNot(LanguageMode language_mode); On 2015/04/23 16:08:02, conradw wrote: ...
5 years, 8 months ago (2015-04-24 11:08:18 UTC) #24
Michael Starzinger
https://codereview.chromium.org/1092353002/diff/300001/src/compiler/js-operator.h File src/compiler/js-operator.h (right): https://codereview.chromium.org/1092353002/diff/300001/src/compiler/js-operator.h#newcode236 src/compiler/js-operator.h:236: const Operator* UnaryNot(LanguageMode language_mode); Let me try to rephrase ...
5 years, 8 months ago (2015-04-24 11:26:38 UTC) #25
conradw
https://codereview.chromium.org/1092353002/diff/260001/src/compiler/js-operator.h File src/compiler/js-operator.h (right): https://codereview.chromium.org/1092353002/diff/260001/src/compiler/js-operator.h#newcode236 src/compiler/js-operator.h:236: const Operator* UnaryNot(LanguageMode language_mode); On 2015/04/24 11:08:18, rossberg wrote: ...
5 years, 8 months ago (2015-04-24 11:35:37 UTC) #26
Michael Starzinger
LGTM. The CL description talks about "casts", I think it it would make more sense ...
5 years, 8 months ago (2015-04-24 11:47:07 UTC) #27
conradw
Renamed https://codereview.chromium.org/1092353002/diff/320001/test/cctest/compiler/test-js-typed-lowering.cc File test/cctest/compiler/test-js-typed-lowering.cc (right): https://codereview.chromium.org/1092353002/diff/320001/test/cctest/compiler/test-js-typed-lowering.cc#newcode234 test/cctest/compiler/test-js-typed-lowering.cc:234: TEST(StringBinops) { On 2015/04/24 11:47:06, Michael Starzinger wrote: ...
5 years, 8 months ago (2015-04-24 12:04:44 UTC) #28
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1092353002/340001
5 years, 8 months ago (2015-04-24 12:30:58 UTC) #31
commit-bot: I haz the power
Committed patchset #9 (id:340001)
5 years, 8 months ago (2015-04-24 12:33:05 UTC) #32
commit-bot: I haz the power
Patchset 9 (id:??) landed as https://crrev.com/ae7ce701aef2356424bb35ace91cd0ca595fe047 Cr-Commit-Position: refs/heads/master@{#28045}
5 years, 8 months ago (2015-04-24 12:33:19 UTC) #33
arv (Not doing code reviews)
LGTM Since `git cl format` does not check JavaScript I used the arv linter instead. ...
5 years, 8 months ago (2015-04-24 14:14:23 UTC) #35
conradw
5 years, 8 months ago (2015-04-24 14:42:32 UTC) #36
Message was sent while issue was closed.
https://codereview.chromium.org/1092353002/diff/340001/src/ic/ic.cc
File src/ic/ic.cc (right):

https://codereview.chromium.org/1092353002/diff/340001/src/ic/ic.cc#newcode2810
src/ic/ic.cc:2810: if (is_strong(language_mode)) {
On 2015/04/24 14:14:23, arv wrote:
> Why is this needed? The two branches looks identical to me.

In strong mode, the strong version of the builtin needs to be selected (e.g.
Builtins::SUB_STRONG). Eventually, all of the cases in the strong branch will
select strong versions, but some ops are still WIP.

https://codereview.chromium.org/1092353002/diff/340001/test/mjsunit/strong/im...
File test/mjsunit/strong/implicit-conversions.js (right):

https://codereview.chromium.org/1092353002/diff/340001/test/mjsunit/strong/im...
test/mjsunit/strong/implicit-conversions.js:11: "-",
On 2015/04/24 14:14:23, arv wrote:
> Don't mix ' and " in the same file. ' is preferred:
> 
>
https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showon...
> 
> If you modify an existing file use whatever is in there.

I've been trying to be consistent in using ", which seems to be preferred by the
other strong mode tests. ' has been used to mark out string literals when the
"outer string" is passed into an eval-like function.

https://codereview.chromium.org/1092353002/diff/340001/test/mjsunit/strong/im...
test/mjsunit/strong/implicit-conversions.js:11: "-",
On 2015/04/24 14:14:23, arv wrote:
> Array and Object literals should be indented 2 spaces and not 4.
> 
>
https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showon...

Will add to my followup https://codereview.chromium.org/1102923002/

https://codereview.chromium.org/1092353002/diff/340001/test/mjsunit/strong/im...
test/mjsunit/strong/implicit-conversions.js:15: ]
On 2015/04/24 14:14:23, arv wrote:
> semicolon

followup

https://codereview.chromium.org/1092353002/diff/340001/test/mjsunit/strong/im...
test/mjsunit/strong/implicit-conversions.js:17: let nonnumber_values = [
On 2015/04/24 14:14:23, arv wrote:
> nonNumberValues
> 
>
https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showon...

followup

https://codereview.chromium.org/1092353002/diff/340001/test/mjsunit/strong/im...
test/mjsunit/strong/implicit-conversions.js:51: return v;
On 2015/04/24 14:14:23, arv wrote:
> why not just `return x - y`?
> 
> Is this to prevent inlining?

there's no particular reason for it, will change in followup

https://codereview.chromium.org/1092353002/diff/340001/test/mjsunit/strong/im...
test/mjsunit/strong/implicit-conversions.js:109: assertThrows("'use strong'; let
v = " + expr + ";", TypeError);
On 2015/04/24 14:14:23, arv wrote:
> These things might be easier to read with template literals?

Probably. It doesn't sound like a bad idea for me to change the strong tests
built like this to use template literals sometime. There are a decent number.

https://codereview.chromium.org/1092353002/diff/340001/test/mjsunit/strong/im...
test/mjsunit/strong/implicit-conversions.js:146: } catch(e) {
On 2015/04/24 14:14:23, arv wrote:
> catch (e)
> 
> Just like if, for etc

followup

https://codereview.chromium.org/1092353002/diff/340001/test/mjsunit/strong/im...
test/mjsunit/strong/implicit-conversions.js:147: assertTrue(e instanceof
TypeError);
On 2015/04/24 14:14:23, arv wrote:
> or assertInstanceof

followup

https://codereview.chromium.org/1092353002/diff/340001/test/unittests/compile...
File test/unittests/compiler/js-operator-unittest.cc (right):

https://codereview.chromium.org/1092353002/diff/340001/test/unittests/compile...
test/unittests/compiler/js-operator-unittest.cc:74:
kSharedOperatorsWithlanguageMode[] = {
On 2015/04/24 14:14:23, arv wrote:
> strange indentation

I guess I was slightly religious in sticking to the format of the existing
macro. In fact now that I think about it it's intensely silly that I
define-undef-define-undef this macro, both uses are identical.

Powered by Google App Engine
This is Rietveld 408576698