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

Unified Diff: runtime/vm/intermediate_language_ia32.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
Index: runtime/vm/intermediate_language_ia32.cc
diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc
index a57cc42eb1d75fab24d5145edad3d6b3996f84fa..a9ef4bc3ee26099ca27b1cfac3bbade5b8a6984c 100644
--- a/runtime/vm/intermediate_language_ia32.cc
+++ b/runtime/vm/intermediate_language_ia32.cc
@@ -4385,6 +4385,24 @@ void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
return;
}
+ intptr_t guarded_array_length = -1;
+ 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.
+ __ jmp(deopt);
+ }
+ // Nothing to emit.
+ return;
+ }
+
if (index_loc.IsConstant()) {
Register length = length_loc.reg();
const Object& index = Smi::Cast(index_loc.constant());

Powered by Google App Engine
This is Rietveld 408576698