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

Unified Diff: runtime/vm/flow_graph_optimizer.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/flow_graph_inliner.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 32158)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -3680,6 +3680,31 @@
ConstantInstr* cid_instr = new ConstantInstr(Smi::Handle(Smi::New(cid)));
ReplaceCall(call, cid_instr);
}
+
+ if (call->function().IsFactory()) {
+ const Class& function_class = Class::Handle(call->function().Owner());
+ if ((function_class.library() == Library::CoreLibrary()) ||
+ (function_class.library() == Library::TypedDataLibrary())) {
+ intptr_t cid = FactoryRecognizer::ResultCid(call->function());
+ switch (cid) {
+ case kArrayCid: {
+ Value* type = new Value(call->ArgumentAt(0));
+ Value* num_elements = new Value(call->ArgumentAt(1));
+ if (num_elements->BindsToConstant() &&
+ num_elements->BoundConstant().IsSmi()) {
+ intptr_t length = Smi::Cast(num_elements->BoundConstant()).Value();
+ if (length >= 0 && length <= Array::kMaxElements) {
+ CreateArrayInstr* create_array =
+ new CreateArrayInstr(call->token_pos(), type, num_elements);
+ ReplaceCall(call, create_array);
+ }
+ }
+ }
+ default:
+ break;
+ }
+ }
+ }
}
@@ -7119,11 +7144,15 @@
void ConstantPropagator::VisitLoadField(LoadFieldInstr* instr) {
if ((instr->recognized_kind() == MethodRecognizer::kObjectArrayLength) &&
(instr->instance()->definition()->IsCreateArray())) {
- const intptr_t length =
+ Value* num_elements =
instr->instance()->definition()->AsCreateArray()->num_elements();
- const Object& result = Smi::ZoneHandle(Smi::New(length));
- SetValue(instr, result);
- return;
+ if (num_elements->BindsToConstant() &&
+ num_elements->BoundConstant().IsSmi()) {
+ intptr_t length = Smi::Cast(num_elements->BoundConstant()).Value();
+ const Object& result = Smi::ZoneHandle(Smi::New(length));
+ SetValue(instr, result);
+ return;
+ }
}
if (instr->IsImmutableLengthLoad()) {
« no previous file with comments | « runtime/vm/flow_graph_inliner.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698