diff options
-rw-r--r-- | 054static_dispatch.cc | 9 | ||||
-rw-r--r-- | 056shape_shifting_recipe.cc | 5 |
2 files changed, 8 insertions, 6 deletions
diff --git a/054static_dispatch.cc b/054static_dispatch.cc index e4e417d8..702e5331 100644 --- a/054static_dispatch.cc +++ b/054static_dispatch.cc @@ -180,7 +180,7 @@ void resolve_ambiguous_calls(const recipe_ordinal r) { } string best_variant(instruction& inst, const recipe& caller_recipe) { - vector<recipe_ordinal>& variants = get(Recipe_variants, inst.name); + const vector<recipe_ordinal>& variants = get(Recipe_variants, inst.name); vector<recipe_ordinal> candidates; // Static Dispatch Phase 1 @@ -234,7 +234,7 @@ string best_variant(instruction& inst, const recipe& caller_recipe) { } // phase 1 -vector<recipe_ordinal> strictly_matching_variants(const instruction& inst, vector<recipe_ordinal>& variants) { +vector<recipe_ordinal> strictly_matching_variants(const instruction& inst, const vector<recipe_ordinal>& variants) { vector<recipe_ordinal> result; for (int i = 0; i < SIZE(variants); ++i) { if (variants.at(i) == -1) continue; @@ -263,7 +263,7 @@ bool all_header_reagents_strictly_match(const instruction& inst, const recipe& v } // phase 2 -vector<recipe_ordinal> strictly_matching_variants_except_literal_against_address_or_boolean(const instruction& inst, vector<recipe_ordinal>& variants) { +vector<recipe_ordinal> strictly_matching_variants_except_literal_against_address_or_boolean(const instruction& inst, const vector<recipe_ordinal>& variants) { vector<recipe_ordinal> result; for (int i = 0; i < SIZE(variants); ++i) { if (variants.at(i) == -1) continue; @@ -302,7 +302,7 @@ bool types_strictly_match_except_literal_against_address_or_boolean(const reagen } // phase 4 -vector<recipe_ordinal> matching_variants(const instruction& inst, vector<recipe_ordinal>& variants) { +vector<recipe_ordinal> matching_variants(const instruction& inst, const vector<recipe_ordinal>& variants) { vector<recipe_ordinal> result; for (int i = 0; i < SIZE(variants); ++i) { if (variants.at(i) == -1) continue; @@ -333,6 +333,7 @@ bool all_header_reagents_match(const instruction& inst, const recipe& variant) { // tie-breaker for each phase const recipe& best_variant(const instruction& inst, vector<recipe_ordinal>& candidates) { assert(!candidates.empty()); + if (SIZE(candidates) == 1) return get(Recipe, candidates.at(0)); int min_score = 999; int min_index = 0; for (int i = 0; i < SIZE(candidates); ++i) { diff --git a/056shape_shifting_recipe.cc b/056shape_shifting_recipe.cc index 917fce5c..d28b5713 100644 --- a/056shape_shifting_recipe.cc +++ b/056shape_shifting_recipe.cc @@ -53,7 +53,7 @@ if (!candidates.empty()) { trace(9992, "transform") << "found variant to specialize: " << exemplar << ' ' << get(Recipe, exemplar).name << end(); recipe_ordinal new_recipe_ordinal = new_variant(exemplar, inst, caller_recipe); if (new_recipe_ordinal == 0) goto skip_shape_shifting_variants; - variants.push_back(new_recipe_ordinal); // side-effect + get(Recipe_variants, inst.name).push_back(new_recipe_ordinal); // side-effect recipe& variant = get(Recipe, new_recipe_ordinal); // perform all transforms on the new specialization if (!variant.steps.empty()) { @@ -87,7 +87,7 @@ if (is_literal(from) && is_mu_address(to)) :(code) // phase 3 of static dispatch -vector<recipe_ordinal> strictly_matching_shape_shifting_variants(const instruction& inst, vector<recipe_ordinal>& variants) { +vector<recipe_ordinal> strictly_matching_shape_shifting_variants(const instruction& inst, const vector<recipe_ordinal>& variants) { vector<recipe_ordinal> result; for (int i = 0; i < SIZE(variants); ++i) { if (variants.at(i) == -1) continue; @@ -118,6 +118,7 @@ bool all_concrete_header_reagents_strictly_match(const instruction& inst, const // tie-breaker for phase 3 recipe_ordinal best_shape_shifting_variant(const instruction& inst, vector<recipe_ordinal>& candidates) { assert(!candidates.empty()); + if (SIZE(candidates) == 1) return candidates.at(0); // primary score int max_score = -1; for (int i = 0; i < SIZE(candidates); ++i) { |