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

Issue 619903002: Generalize bounds checks. (Closed)

Created:
6 years, 2 months ago by Vyacheslav Egorov (Google)
Modified:
6 years ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

If bounds check 0 <= index < length is not redundant we attempt to replace it with a sequence of checks that guarantee 0 <= LowerBound(index) < UpperBound(index) < length and hoist all of those checks out of the enclosing loop. Upper/Lower bounds are symbolic arithmetic expressions with +, -, * operations and are computed based on discovered simple induction variables. Simple induction variable is a variable that follows the pattern v1 <- phi(v0, v1 + 1) BUG= R=fschneider@google.com Committed: https://code.google.com/p/dart/source/detail?r=40969

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Patch Set 4 : #

Total comments: 36

Patch Set 5 : #

Patch Set 6 : #

Total comments: 13
Unified diffs Side-by-side diffs Delta from patch set Stats (+1342 lines, -374 lines) Patch
M runtime/vm/code_generator.cc View 1 2 3 4 1 chunk +3 lines, -2 lines 0 comments Download
M runtime/vm/compiler.cc View 1 chunk +6 lines, -5 lines 0 comments Download
M runtime/vm/deopt_instructions.h View 4 chunks +15 lines, -2 lines 0 comments Download
M runtime/vm/deopt_instructions.cc View 4 chunks +16 lines, -13 lines 0 comments Download
M runtime/vm/flow_graph.h View 2 chunks +47 lines, -0 lines 0 comments Download
M runtime/vm/flow_graph.cc View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/flow_graph_compiler.h View 5 chunks +9 lines, -2 lines 0 comments Download
M runtime/vm/flow_graph_compiler.cc View 4 chunks +9 lines, -4 lines 0 comments Download
M runtime/vm/flow_graph_inliner.cc View 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/flow_graph_optimizer.cc View 1 2 3 4 5 5 chunks +3 lines, -50 lines 0 comments Download
M runtime/vm/flow_graph_range_analysis.h View 1 5 chunks +16 lines, -2 lines 0 comments Download
M runtime/vm/flow_graph_range_analysis.cc View 1 2 3 4 5 19 chunks +915 lines, -63 lines 10 comments Download
M runtime/vm/intermediate_language.h View 1 2 3 4 5 16 chunks +50 lines, -17 lines 0 comments Download
M runtime/vm/intermediate_language.cc View 1 2 3 4 5 2 chunks +37 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language_arm.cc View 1 2 3 4 4 chunks +14 lines, -8 lines 0 comments Download
M runtime/vm/intermediate_language_arm64.cc View 1 2 3 4 4 chunks +14 lines, -8 lines 0 comments Download
M runtime/vm/intermediate_language_ia32.cc View 1 2 3 4 4 chunks +14 lines, -8 lines 1 comment Download
M runtime/vm/intermediate_language_mips.cc View 1 2 3 4 4 chunks +13 lines, -8 lines 0 comments Download
M runtime/vm/intermediate_language_x64.cc View 1 2 3 4 4 chunks +15 lines, -9 lines 0 comments Download
M runtime/vm/object.h View 1 2 3 4 10 chunks +48 lines, -92 lines 0 comments Download
M runtime/vm/object.cc View 1 2 3 4 9 chunks +17 lines, -77 lines 0 comments Download
M runtime/vm/object_test.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M runtime/vm/stack_frame.cc View 1 chunk +2 lines, -1 line 0 comments Download
A tests/standalone/array_bounds_check_generalization_test.dart View 1 2 3 4 5 1 chunk +75 lines, -0 lines 2 comments Download

Messages

Total messages: 9 (2 generated)
Vyacheslav Egorov (Google)
PTAL
6 years, 2 months ago (2014-10-01 17:16:13 UTC) #2
Florian Schneider
https://codereview.chromium.org/619903002/diff/60001/runtime/vm/flow_graph_range_analysis.cc File runtime/vm/flow_graph_range_analysis.cc (right): https://codereview.chromium.org/619903002/diff/60001/runtime/vm/flow_graph_range_analysis.cc#newcode64 runtime/vm/flow_graph_range_analysis.cc:64: // v4 is constrained to [v0, v2 + (v0 ...
6 years, 2 months ago (2014-10-06 16:04:53 UTC) #3
Vyacheslav Egorov (Google)
PTAL https://codereview.chromium.org/619903002/diff/60001/runtime/vm/flow_graph_range_analysis.cc File runtime/vm/flow_graph_range_analysis.cc (right): https://codereview.chromium.org/619903002/diff/60001/runtime/vm/flow_graph_range_analysis.cc#newcode64 runtime/vm/flow_graph_range_analysis.cc:64: // v4 is constrained to [v0, v2 + ...
6 years, 2 months ago (2014-10-06 20:30:09 UTC) #4
Florian Schneider
LGTM. https://codereview.chromium.org/619903002/diff/100001/runtime/vm/flow_graph_range_analysis.cc File runtime/vm/flow_graph_range_analysis.cc (right): https://codereview.chromium.org/619903002/diff/100001/runtime/vm/flow_graph_range_analysis.cc#newcode835 runtime/vm/flow_graph_range_analysis.cc:835: T* Emit(T* instruction, Instruction* post_dominator) { Maybe rename ...
6 years, 2 months ago (2014-10-07 11:40:49 UTC) #5
Vyacheslav Egorov (Google)
Committed patchset #6 (id:100001) manually as 40969 (presubmit successful).
6 years, 2 months ago (2014-10-07 18:50:49 UTC) #6
Vyacheslav Egorov (Google)
https://codereview.chromium.org/619903002/diff/100001/runtime/vm/flow_graph_range_analysis.cc File runtime/vm/flow_graph_range_analysis.cc (right): https://codereview.chromium.org/619903002/diff/100001/runtime/vm/flow_graph_range_analysis.cc#newcode835 runtime/vm/flow_graph_range_analysis.cc:835: T* Emit(T* instruction, Instruction* post_dominator) { On 2014/10/07 11:40:48, ...
6 years, 2 months ago (2014-10-07 18:57:27 UTC) #7
regis
6 years ago (2014-12-17 22:00:39 UTC) #9
Message was sent while issue was closed.
https://codereview.chromium.org/619903002/diff/100001/runtime/vm/intermediate...
File runtime/vm/intermediate_language_ia32.cc (right):

https://codereview.chromium.org/619903002/diff/100001/runtime/vm/intermediate...
runtime/vm/intermediate_language_ia32.cc:5613: }
Slava,

I stumbled upon this code and do not quite understand how it can be correct. If
both index and length are Smi::kMaxValue (highly improbable, but still), then we
will emit a test instruction instead of the compare. We will not deopt, because
index is not negative, but we should.

What am I missing?

Thanks,
Regis

Powered by Google App Engine
This is Rietveld 408576698