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

Issue 8373029: [hydrogen] optimize switch with string clauses (Closed)

Created:
9 years, 2 months ago by indutny
Modified:
9 years, 1 month ago
CC:
v8-dev
Base URL:
gh:v8/v8@master
Visibility:
Public.

Description

[hydrogen] optimize switch with string clauses Hydrogen should optimize not only SMI clauses, but clauses with string literals too. Patch from fedor.indutny <fedor.indutny@gmail.com>;. R=vegorov@chromium.org BUG= TEST= Committed: http://code.google.com/p/v8/source/detail?r=9901 Committed: http://code.google.com/p/v8/source/detail?r=10019

Patch Set 1 #

Total comments: 1

Patch Set 2 : split string and smi cases #

Total comments: 8

Patch Set 3 : separate type extraction and code generation #

Total comments: 3

Patch Set 4 : Added HCheckNonSmi #

Total comments: 1

Patch Set 5 : do not segfault #

Patch Set 6 : clause()->IsSymbolCompare() initial #

Patch Set 7 : oracle changes #

Patch Set 8 : IsStringAndBranch for ia32 #

Patch Set 9 : IsString branch before matching literals #

Patch Set 10 : still need to check tag's type #

Patch Set 11 : do not deoptimize on non-symbol cmp #

Patch Set 12 : some fixes #

Patch Set 13 : just update #

Patch Set 14 : haha, it works #

Patch Set 15 : fix graph #

Patch Set 16 : dumb stupid patch #

Patch Set 17 : fixed graph, improved test #

Patch Set 18 : link bodies of parallel branch to normal #

Patch Set 19 : join tails #

Patch Set 20 : fix one assertion error #

Patch Set 21 : fix all assertions #

Patch Set 22 : finally, it works... added regression test #

Patch Set 23 : x64 instructions #

Patch Set 24 : mips and arm #

Patch Set 25 : mips+arm #

Patch Set 26 : fix x64 build, optimized jumps #

Patch Set 27 : fixed arm #

Patch Set 28 : CompareGenericAndBranch #

Patch Set 29 : x64 do compare generic and branch #

Patch Set 30 : arm: CompareGenericAndBranch #

Patch Set 31 : mips: CompareGenericAndBranch #

Total comments: 7

Patch Set 32 : last_block != NULL for string cases #

Total comments: 1

Patch Set 33 : use type feedback to bailout switches with known beforehand string(non-symbol) comparison #

Total comments: 10

Patch Set 34 : StringCompareAndBranch #

Patch Set 35 : use StringCompareStub #

Patch Set 36 : reverted StringCompareStub #

Patch Set 37 : remove fishy assigns #

Total comments: 4

Patch Set 38 : revert unintended change #

Patch Set 39 : remove second pass #

Total comments: 3

Patch Set 40 : x64: fix regression on mozilla:366601 #

Patch Set 41 : merged with master #

Total comments: 1

Patch Set 42 : rebase correctly #

Patch Set 43 : remove unused var #

Total comments: 2

Patch Set 44 : test coverage for switch (mjsunit) #

Total comments: 2

Patch Set 45 : fix lint errors, improved test #

Unified diffs Side-by-side diffs Delta from patch set Stats (+864 lines, -82 lines) Patch
M src/arm/lithium-arm.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 3 chunks +33 lines, -0 lines 0 comments Download
M src/arm/lithium-arm.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 4 chunks +34 lines, -0 lines 0 comments Download
M src/arm/lithium-codegen-arm.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 1 chunk +7 lines, -0 lines 0 comments Download
M src/arm/lithium-codegen-arm.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 3 chunks +60 lines, -20 lines 0 comments Download
M src/ast.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 2 chunks +9 lines, -1 line 0 comments Download
M src/ast.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 1 chunk +4 lines, -0 lines 0 comments Download
M src/hydrogen.h View 1 2 3 4 5 6 7 8 9 10 11 12 40 41 1 chunk +1 line, -0 lines 0 comments Download
M src/hydrogen.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 3 chunks +78 lines, -20 lines 0 comments Download
M src/hydrogen-instructions.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 3 chunks +50 lines, -0 lines 0 comments Download
M src/hydrogen-instructions.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 40 41 1 chunk +7 lines, -0 lines 0 comments Download
M src/ia32/lithium-codegen-ia32.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 1 chunk +7 lines, -0 lines 0 comments Download
M src/ia32/lithium-codegen-ia32.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 3 chunks +60 lines, -20 lines 0 comments Download
M src/ia32/lithium-ia32.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 3 chunks +33 lines, -0 lines 0 comments Download
M src/ia32/lithium-ia32.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 4 chunks +37 lines, -0 lines 0 comments Download
M src/mips/lithium-codegen-mips.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 1 chunk +7 lines, -0 lines 0 comments Download
M src/mips/lithium-codegen-mips.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 3 chunks +64 lines, -20 lines 0 comments Download
M src/mips/lithium-mips.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 3 chunks +33 lines, -0 lines 0 comments Download
M src/mips/lithium-mips.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 5 chunks +35 lines, -1 line 0 comments Download
src/type-info.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 40 41 4 chunks +14 lines, -0 lines 0 comments Download
M src/type-info.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 40 41 1 chunk +4 lines, -0 lines 0 comments Download
M src/x64/lithium-codegen-x64.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 1 chunk +7 lines, -0 lines 0 comments Download
M src/x64/lithium-codegen-x64.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 2 chunks +39 lines, -0 lines 0 comments Download
M src/x64/lithium-x64.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 3 chunks +33 lines, -0 lines 0 comments Download
M src/x64/lithium-x64.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 4 chunks +35 lines, -0 lines 0 comments Download
M test/mjsunit/switch.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 3 chunks +173 lines, -0 lines 0 comments Download

