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

Unified Diff: runtime/vm/flow_graph.cc

Issue 11028140: Inlining of calls with optional parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review comments. Created 8 years, 2 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.h ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph.cc
diff --git a/runtime/vm/flow_graph.cc b/runtime/vm/flow_graph.cc
index ea28c56909a810c9908b1defef1059de12d93f9f..70596f9ef57d00cf27ec76896114e48d7b6cf0a5 100644
--- a/runtime/vm/flow_graph.cc
+++ b/runtime/vm/flow_graph.cc
@@ -36,6 +36,24 @@ FlowGraph::FlowGraph(const FlowGraphBuilder& builder,
}
+ConstantInstr* FlowGraph::AddConstantToInitialDefinitions(
+ const Object& object) {
+ // Check if the constant is already in the pool.
+ for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) {
+ ConstantInstr* constant =
+ (*graph_entry_->initial_definitions())[i]->AsConstant();
+ if ((constant != NULL) && (constant->value().raw() == object.raw())) {
+ return constant;
+ }
+ }
+ // Otherwise, allocate and add it to the pool.
+ ConstantInstr* constant = new ConstantInstr(object);
+ constant->set_ssa_temp_index(alloc_ssa_temp_index());
+ graph_entry_->initial_definitions()->Add(constant);
+ return constant;
+}
+
+
void FlowGraph::DiscoverBlocks() {
// Initialize state.
preorder_.Clear();
@@ -282,7 +300,9 @@ void FlowGraph::ComputeUseLists() {
}
-void FlowGraph::ComputeSSA(intptr_t next_virtual_register_number) {
+void FlowGraph::ComputeSSA(intptr_t next_virtual_register_number,
+ GrowableArray<Definition*>* inlining_parameters) {
+ ASSERT((next_virtual_register_number == 0) || (inlining_parameters != NULL));
current_ssa_temp_index_ = next_virtual_register_number;
GrowableArray<BitVector*> dominance_frontier;
ComputeDominators(&dominance_frontier);
@@ -290,7 +310,7 @@ void FlowGraph::ComputeSSA(intptr_t next_virtual_register_number) {
GrowableArray<PhiInstr*> live_phis;
// Rename uses to reference inserted phis where appropriate.
// Collect phis that reach a non-environment use.
- Rename(&live_phis);
+ Rename(&live_phis, inlining_parameters);
// Propagate alive mark transitively from alive phis.
MarkLivePhis(&live_phis);
}
@@ -471,7 +491,8 @@ void FlowGraph::InsertPhis(
}
-void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis) {
+void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis,
+ GrowableArray<Definition*>* inlining_parameters) {
// TODO(fschneider): Support catch-entry.
if (graph_entry_->SuccessorCount() > 1) {
Bailout("Catch-entry support in SSA.");
@@ -485,13 +506,24 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis) {
constant_null->set_ssa_temp_index(alloc_ssa_temp_index());
graph_entry_->initial_definitions()->Add(constant_null);
- // Add incoming parameters to the initial definitions and the renaming
- // environment.
- for (intptr_t i = 0; i < parameter_count(); ++i) {
- ParameterInstr* param = new ParameterInstr(i, graph_entry_);
- param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
- graph_entry_->initial_definitions()->Add(param);
- env.Add(param);
+ // Add parameters to the initial definitions and renaming environment.
+ if (inlining_parameters != NULL) {
+ // Use known parameters.
+ ASSERT(parameter_count() == inlining_parameters->length());
+ for (intptr_t i = 0; i < parameter_count(); ++i) {
+ Definition* defn = (*inlining_parameters)[i];
+ defn->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
+ graph_entry_->initial_definitions()->Add(defn);
+ env.Add(defn);
+ }
+ } else {
+ // Create new parameters.
+ for (intptr_t i = 0; i < parameter_count(); ++i) {
+ ParameterInstr* param = new ParameterInstr(i, graph_entry_);
+ param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
+ graph_entry_->initial_definitions()->Add(param);
+ env.Add(param);
+ }
}
// Initialize all locals with #null in the renaming environment.
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698