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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 12377082: Recognize more list factories. Recognizing list factories (Array, Bytearrays, etc) allows the type … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 19395)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -1141,6 +1141,28 @@
}
+bool LoadFieldInstr::IsFixedLengthArrayCid(intptr_t cid) {
+ switch (cid) {
+ case kArrayCid:
+ case kImmutableArrayCid:
+ case kInt8ArrayCid:
+ case kUint8ArrayCid:
+ case kUint8ClampedArrayCid:
+ case kInt16ArrayCid:
+ case kUint16ArrayCid:
+ case kInt32ArrayCid:
+ case kUint32ArrayCid:
+ case kInt64ArrayCid:
+ case kUint64ArrayCid:
+ case kFloat32ArrayCid:
+ case kFloat64ArrayCid:
+ return true;
+ default:
+ return false;
+ }
+}
+
+
Definition* LoadFieldInstr::Canonicalize(FlowGraphOptimizer* optimizer) {
if (!IsImmutableLengthLoad()) return this;
@@ -1148,9 +1170,9 @@
// call we can replace the length load with the length argument passed to
// the constructor.
StaticCallInstr* call = value()->definition()->AsStaticCall();
- if (call != NULL &&
- call->is_known_constructor() &&
- (call->Type()->ToCid() == kArrayCid)) {
+ if ((call != NULL) &&
+ call->is_known_list_constructor() &&
+ IsFixedLengthArrayCid(call->Type()->ToCid())) {
return call->ArgumentAt(1);
}
return this;
@@ -2095,24 +2117,7 @@
bool CheckArrayBoundInstr::IsFixedLengthArrayType(intptr_t cid) {
- switch (cid) {
- case kArrayCid:
- case kImmutableArrayCid:
- case kInt8ArrayCid:
- case kUint8ArrayCid:
- case kUint8ClampedArrayCid:
- case kInt16ArrayCid:
- case kUint16ArrayCid:
- case kInt32ArrayCid:
- case kUint32ArrayCid:
- case kInt64ArrayCid:
- case kUint64ArrayCid:
- case kFloat32ArrayCid:
- case kFloat64ArrayCid:
- return true;
- default:
- return false;
- }
+ return LoadFieldInstr::IsFixedLengthArrayCid(cid);
}

Powered by Google App Engine
This is Rietveld 408576698