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

Unified Diff: runtime/vm/flow_graph.cc

Issue 2894953002: Support inlining of calls where type arguments are passed to generic functions. (Closed)
Patch Set: Created 3 years, 7 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_inliner.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 84b9e483e42517457bd48e6b7bce6e65207ac959..df8ac683c7e41e352fd714e8d24dd343502f67c5 100644
--- a/runtime/vm/flow_graph.cc
+++ b/runtime/vm/flow_graph.cc
@@ -680,6 +680,10 @@ class VariableLivenessAnalysis : public LivenessAnalysis {
if (store->local().Equals(*flow_graph_->CurrentContextVar())) {
return true;
}
+ if ((flow_graph_->FunctionTypeArgsVar() != NULL) &&
Vyacheslav Egorov (Google) 2017/05/22 11:23:21 Is this a mutable variable? I thought it's just
regis 2017/05/22 17:51:08 It is invariable with one exception: if the generi
regis 2017/05/22 18:02:42 I suppose I could use the SpecialParameterInstr on
Vyacheslav Egorov (Google) 2017/05/22 18:39:43 I think there is no problem. I think the best way
+ store->local().Equals(*flow_graph_->FunctionTypeArgsVar())) {
+ return true;
+ }
if (store->is_dead()) {
return false;
@@ -698,6 +702,10 @@ class VariableLivenessAnalysis : public LivenessAnalysis {
if (load->local().Equals(*flow_graph_->CurrentContextVar())) {
return false;
}
+ if ((flow_graph_->FunctionTypeArgsVar() != NULL) &&
+ load->local().Equals(*flow_graph_->FunctionTypeArgsVar())) {
+ return false;
+ }
const intptr_t index = load->local().BitIndexIn(num_non_copied_params_);
return load->is_last() && !GetLiveOutSet(block)->Contains(index);
}
@@ -772,9 +780,9 @@ void VariableLivenessAnalysis::ComputeInitialSets() {
}
-void FlowGraph::ComputeSSA(
- intptr_t next_virtual_register_number,
- ZoneGrowableArray<Definition*>* inlining_parameters) {
+void FlowGraph::ComputeSSA(intptr_t next_virtual_register_number,
+ ZoneGrowableArray<Definition*>* inlining_parameters,
+ Definition* inlining_type_args) {
ASSERT((next_virtual_register_number == 0) || (inlining_parameters != NULL));
current_ssa_temp_index_ = next_virtual_register_number;
GrowableArray<BitVector*> dominance_frontier;
@@ -791,7 +799,8 @@ void FlowGraph::ComputeSSA(
// Rename uses to reference inserted phis where appropriate.
// Collect phis that reach a non-environment use.
- Rename(&live_phis, &variable_liveness, inlining_parameters);
+ Rename(&live_phis, &variable_liveness, inlining_parameters,
+ inlining_type_args);
// Propagate alive mark transitively from alive phis and then remove
// non-live ones.
@@ -979,7 +988,8 @@ void FlowGraph::InsertPhis(const GrowableArray<BlockEntryInstr*>& preorder,
void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis,
VariableLivenessAnalysis* variable_liveness,
- ZoneGrowableArray<Definition*>* inlining_parameters) {
+ ZoneGrowableArray<Definition*>* inlining_parameters,
+ Definition* inlining_type_args) {
GraphEntryInstr* entry = graph_entry();
// Initial renaming environment.
@@ -1015,8 +1025,22 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis,
// Initialize all locals in the renaming environment For OSR, the locals have
// already been handled as parameters.
if (!IsCompiledForOsr()) {
+ const intptr_t type_args_env_index =
+ (FunctionTypeArgsVar() != NULL) ? FunctionTypeArgsEnvIndex() : -1;
for (intptr_t i = parameter_count(); i < variable_count(); ++i) {
- if (i == CurrentContextEnvIndex()) {
+ if (i == type_args_env_index) {
Vyacheslav Egorov (Google) 2017/05/22 11:23:21 I think a better way would be to mimic what we do
regis 2017/05/22 17:51:08 Thank you for the suggestion. Let me try that.
+ if (inlining_type_args != NULL) {
+ AllocateSSAIndexes(inlining_type_args);
+ AddToInitialDefinitions(inlining_type_args);
+ env.Add(inlining_type_args);
+ } else {
+ // TODO(regis): For now, initialize local variable to null.
+ // Where do we check for a passed type args? If not passed in, must
+ // set to vector of dynamic of the proper length.
+ // Do we need a FunctionTypeArgsInstr?
+ env.Add(constant_null());
+ }
+ } else if (i == CurrentContextEnvIndex()) {
if (function().IsClosureFunction()) {
CurrentContextInstr* context = new CurrentContextInstr();
context->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
« no previous file with comments | « runtime/vm/flow_graph.h ('k') | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698