about summary refs log tree commit diff stats
path: root/054static_dispatch.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-12-04 10:24:50 -0800
committerKartik K. Agaram <vc@akkartik.com>2017-12-04 10:24:50 -0800
commita87118d98906d2eda0265fba6cfef8b979f8d8ec (patch)
tree74d0e584aad6ad6990e1c63be0ef53bdd818d406 /054static_dispatch.cc
parent8050782c17560ef33a85bd739da8158f9c530e39 (diff)
downloadmu-a87118d98906d2eda0265fba6cfef8b979f8d8ec.tar.gz
4137 - perform specialization on indirect calls
https://lobste.rs/s/esqphf/what_are_you_working_on_this_week#c_ajgfim
Diffstat (limited to '054static_dispatch.cc')
-rw-r--r--054static_dispatch.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/054static_dispatch.cc b/054static_dispatch.cc
index 566bb7ad..8037892e 100644
--- a/054static_dispatch.cc
+++ b/054static_dispatch.cc
@@ -166,18 +166,23 @@ void resolve_ambiguous_calls(const recipe_ordinal r) {
   for (int index = 0;  index < SIZE(caller_recipe.steps);  ++index) {
     instruction& inst = caller_recipe.steps.at(index);
     if (inst.is_label) continue;
-    if (non_ghost_size(get_or_insert(Recipe_variants, inst.name)) == 0) continue;
-    trace(9992, "transform") << "instruction " << to_original_string(inst) << end();
-    Resolve_stack.push_front(call(r, index));
-    string new_name = best_variant(inst, caller_recipe);
-    if (!new_name.empty())
-      inst.name = new_name;
-    assert(Resolve_stack.front().running_recipe == r);
-    assert(Resolve_stack.front().running_step_index == index);
-    Resolve_stack.pop_front();
+    resolve_ambiguous_call(r, index, inst, caller_recipe);
   }
 }
 
+void resolve_ambiguous_call(const recipe_ordinal r, int index, instruction& inst, const recipe& caller_recipe) {
+  // End resolve_ambiguous_call(r, index, inst, caller_recipe) Special-cases
+  if (non_ghost_size(get_or_insert(Recipe_variants, inst.name)) == 0) return;
+  trace(9992, "transform") << "instruction " << to_original_string(inst) << end();
+  Resolve_stack.push_front(call(r, index));
+  string new_name = best_variant(inst, caller_recipe);
+  if (!new_name.empty())
+    inst.name = new_name;
+  assert(Resolve_stack.front().running_recipe == r);
+  assert(Resolve_stack.front().running_step_index == index);
+  Resolve_stack.pop_front();
+}
+
 string best_variant(const instruction& inst, const recipe& caller_recipe) {
   const vector<recipe_ordinal>& variants = get(Recipe_variants, inst.name);
   vector<recipe_ordinal> candidates;