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

Issue 10032029: Eliminate redundant array bound checks (checks already performed earlier in the DT). (Closed)

Created:
8 years, 8 months ago by Massi
Modified:
8 years, 8 months ago
Reviewers:
Sven Panne, fschneider
CC:
v8-dev
Visibility:
Public.

Description

Eliminate redundant array bound checks (checks already performed earlier in the DT). As a special case, for checks on index expressions with the form (expr + constant) if a smaller constant is checked later in the DT also eliminate the check. Finally, if a larger constant is checked later in the same BB do the more general check (larger constant) earlier instead of the less general one. This will not cause useless deoptimizations because, since we are in the same BB, all the checks would have been executed anyway. BUG= TEST= Committed: https://code.google.com/p/v8/source/detail?r=11437

Patch Set 1 #

Total comments: 14

Patch Set 2 : 'Addressed comments and fixed bugs.' #

Total comments: 29

Patch Set 3 : Fixed remaining implementation issues. #

Patch Set 4 : Small code style fix. #

Total comments: 12

Patch Set 5 : Fixed style issues and shortened the phase name to help Golem understand it. #

Total comments: 11

Patch Set 6 : Changed implementation to handle negative values properly, and added tests. #

Patch Set 7 : Fixed issue with lower bound changing in unusual ways. #

Total comments: 20

Patch Set 8 : Style fixes. #

Patch Set 9 : More small style fixes. #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+468 lines, -16 lines) Patch
M src/flag-definitions.h View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M src/hydrogen.h View 1 3 chunks +3 lines, -1 line 0 comments Download
M src/hydrogen.cc View 1 2 3 4 5 6 7 8 1 chunk +314 lines, -15 lines 2 comments Download
M src/hydrogen-instructions.cc View 1 2 3 4 5 6 2 chunks +2 lines, -0 lines 0 comments Download
M src/v8-counters.h View 1 1 chunk +2 lines, -0 lines 0 comments Download
A test/mjsunit/array-bounds-check-removal.js View 1 2 3 4 5 1 chunk +145 lines, -0 lines 1 comment Download

Messages

