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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 196353012: VM: Fix infinite recursion in optimization of of string interpolation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | « no previous file | no next file » | 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 33643)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -3043,6 +3043,12 @@
// StoreIndexed(v2, v3, v4) -- v3:constant index, v4: value.
// ..
// v8 <- StringInterpolate(v2)
+
+ // Don't compile-time fold when optimizing the interpolation function itself.
+ if (flow_graph->parsed_function().function().raw() == CallFunction().raw()) {
+ return this;
+ }
+
CreateArrayInstr* create_array = value()->definition()->AsCreateArray();
ASSERT(create_array != NULL);
// Check if the string interpolation has only constant inputs.
@@ -3087,13 +3093,14 @@
const Array& interpolate_arg = Array::Handle(Array::New(1));
interpolate_arg.SetAt(0, array_argument);
// Call interpolation function.
- String& concatenated = String::ZoneHandle();
- concatenated ^=
- DartEntry::InvokeFunction(CallFunction(), interpolate_arg);
- if (concatenated.IsUnhandledException()) {
+ const Object& result = Object::Handle(
+ DartEntry::InvokeFunction(CallFunction(), interpolate_arg));
+ if (result.IsUnhandledException()) {
return this;
}
- concatenated = Symbols::New(concatenated);
+ ASSERT(result.IsString());
+ const String& concatenated =
+ String::ZoneHandle(Symbols::New(String::Cast(result)));
return flow_graph->GetConstant(concatenated);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698