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

Unified Diff: runtime/vm/intermediate_language_arm.cc

Issue 23003026: Avoid array bounds check when allowed by guarded field. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_arm.cc
diff --git a/runtime/vm/intermediate_language_arm.cc b/runtime/vm/intermediate_language_arm.cc
index 830ade19e433bb231929621a9a5a9457ee6922b6..ddfc563e5f18b90da5ba53ff6da3103b525d1733 100644
--- a/runtime/vm/intermediate_language_arm.cc
+++ b/runtime/vm/intermediate_language_arm.cc
@@ -4325,6 +4325,24 @@ void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
return;
}
+ intptr_t guarded_array_length = -1;
srdjan 2013/08/22 22:02:43 Instead of checking here, move the code to CheckAr
+ if (array_ != NULL) {
+ if (array_->guarded_list_length() >= 0) {
+ guarded_array_length = array_->guarded_list_length();
+ }
+ }
+
+ if (index_loc.IsConstant() && guarded_array_length >= 0) {
+ const Object& index = Smi::Cast(index_loc.constant());
+ int32_t i = reinterpret_cast<int32_t>(index.raw());
+ if (i >= guarded_array_length) {
+ // We know this bounds check will trigger a deoptimization.
+ __ b(deopt);
+ }
+ // Nothing to emit.
+ return;
+ }
+
if (index_loc.IsConstant()) {
Register length = length_loc.reg();
const Smi& index = Smi::Cast(index_loc.constant());
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698