Total messages: 18 (0 generated)
Massi
8 years, 8 months ago (2012-04-10 15:46:07 UTC) #1
Sven Panne
First round of comments... http://codereview.chromium.org/10032029/diff/1/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/10032029/diff/1/src/hydrogen.cc#newcode2593 src/hydrogen.cc:2593: static BoundsCheckKey* CreateBoundsCheckKey(Zone* zone, To ...
8 years, 8 months ago (2012-04-12 09:45:42 UTC) #2
Massi
I fixed the issues described in the comments. I also did the following: - Do ...
8 years, 8 months ago (2012-04-13 10:55:16 UTC) #3
Sven Panne
Next round of comments... http://codereview.chromium.org/10032029/diff/4001/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/10032029/diff/4001/src/hydrogen.cc#newcode2592 src/hydrogen.cc:2592: if (check->index()->IsAdd()) { If we ...
8 years, 8 months ago (2012-04-13 11:38:06 UTC) #4
fschneider
http://codereview.chromium.org/10032029/diff/4001/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/10032029/diff/4001/src/hydrogen.cc#newcode2639 src/hydrogen.cc:2639: BoundsCheckKey* Key() {return key_;} style-nit: add spaces after/before {}. ...
8 years, 8 months ago (2012-04-13 12:38:00 UTC) #5
Sven Panne
http://codereview.chromium.org/10032029/diff/4001/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/10032029/diff/4001/src/hydrogen.cc#newcode2671 src/hydrogen.cc:2671: added_index_->InsertBefore(added_simulate); On 2012/04/13 12:38:00, fschneider wrote: > I think ...
8 years, 8 months ago (2012-04-13 12:49:33 UTC) #6
fschneider
On 2012/04/13 12:49:33, Sven Panne wrote: > http://codereview.chromium.org/10032029/diff/4001/src/hydrogen.cc > File src/hydrogen.cc (right): > > http://codereview.chromium.org/10032029/diff/4001/src/hydrogen.cc#newcode2671 ...
8 years, 8 months ago (2012-04-13 13:16:59 UTC) #7
Massi
On 2012/04/13 13:16:59, fschneider wrote: > Actually even simpler: I'd expect that you can ASSERT ...
8 years, 8 months ago (2012-04-17 10:54:16 UTC) #8
Massi
Everything should have been addressed at this point... https://chromiumcodereview.appspot.com/10032029/diff/4001/src/hydrogen.cc File src/hydrogen.cc (right): https://chromiumcodereview.appspot.com/10032029/diff/4001/src/hydrogen.cc#newcode2592 src/hydrogen.cc:2592: if ...
8 years, 8 months ago (2012-04-17 10:56:58 UTC) #9
fschneider
http://codereview.chromium.org/10032029/diff/14001/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/10032029/diff/14001/src/hydrogen.cc#newcode2639 src/hydrogen.cc:2639: int32_t Offset() {return offset_;} Spaces around { and }. ...
8 years, 8 months ago (2012-04-18 07:51:35 UTC) #10
Massi
Fixed style issues and shortened the phase name to help Golem understand it. At this ...
8 years, 8 months ago (2012-04-18 09:19:27 UTC) #11
fschneider
LGTM if you add a unit test. Please add a mjsunit test that covers all ...
8 years, 8 months ago (2012-04-18 09:42:18 UTC) #12
Massi
the last patch set should address everything... https://chromiumcodereview.appspot.com/10032029/diff/16001/src/hydrogen.cc File src/hydrogen.cc (right): https://chromiumcodereview.appspot.com/10032029/diff/16001/src/hydrogen.cc#newcode2621 src/hydrogen.cc:2621: On 2012/04/18 ...
8 years, 8 months ago (2012-04-23 15:19:19 UTC) #13
Massi
Patch 7 fixes all known issues, and passes a "golem sanity check". It does not ...
8 years, 8 months ago (2012-04-25 07:27:11 UTC) #14
fschneider
Almost there. Mostly style comments left: http://codereview.chromium.org/10032029/diff/28001/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/10032029/diff/28001/src/hydrogen.cc#newcode2617 src/hydrogen.cc:2617: *offset = is_sub ...
8 years, 8 months ago (2012-04-25 09:40:48 UTC) #15
Massi
Patch 8 addresses the last round of comments. http://codereview.chromium.org/10032029/diff/28001/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/10032029/diff/28001/src/hydrogen.cc#newcode2617 src/hydrogen.cc:2617: *offset ...
8 years, 8 months ago (2012-04-25 12:19:18 UTC) #16
Massi
Fixed colon position in initializers. http://codereview.chromium.org/10032029/diff/28001/src/hydrogen.cc File src/hydrogen.cc (right): http://codereview.chromium.org/10032029/diff/28001/src/hydrogen.cc#newcode2628 src/hydrogen.cc:2628: BoundsCheckKey(HValue* index_base, HValue* length) ...
8 years, 8 months ago (2012-04-25 12:29:15 UTC) #17
fschneider
8 years, 8 months ago (2012-04-26 09:35:49 UTC) #18
Looks almost good! Can you also fix the redundant index-additions that may
arrive in the example we discussed offline? I think it will improve the benefits
of your optimization noticable.

http://codereview.chromium.org/10032029/diff/28001/src/hydrogen.cc
File src/hydrogen.cc (right):

http://codereview.chromium.org/10032029/diff/28001/src/hydrogen.cc#newcode2884
src/hydrogen.cc:2884: AssertNoAllocation no_gc;
On 2012/04/25 12:19:19, Massi wrote:
> On 2012/04/25 09:40:48, fschneider wrote:
> > Why would you want to assert no allocation here? It does not hurt, but does
> not
> > seem necessary.
> 
> It is necessary: I was hitting asserts without it.
> This happened computing key hashes calling HConstant::Hashcode().

I don't believe it is necessary. If anything it will trigger an assert once you
allocate a heap object on the JS heap in your code.
I don't this is currently the case, and even if it would, we can deal with
allocations inside the compiler since everything is handlified.

http://codereview.chromium.org/10032029/diff/33002/src/hydrogen.cc
File src/hydrogen.cc (right):

http://codereview.chromium.org/10032029/diff/33002/src/hydrogen.cc#newcode2687
src/hydrogen.cc:2687: int32_t new_offset) {
Fits in previous line?

http://codereview.chromium.org/10032029/diff/33002/src/hydrogen.cc#newcode2775
src/hydrogen.cc:2775: (*add)->DeleteAndReplaceWith((*add)->left());
Could you add a test case that exercises this code inside the if-statement? When
running your added it, I don't find this path to be executed.

http://codereview.chromium.org/10032029/diff/33002/test/mjsunit/array-bounds-...
File test/mjsunit/array-bounds-check-removal.js (right):

http://codereview.chromium.org/10032029/diff/33002/test/mjsunit/array-bounds-...
test/mjsunit/array-bounds-check-removal.js:144: gc();
Why do you need --expose-gc and a call gc() here?

Powered by Google App Engine
This is Rietveld 408576698