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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 138523004: Inline recognized List factory in the flow graph optimizer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 32158)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -2917,8 +2917,14 @@
CreateArrayInstr* create_array = value()->definition()->AsCreateArray();
ASSERT(create_array != NULL);
// Check if the string interpolation has only constant inputs.
- GrowableArray<ConstantInstr*> constants(create_array->num_elements());
- for (intptr_t i = 0; i < create_array->num_elements(); i++) {
+ Value* num_elements = create_array->num_elements();
+ if (!num_elements->BindsToConstant() ||
+ !num_elements->BoundConstant().IsSmi()) {
+ return this;
+ }
+ intptr_t length = Smi::Cast(num_elements->BoundConstant()).Value();
+ GrowableArray<ConstantInstr*> constants(length);
+ for (intptr_t i = 0; i < length; i++) {
constants.Add(NULL);
}
for (Value::Iterator it(create_array->input_use_list());
@@ -2944,7 +2950,7 @@
}
// Interpolate string at compile time.
const Array& array_argument =
- Array::Handle(Array::New(create_array->num_elements()));
+ Array::Handle(Array::New(length));
for (intptr_t i = 0; i < constants.length(); i++) {
array_argument.SetAt(i, constants[i]->value());
}
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698