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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 10905233: Whenever possible use length passed to the List constructor for bounds checks instead of loading it… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Srdjan's comments Created 8 years, 3 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.cc
diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc
index 069528f16caff523eacd1fd4959aad9043416f87..10292764b10394e5f6bf687ca695fda55bd1953c 100644
--- a/runtime/vm/intermediate_language.cc
+++ b/runtime/vm/intermediate_language.cc
@@ -1125,6 +1125,11 @@ RawAbstractType* CheckArrayBoundInstr::CompileType() const {
}
+RawAbstractType* CheckBoundInstr::CompileType() const {
+ return AbstractType::null();
+}
+
+
RawAbstractType* CheckEitherNonSmiInstr::CompileType() const {
return AbstractType::null();
}
@@ -1181,6 +1186,28 @@ Definition* CheckEitherNonSmiInstr::Canonicalize() {
}
+Definition* CheckArrayBoundInstr::Canonicalize() {
+ if (array_type() == kArrayCid) {
+ // For fixed length arrays check if array is the result of a constructor
+ // call. In this case we can use the length passed to the constructor
+ // instead of loading it from array itself.
+ StaticCallInstr* allocation = array()->definition()->AsStaticCall();
+ if ((allocation != NULL) &&
+ allocation->is_known_constructor() &&
+ (allocation->ResultCid() == kArrayCid)) {
+ CheckBoundInstr* check =
+ new CheckBoundInstr(allocation->ArgumentAt(0)->value()->Copy(),
+ index(),
+ deopt_id_);
+ check->set_env(env());
+ set_env(NULL);
+ return check;
+ }
+ }
+ return this;
+}
+
+
// Shared code generation methods (EmitNativeCode, MakeLocationSummary, and
// PrepareEntry). Only assembly code that can be shared across all architectures
// can be used. Machine specific register allocation and code generation
« 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