Messages

Total messages: 38 (0 generated)
indutny
9 years, 2 months ago (2011-10-24 05:58:06 UTC) #1
indutny
Base URL is incorrect, please update it if it's possible: https://github.com/indutny/v8/tree/feature-switch-string-literal-opt
9 years, 2 months ago (2011-10-24 05:59:36 UTC) #2
Vyacheslav Egorov (Chromium)
I think it makes sense to distinguish between fully smi and fully string literal cases ...
9 years, 2 months ago (2011-10-24 09:37:19 UTC) #3
indutny
Updated.
9 years, 2 months ago (2011-10-24 10:14:47 UTC) #4
Vyacheslav Egorov (Chromium)
http://codereview.chromium.org/8373029/diff/2002/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/8373029/diff/2002/src/hydrogen.cc#newcode2693 src/hydrogen.cc:2693: enum { We don't use anonymous enums http://codereview.chromium.org/8373029/diff/2002/src/hydrogen.cc#newcode2694 src/hydrogen.cc:2694: ...
9 years, 2 months ago (2011-10-24 10:56:26 UTC) #5
indutny
Updated
9 years, 2 months ago (2011-10-24 11:57:36 UTC) #6
Vyacheslav Egorov (Chromium)
lgtm with comments addressed. please address the comments and I will land. http://codereview.chromium.org/8373029/diff/8001/src/hydrogen.cc File src/hydrogen.cc ...
9 years, 2 months ago (2011-10-24 12:12:00 UTC) #7
indutny
Updated
9 years, 2 months ago (2011-10-24 12:18:37 UTC) #8
Vyacheslav Egorov (Chromium)
additional comment. I'll fix it myself and also add tests before landing. http://codereview.chromium.org/8373029/diff/11001/src/hydrogen.cc File src/hydrogen.cc ...
9 years, 2 months ago (2011-10-24 12:27:29 UTC) #9
indutny
Can you please benchmark this branch. It's faster on jslint for me.
9 years, 1 month ago (2011-10-26 20:29:21 UTC) #10
Vyacheslav Egorov (Chromium)
Adding Florian as a reviewer to have more eyes on graph construction.
9 years, 1 month ago (2011-10-28 12:39:05 UTC) #11
indutny
Finally, this thing works w/o segfaults and assertions. On my machine jslint is about 5% ...
9 years, 1 month ago (2011-10-28 22:24:02 UTC) #12
fschneider
Here are my comments: I'd like to see the code simpler if possible. Also lazy-deoptimization ...
9 years, 1 month ago (2011-11-01 09:26:19 UTC) #13
indutny
http://codereview.chromium.org/8373029/diff/32026/src/ast.h File src/ast.h (right): http://codereview.chromium.org/8373029/diff/32026/src/ast.h#newcode713 src/ast.h:713: bool IsSymbolCompare() { return compare_type_ == SYMBOL_ONLY; } On ...
9 years, 1 month ago (2011-11-01 09:31:07 UTC) #14
indutny
btw, it fails sometimes when trying to apply uglifyjs on itself, and I don't understand ...
9 years, 1 month ago (2011-11-01 09:53:14 UTC) #15
indutny
Any news?
9 years, 1 month ago (2011-11-02 12:40:41 UTC) #16
fschneider
The error in jsuglify seems unrelated to your change. I could also reproduce it in ...
9 years, 1 month ago (2011-11-02 15:01:17 UTC) #17
indutny
As I can see, problem comes from different place. `advance` was bailout'ed because of switch ...
9 years, 1 month ago (2011-11-02 16:28:46 UTC) #18
indutny
So I guess that performance regression was caused by some v8 team's commits and we ...
9 years, 1 month ago (2011-11-02 16:30:45 UTC) #19
indutny
Renamed oddball_check. Added type feedback check for bailouting switches that are taking non-symbol strings as ...
9 years, 1 month ago (2011-11-02 18:35:09 UTC) #20
indutny
Any updates?
9 years, 1 month ago (2011-11-07 07:50:49 UTC) #21
fschneider
Sorry for the delay, but we're getting there. My main concern is still the complexity ...
9 years, 1 month ago (2011-11-07 08:27:18 UTC) #22
indutny
http://codereview.chromium.org/8373029/diff/43002/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/8373029/diff/43002/src/hydrogen.cc#newcode2762 src/hydrogen.cc:2762: iterations = iterations * 2; It yields a big ...
9 years, 1 month ago (2011-11-07 11:17:04 UTC) #23
indutny
http://codereview.chromium.org/8373029/diff/43002/src/ia32/lithium-codegen-ia32.cc File src/ia32/lithium-codegen-ia32.cc (right): http://codereview.chromium.org/8373029/diff/43002/src/ia32/lithium-codegen-ia32.cc#newcode1798 src/ia32/lithium-codegen-ia32.cc:1798: Handle<Code> ic = CompareIC::GetUninitialized(op); Just benchmarked it, and found ...
9 years, 1 month ago (2011-11-07 11:49:27 UTC) #24
indutny
http://codereview.chromium.org/8373029/diff/43002/src/ia32/lithium-ia32.cc File src/ia32/lithium-ia32.cc (right): http://codereview.chromium.org/8373029/diff/43002/src/ia32/lithium-ia32.cc#newcode1548 src/ia32/lithium-ia32.cc:1548: return AssignEnvironment(MarkAsCall(result, instr)); You're right. We don't need this ...
9 years, 1 month ago (2011-11-07 11:53:46 UTC) #25
indutny
Fixed all things you commented. ;)
9 years, 1 month ago (2011-11-07 11:54:10 UTC) #26
fschneider
See my inlined comments. http://codereview.chromium.org/8373029/diff/43002/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/8373029/diff/43002/src/hydrogen.cc#newcode2762 src/hydrogen.cc:2762: iterations = iterations * 2; ...
9 years, 1 month ago (2011-11-07 15:33:59 UTC) #27
indutny
http://codereview.chromium.org/8373029/diff/43002/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/8373029/diff/43002/src/hydrogen.cc#newcode2762 src/hydrogen.cc:2762: iterations = iterations * 2; I tried implementing graph ...
9 years, 1 month ago (2011-11-07 17:06:08 UTC) #28
fschneider
LGTM. I'll land it for you. Thanks for the patch!
9 years, 1 month ago (2011-11-08 08:57:59 UTC) #29
indutny
Thanks for reviewing it! Should I open a new request with rest of the features ...
9 years, 1 month ago (2011-11-08 08:58:43 UTC) #30
fschneider
http://codereview.chromium.org/8373029/diff/47027/src/x64/lithium-codegen-x64.cc File src/x64/lithium-codegen-x64.cc (right): http://codereview.chromium.org/8373029/diff/47027/src/x64/lithium-codegen-x64.cc#newcode1688 src/x64/lithium-codegen-x64.cc:1688: __ CmpObjectType(input, FIRST_NONSTRING_TYPE, rcx); Here you need to use ...
9 years, 1 month ago (2011-11-08 10:14:37 UTC) #31
indutny
Fixed, thanks
9 years, 1 month ago (2011-11-08 10:24:56 UTC) #32
fschneider
http://codereview.chromium.org/8373029/diff/58004/src/x64/lithium-codegen-x64.cc File src/x64/lithium-codegen-x64.cc (right): http://codereview.chromium.org/8373029/diff/58004/src/x64/lithium-codegen-x64.cc#newcode1686 src/x64/lithium-codegen-x64.cc:1686: Label* is_string) { Parameter is_string is not used. It ...
9 years, 1 month ago (2011-11-08 10:33:20 UTC) #33
indutny
fixed, thanks
9 years, 1 month ago (2011-11-08 10:46:26 UTC) #34
indutny
(empty message, just to remind you about this issue)
9 years, 1 month ago (2011-11-09 06:41:59 UTC) #35
indutny
Added comprehensive test for different type of clauses, tags, feedback and optimizations.
9 years, 1 month ago (2011-11-17 07:33:01 UTC) #36
fschneider
LGTM. I like the new unit test! Thanks for adding it. I have one improvement ...
9 years, 1 month ago (2011-11-17 10:05:32 UTC) #37
indutny
9 years, 1 month ago (2011-11-17 10:29:04 UTC) #38
Thanks, fixed

Powered by Google App Engine
This is Rietveld 408576698