From 82d6cedb9a88aee64b1b806fe35d2689a32bc9a0 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Wed, 1 May 2019 22:31:40 -0500 Subject: [PATCH 1/2] Try out a branching trampoline dispatch Commit migrated from https://github.com/mono/mono/commit/f557414b6164f9428ffbef1d8b42754ef89aae0b --- src/mono/mono/mini/m2n-gen.cs | 53 ++ src/mono/mono/mini/wasm_m2n_invoke.g.h | 894 ++++++++++++++++++++----- 2 files changed, 764 insertions(+), 183 deletions(-) diff --git a/src/mono/mono/mini/m2n-gen.cs b/src/mono/mono/mini/m2n-gen.cs index 423b19b7f39a7..3db96cadd588a 100644 --- a/src/mono/mono/mini/m2n-gen.cs +++ b/src/mono/mono/mini/m2n-gen.cs @@ -1,4 +1,6 @@ using System; +using System.Linq; +using System.Collections.Generic; class EmitCtx { @@ -174,7 +176,58 @@ static void Main () { Console.WriteLine ("\n}\n"); } + WriteDispatch (cookies); + } + + static void WriteDispatch (string [] items) + { + Array.Sort (items); + Console.WriteLine ("static void\nicall_trampoline_dispatch (const char *cookie, void *target_func, InterpMethodArguments *margs)"); + Console.WriteLine ("{"); + Partition (items, 0); + Console.WriteLine ("\tprintf (\"CANNOT HANDLE COOKIE %s\\n\", cookie);"); + Console.WriteLine ("\tg_assert (0);"); + Console.WriteLine ("}"); + } + + static void Partition (IEnumerable set, int pos, int depth = 0) { + const string Indent = "\t"; + var prefix = Indent; + for (var c = 0; c < pos; c++) + prefix += Indent; + + var checks = 0; + + var hits = set.Where (s => s.Length == pos); + if (hits.Any ()) { + Console.WriteLine ($"{prefix}{Elif (checks++)} (cookie[{pos}] == '\\0') {{"); + + var h = hits.First (); + Console.WriteLine ($"{prefix}{Indent}// found: {h} depth {pos + checks + depth}"); + Console.WriteLine ($"{prefix}{Indent}wasm_invoke_{h.ToLower ()}(target_func, margs);"); + Console.WriteLine ($"{prefix}{Indent}return;"); + Console.WriteLine ($"{prefix}}}"); + } + + var groups = set.Where (s => s.Length > pos).GroupBy (s => s.Skip(pos).First().ToString()); + + if (!groups.Any ()) + return; + + foreach (var g in groups) { + Console.WriteLine ($"{prefix}{Elif (checks)} (cookie[{pos}] == '{g.Key}') {{"); + Partition (g.ToList (), pos + 1, checks + depth); + Console.WriteLine ($"{prefix}}}"); + checks++; + } + + string Elif (int c) + { + return c == 0 ? "if" : "else if"; + } + } + static void WriteFlat () { Console.WriteLine ("static void\nicall_trampoline_dispatch (const char *cookie, void *target_func, InterpMethodArguments *margs)"); Console.WriteLine ("{"); for (int i = 0; i < cookies.Length; ++i) { diff --git a/src/mono/mono/mini/wasm_m2n_invoke.g.h b/src/mono/mono/mini/wasm_m2n_invoke.g.h index 3dca03991d36b..b9dd39ab2cb45 100644 --- a/src/mono/mono/mini/wasm_m2n_invoke.g.h +++ b/src/mono/mono/mini/wasm_m2n_invoke.g.h @@ -886,188 +886,716 @@ wasm_invoke_vil (void *target_func, InterpMethodArguments *margs) static void icall_trampoline_dispatch (const char *cookie, void *target_func, InterpMethodArguments *margs) { - if (!strcmp ("V", cookie)) - wasm_invoke_v (target_func, margs); - else if (!strcmp ("VI", cookie)) - wasm_invoke_vi (target_func, margs); - else if (!strcmp ("VII", cookie)) - wasm_invoke_vii (target_func, margs); - else if (!strcmp ("VIII", cookie)) - wasm_invoke_viii (target_func, margs); - else if (!strcmp ("VIIII", cookie)) - wasm_invoke_viiii (target_func, margs); - else if (!strcmp ("VIIIII", cookie)) - wasm_invoke_viiiii (target_func, margs); - else if (!strcmp ("VIIIIII", cookie)) - wasm_invoke_viiiiii (target_func, margs); - else if (!strcmp ("VIIIIIII", cookie)) - wasm_invoke_viiiiiii (target_func, margs); - else if (!strcmp ("VIIIIIIII", cookie)) - wasm_invoke_viiiiiiii (target_func, margs); - else if (!strcmp ("VIIIIIIIII", cookie)) - wasm_invoke_viiiiiiiii (target_func, margs); - else if (!strcmp ("VIIIIIIIIII", cookie)) - wasm_invoke_viiiiiiiiii (target_func, margs); - else if (!strcmp ("I", cookie)) - wasm_invoke_i (target_func, margs); - else if (!strcmp ("II", cookie)) - wasm_invoke_ii (target_func, margs); - else if (!strcmp ("III", cookie)) - wasm_invoke_iii (target_func, margs); - else if (!strcmp ("IIII", cookie)) - wasm_invoke_iiii (target_func, margs); - else if (!strcmp ("IIIII", cookie)) - wasm_invoke_iiiii (target_func, margs); - else if (!strcmp ("IIIIII", cookie)) - wasm_invoke_iiiiii (target_func, margs); - else if (!strcmp ("IIIIIII", cookie)) - wasm_invoke_iiiiiii (target_func, margs); - else if (!strcmp ("IIIIIIII", cookie)) - wasm_invoke_iiiiiiii (target_func, margs); - else if (!strcmp ("IIIIIIIII", cookie)) - wasm_invoke_iiiiiiiii (target_func, margs); - else if (!strcmp ("IIIIIIIIII", cookie)) - wasm_invoke_iiiiiiiiii (target_func, margs); - else if (!strcmp ("IIIIIIIIIII", cookie)) - wasm_invoke_iiiiiiiiiii (target_func, margs); - else if (!strcmp ("IIIIIIIIIIII", cookie)) - wasm_invoke_iiiiiiiiiiii (target_func, margs); - else if (!strcmp ("IIIIIIIIIIIII", cookie)) - wasm_invoke_iiiiiiiiiiiii (target_func, margs); - else if (!strcmp ("IIIIIIIIIIIIII", cookie)) - wasm_invoke_iiiiiiiiiiiiii (target_func, margs); - else if (!strcmp ("IILIIII", cookie)) - wasm_invoke_iiliiii (target_func, margs); - else if (!strcmp ("IIF", cookie)) - wasm_invoke_iif (target_func, margs); - else if (!strcmp ("IIFI", cookie)) - wasm_invoke_iifi (target_func, margs); - else if (!strcmp ("IIFF", cookie)) - wasm_invoke_iiff (target_func, margs); - else if (!strcmp ("IFFII", cookie)) - wasm_invoke_iffii (target_func, margs); - else if (!strcmp ("IIFII", cookie)) - wasm_invoke_iifii (target_func, margs); - else if (!strcmp ("IIFFI", cookie)) - wasm_invoke_iiffi (target_func, margs); - else if (!strcmp ("IIFFF", cookie)) - wasm_invoke_iifff (target_func, margs); - else if (!strcmp ("IIFFFI", cookie)) - wasm_invoke_iifffi (target_func, margs); - else if (!strcmp ("IIFFII", cookie)) - wasm_invoke_iiffii (target_func, margs); - else if (!strcmp ("IIFIII", cookie)) - wasm_invoke_iifiii (target_func, margs); - else if (!strcmp ("IIFFFFI", cookie)) - wasm_invoke_iiffffi (target_func, margs); - else if (!strcmp ("IIFFFFII", cookie)) - wasm_invoke_iiffffii (target_func, margs); - else if (!strcmp ("IIIF", cookie)) - wasm_invoke_iiif (target_func, margs); - else if (!strcmp ("IIIFI", cookie)) - wasm_invoke_iiifi (target_func, margs); - else if (!strcmp ("IIIFII", cookie)) - wasm_invoke_iiifii (target_func, margs); - else if (!strcmp ("IIIFIII", cookie)) - wasm_invoke_iiifiii (target_func, margs); - else if (!strcmp ("IIIIF", cookie)) - wasm_invoke_iiiif (target_func, margs); - else if (!strcmp ("IIIIFI", cookie)) - wasm_invoke_iiiifi (target_func, margs); - else if (!strcmp ("IIIIFII", cookie)) - wasm_invoke_iiiifii (target_func, margs); - else if (!strcmp ("IIIIFIII", cookie)) - wasm_invoke_iiiifiii (target_func, margs); - else if (!strcmp ("IIIFFFF", cookie)) - wasm_invoke_iiiffff (target_func, margs); - else if (!strcmp ("IIIFFFFF", cookie)) - wasm_invoke_iiifffff (target_func, margs); - else if (!strcmp ("IIFFFFFF", cookie)) - wasm_invoke_iiffffff (target_func, margs); - else if (!strcmp ("IIIFFFFFF", cookie)) - wasm_invoke_iiiffffff (target_func, margs); - else if (!strcmp ("IIIIIIIF", cookie)) - wasm_invoke_iiiiiiif (target_func, margs); - else if (!strcmp ("IIIIIIIFF", cookie)) - wasm_invoke_iiiiiiiff (target_func, margs); - else if (!strcmp ("IIFFFFFFFF", cookie)) - wasm_invoke_iiffffffff (target_func, margs); - else if (!strcmp ("IIIFFFFFFFF", cookie)) - wasm_invoke_iiiffffffff (target_func, margs); - else if (!strcmp ("IIIIIIFII", cookie)) - wasm_invoke_iiiiiifii (target_func, margs); - else if (!strcmp ("IIIFFFFFFFFIII", cookie)) - wasm_invoke_iiiffffffffiii (target_func, margs); - else if (!strcmp ("IIIIIFFFFIIII", cookie)) - wasm_invoke_iiiiiffffiiii (target_func, margs); - else if (!strcmp ("IFFFFFFI", cookie)) - wasm_invoke_iffffffi (target_func, margs); - else if (!strcmp ("IIFFIII", cookie)) - wasm_invoke_iiffiii (target_func, margs); - else if (!strcmp ("ILI", cookie)) - wasm_invoke_ili (target_func, margs); - else if (!strcmp ("L", cookie)) - wasm_invoke_l (target_func, margs); - else if (!strcmp ("LL", cookie)) - wasm_invoke_ll (target_func, margs); - else if (!strcmp ("LI", cookie)) - wasm_invoke_li (target_func, margs); - else if (!strcmp ("LIL", cookie)) - wasm_invoke_lil (target_func, margs); - else if (!strcmp ("LILII", cookie)) - wasm_invoke_lilii (target_func, margs); - else if (!strcmp ("DD", cookie)) - wasm_invoke_dd (target_func, margs); - else if (!strcmp ("DDI", cookie)) - wasm_invoke_ddi (target_func, margs); - else if (!strcmp ("DDD", cookie)) - wasm_invoke_ddd (target_func, margs); - else if (!strcmp ("VIF", cookie)) - wasm_invoke_vif (target_func, margs); - else if (!strcmp ("VIFF", cookie)) - wasm_invoke_viff (target_func, margs); - else if (!strcmp ("VIFFFF", cookie)) - wasm_invoke_viffff (target_func, margs); - else if (!strcmp ("VIFFFFFI", cookie)) - wasm_invoke_vifffffi (target_func, margs); - else if (!strcmp ("VIIFFI", cookie)) - wasm_invoke_viiffi (target_func, margs); - else if (!strcmp ("FF", cookie)) - wasm_invoke_ff (target_func, margs); - else if (!strcmp ("FFF", cookie)) - wasm_invoke_fff (target_func, margs); - else if (!strcmp ("DI", cookie)) - wasm_invoke_di (target_func, margs); - else if (!strcmp ("FI", cookie)) - wasm_invoke_fi (target_func, margs); - else if (!strcmp ("IIL", cookie)) - wasm_invoke_iil (target_func, margs); - else if (!strcmp ("IILI", cookie)) - wasm_invoke_iili (target_func, margs); - else if (!strcmp ("IILLLI", cookie)) - wasm_invoke_iillli (target_func, margs); - else if (!strcmp ("IDIII", cookie)) - wasm_invoke_idiii (target_func, margs); - else if (!strcmp ("LII", cookie)) - wasm_invoke_lii (target_func, margs); - else if (!strcmp ("VID", cookie)) - wasm_invoke_vid (target_func, margs); - else if (!strcmp ("VILLI", cookie)) - wasm_invoke_villi (target_func, margs); - else if (!strcmp ("DID", cookie)) - wasm_invoke_did (target_func, margs); - else if (!strcmp ("DIDD", cookie)) - wasm_invoke_didd (target_func, margs); - else if (!strcmp ("FIF", cookie)) - wasm_invoke_fif (target_func, margs); - else if (!strcmp ("FIFF", cookie)) - wasm_invoke_fiff (target_func, margs); - else if (!strcmp ("LILL", cookie)) - wasm_invoke_lill (target_func, margs); - else if (!strcmp ("VIL", cookie)) - wasm_invoke_vil (target_func, margs); - else { - printf ("CANNOT HANDLE COOKIE %s\n", cookie); - g_assert (0); + if (cookie[0] == 'D') { + if (cookie[1] == 'D') { + if (cookie[2] == '\0') { + // found: DD depth 3 + wasm_invoke_dd(target_func, margs); + return; + } + else if (cookie[2] == 'D') { + if (cookie[3] == '\0') { + // found: DDD depth 5 + wasm_invoke_ddd(target_func, margs); + return; + } + } + else if (cookie[2] == 'I') { + if (cookie[3] == '\0') { + // found: DDI depth 6 + wasm_invoke_ddi(target_func, margs); + return; + } + } + } + else if (cookie[1] == 'I') { + if (cookie[2] == '\0') { + // found: DI depth 4 + wasm_invoke_di(target_func, margs); + return; + } + else if (cookie[2] == 'D') { + if (cookie[3] == '\0') { + // found: DID depth 6 + wasm_invoke_did(target_func, margs); + return; + } + else if (cookie[3] == 'D') { + if (cookie[4] == '\0') { + // found: DIDD depth 8 + wasm_invoke_didd(target_func, margs); + return; + } + } + } + } } + else if (cookie[0] == 'F') { + if (cookie[1] == 'F') { + if (cookie[2] == '\0') { + // found: FF depth 4 + wasm_invoke_ff(target_func, margs); + return; + } + else if (cookie[2] == 'F') { + if (cookie[3] == '\0') { + // found: FFF depth 6 + wasm_invoke_fff(target_func, margs); + return; + } + } + } + else if (cookie[1] == 'I') { + if (cookie[2] == '\0') { + // found: FI depth 5 + wasm_invoke_fi(target_func, margs); + return; + } + else if (cookie[2] == 'F') { + if (cookie[3] == '\0') { + // found: FIF depth 7 + wasm_invoke_fif(target_func, margs); + return; + } + else if (cookie[3] == 'F') { + if (cookie[4] == '\0') { + // found: FIFF depth 9 + wasm_invoke_fiff(target_func, margs); + return; + } + } + } + } + } + else if (cookie[0] == 'I') { + if (cookie[1] == '\0') { + // found: I depth 4 + wasm_invoke_i(target_func, margs); + return; + } + else if (cookie[1] == 'D') { + if (cookie[2] == 'I') { + if (cookie[3] == 'I') { + if (cookie[4] == 'I') { + if (cookie[5] == '\0') { + // found: IDIII depth 9 + wasm_invoke_idiii(target_func, margs); + return; + } + } + } + } + } + else if (cookie[1] == 'F') { + if (cookie[2] == 'F') { + if (cookie[3] == 'F') { + if (cookie[4] == 'F') { + if (cookie[5] == 'F') { + if (cookie[6] == 'F') { + if (cookie[7] == 'I') { + if (cookie[8] == '\0') { + // found: IFFFFFFI depth 13 + wasm_invoke_iffffffi(target_func, margs); + return; + } + } + } + } + } + } + else if (cookie[3] == 'I') { + if (cookie[4] == 'I') { + if (cookie[5] == '\0') { + // found: IFFII depth 11 + wasm_invoke_iffii(target_func, margs); + return; + } + } + } + } + } + else if (cookie[1] == 'I') { + if (cookie[2] == '\0') { + // found: II depth 8 + wasm_invoke_ii(target_func, margs); + return; + } + else if (cookie[2] == 'F') { + if (cookie[3] == '\0') { + // found: IIF depth 10 + wasm_invoke_iif(target_func, margs); + return; + } + else if (cookie[3] == 'F') { + if (cookie[4] == '\0') { + // found: IIFF depth 12 + wasm_invoke_iiff(target_func, margs); + return; + } + else if (cookie[4] == 'F') { + if (cookie[5] == '\0') { + // found: IIFFF depth 14 + wasm_invoke_iifff(target_func, margs); + return; + } + else if (cookie[5] == 'F') { + if (cookie[6] == 'F') { + if (cookie[7] == 'F') { + if (cookie[8] == '\0') { + // found: IIFFFFFF depth 18 + wasm_invoke_iiffffff(target_func, margs); + return; + } + else if (cookie[8] == 'F') { + if (cookie[9] == 'F') { + if (cookie[10] == '\0') { + // found: IIFFFFFFFF depth 21 + wasm_invoke_iiffffffff(target_func, margs); + return; + } + } + } + } + } + else if (cookie[6] == 'I') { + if (cookie[7] == '\0') { + // found: IIFFFFI depth 18 + wasm_invoke_iiffffi(target_func, margs); + return; + } + else if (cookie[7] == 'I') { + if (cookie[8] == '\0') { + // found: IIFFFFII depth 20 + wasm_invoke_iiffffii(target_func, margs); + return; + } + } + } + } + else if (cookie[5] == 'I') { + if (cookie[6] == '\0') { + // found: IIFFFI depth 17 + wasm_invoke_iifffi(target_func, margs); + return; + } + } + } + else if (cookie[4] == 'I') { + if (cookie[5] == '\0') { + // found: IIFFI depth 15 + wasm_invoke_iiffi(target_func, margs); + return; + } + else if (cookie[5] == 'I') { + if (cookie[6] == '\0') { + // found: IIFFII depth 17 + wasm_invoke_iiffii(target_func, margs); + return; + } + else if (cookie[6] == 'I') { + if (cookie[7] == '\0') { + // found: IIFFIII depth 19 + wasm_invoke_iiffiii(target_func, margs); + return; + } + } + } + } + } + else if (cookie[3] == 'I') { + if (cookie[4] == '\0') { + // found: IIFI depth 13 + wasm_invoke_iifi(target_func, margs); + return; + } + else if (cookie[4] == 'I') { + if (cookie[5] == '\0') { + // found: IIFII depth 15 + wasm_invoke_iifii(target_func, margs); + return; + } + else if (cookie[5] == 'I') { + if (cookie[6] == '\0') { + // found: IIFIII depth 17 + wasm_invoke_iifiii(target_func, margs); + return; + } + } + } + } + } + else if (cookie[2] == 'I') { + if (cookie[3] == '\0') { + // found: III depth 11 + wasm_invoke_iii(target_func, margs); + return; + } + else if (cookie[3] == 'F') { + if (cookie[4] == '\0') { + // found: IIIF depth 13 + wasm_invoke_iiif(target_func, margs); + return; + } + else if (cookie[4] == 'F') { + if (cookie[5] == 'F') { + if (cookie[6] == 'F') { + if (cookie[7] == '\0') { + // found: IIIFFFF depth 17 + wasm_invoke_iiiffff(target_func, margs); + return; + } + else if (cookie[7] == 'F') { + if (cookie[8] == '\0') { + // found: IIIFFFFF depth 19 + wasm_invoke_iiifffff(target_func, margs); + return; + } + else if (cookie[8] == 'F') { + if (cookie[9] == '\0') { + // found: IIIFFFFFF depth 21 + wasm_invoke_iiiffffff(target_func, margs); + return; + } + else if (cookie[9] == 'F') { + if (cookie[10] == 'F') { + if (cookie[11] == '\0') { + // found: IIIFFFFFFFF depth 24 + wasm_invoke_iiiffffffff(target_func, margs); + return; + } + else if (cookie[11] == 'I') { + if (cookie[12] == 'I') { + if (cookie[13] == 'I') { + if (cookie[14] == '\0') { + // found: IIIFFFFFFFFIII depth 28 + wasm_invoke_iiiffffffffiii(target_func, margs); + return; + } + } + } + } + } + } + } + } + } + } + } + else if (cookie[4] == 'I') { + if (cookie[5] == '\0') { + // found: IIIFI depth 16 + wasm_invoke_iiifi(target_func, margs); + return; + } + else if (cookie[5] == 'I') { + if (cookie[6] == '\0') { + // found: IIIFII depth 18 + wasm_invoke_iiifii(target_func, margs); + return; + } + else if (cookie[6] == 'I') { + if (cookie[7] == '\0') { + // found: IIIFIII depth 20 + wasm_invoke_iiifiii(target_func, margs); + return; + } + } + } + } + } + else if (cookie[3] == 'I') { + if (cookie[4] == '\0') { + // found: IIII depth 14 + wasm_invoke_iiii(target_func, margs); + return; + } + else if (cookie[4] == 'F') { + if (cookie[5] == '\0') { + // found: IIIIF depth 16 + wasm_invoke_iiiif(target_func, margs); + return; + } + else if (cookie[5] == 'I') { + if (cookie[6] == '\0') { + // found: IIIIFI depth 18 + wasm_invoke_iiiifi(target_func, margs); + return; + } + else if (cookie[6] == 'I') { + if (cookie[7] == '\0') { + // found: IIIIFII depth 20 + wasm_invoke_iiiifii(target_func, margs); + return; + } + else if (cookie[7] == 'I') { + if (cookie[8] == '\0') { + // found: IIIIFIII depth 22 + wasm_invoke_iiiifiii(target_func, margs); + return; + } + } + } + } + } + else if (cookie[4] == 'I') { + if (cookie[5] == '\0') { + // found: IIIII depth 17 + wasm_invoke_iiiii(target_func, margs); + return; + } + else if (cookie[5] == 'F') { + if (cookie[6] == 'F') { + if (cookie[7] == 'F') { + if (cookie[8] == 'F') { + if (cookie[9] == 'I') { + if (cookie[10] == 'I') { + if (cookie[11] == 'I') { + if (cookie[12] == 'I') { + if (cookie[13] == '\0') { + // found: IIIIIFFFFIIII depth 26 + wasm_invoke_iiiiiffffiiii(target_func, margs); + return; + } + } + } + } + } + } + } + } + } + else if (cookie[5] == 'I') { + if (cookie[6] == '\0') { + // found: IIIIII depth 20 + wasm_invoke_iiiiii(target_func, margs); + return; + } + else if (cookie[6] == 'F') { + if (cookie[7] == 'I') { + if (cookie[8] == 'I') { + if (cookie[9] == '\0') { + // found: IIIIIIFII depth 24 + wasm_invoke_iiiiiifii(target_func, margs); + return; + } + } + } + } + else if (cookie[6] == 'I') { + if (cookie[7] == '\0') { + // found: IIIIIII depth 23 + wasm_invoke_iiiiiii(target_func, margs); + return; + } + else if (cookie[7] == 'F') { + if (cookie[8] == '\0') { + // found: IIIIIIIF depth 25 + wasm_invoke_iiiiiiif(target_func, margs); + return; + } + else if (cookie[8] == 'F') { + if (cookie[9] == '\0') { + // found: IIIIIIIFF depth 27 + wasm_invoke_iiiiiiiff(target_func, margs); + return; + } + } + } + else if (cookie[7] == 'I') { + if (cookie[8] == '\0') { + // found: IIIIIIII depth 26 + wasm_invoke_iiiiiiii(target_func, margs); + return; + } + else if (cookie[8] == 'I') { + if (cookie[9] == '\0') { + // found: IIIIIIIII depth 28 + wasm_invoke_iiiiiiiii(target_func, margs); + return; + } + else if (cookie[9] == 'I') { + if (cookie[10] == '\0') { + // found: IIIIIIIIII depth 30 + wasm_invoke_iiiiiiiiii(target_func, margs); + return; + } + else if (cookie[10] == 'I') { + if (cookie[11] == '\0') { + // found: IIIIIIIIIII depth 32 + wasm_invoke_iiiiiiiiiii(target_func, margs); + return; + } + else if (cookie[11] == 'I') { + if (cookie[12] == '\0') { + // found: IIIIIIIIIIII depth 34 + wasm_invoke_iiiiiiiiiiii(target_func, margs); + return; + } + else if (cookie[12] == 'I') { + if (cookie[13] == '\0') { + // found: IIIIIIIIIIIII depth 36 + wasm_invoke_iiiiiiiiiiiii(target_func, margs); + return; + } + else if (cookie[13] == 'I') { + if (cookie[14] == '\0') { + // found: IIIIIIIIIIIIII depth 38 + wasm_invoke_iiiiiiiiiiiiii(target_func, margs); + return; + } + } + } + } + } + } + } + } + } + } + } + } + } + else if (cookie[2] == 'L') { + if (cookie[3] == '\0') { + // found: IIL depth 12 + wasm_invoke_iil(target_func, margs); + return; + } + else if (cookie[3] == 'I') { + if (cookie[4] == '\0') { + // found: IILI depth 14 + wasm_invoke_iili(target_func, margs); + return; + } + else if (cookie[4] == 'I') { + if (cookie[5] == 'I') { + if (cookie[6] == 'I') { + if (cookie[7] == '\0') { + // found: IILIIII depth 18 + wasm_invoke_iiliiii(target_func, margs); + return; + } + } + } + } + } + else if (cookie[3] == 'L') { + if (cookie[4] == 'L') { + if (cookie[5] == 'I') { + if (cookie[6] == '\0') { + // found: IILLLI depth 17 + wasm_invoke_iillli(target_func, margs); + return; + } + } + } + } + } + } + else if (cookie[1] == 'L') { + if (cookie[2] == 'I') { + if (cookie[3] == '\0') { + // found: ILI depth 10 + wasm_invoke_ili(target_func, margs); + return; + } + } + } + } + else if (cookie[0] == 'L') { + if (cookie[1] == '\0') { + // found: L depth 5 + wasm_invoke_l(target_func, margs); + return; + } + else if (cookie[1] == 'I') { + if (cookie[2] == '\0') { + // found: LI depth 7 + wasm_invoke_li(target_func, margs); + return; + } + else if (cookie[2] == 'I') { + if (cookie[3] == '\0') { + // found: LII depth 9 + wasm_invoke_lii(target_func, margs); + return; + } + } + else if (cookie[2] == 'L') { + if (cookie[3] == '\0') { + // found: LIL depth 10 + wasm_invoke_lil(target_func, margs); + return; + } + else if (cookie[3] == 'I') { + if (cookie[4] == 'I') { + if (cookie[5] == '\0') { + // found: LILII depth 13 + wasm_invoke_lilii(target_func, margs); + return; + } + } + } + else if (cookie[3] == 'L') { + if (cookie[4] == '\0') { + // found: LILL depth 13 + wasm_invoke_lill(target_func, margs); + return; + } + } + } + } + else if (cookie[1] == 'L') { + if (cookie[2] == '\0') { + // found: LL depth 8 + wasm_invoke_ll(target_func, margs); + return; + } + } + } + else if (cookie[0] == 'V') { + if (cookie[1] == '\0') { + // found: V depth 6 + wasm_invoke_v(target_func, margs); + return; + } + else if (cookie[1] == 'I') { + if (cookie[2] == '\0') { + // found: VI depth 8 + wasm_invoke_vi(target_func, margs); + return; + } + else if (cookie[2] == 'D') { + if (cookie[3] == '\0') { + // found: VID depth 10 + wasm_invoke_vid(target_func, margs); + return; + } + } + else if (cookie[2] == 'F') { + if (cookie[3] == '\0') { + // found: VIF depth 11 + wasm_invoke_vif(target_func, margs); + return; + } + else if (cookie[3] == 'F') { + if (cookie[4] == '\0') { + // found: VIFF depth 13 + wasm_invoke_viff(target_func, margs); + return; + } + else if (cookie[4] == 'F') { + if (cookie[5] == 'F') { + if (cookie[6] == '\0') { + // found: VIFFFF depth 16 + wasm_invoke_viffff(target_func, margs); + return; + } + else if (cookie[6] == 'F') { + if (cookie[7] == 'I') { + if (cookie[8] == '\0') { + // found: VIFFFFFI depth 19 + wasm_invoke_vifffffi(target_func, margs); + return; + } + } + } + } + } + } + } + else if (cookie[2] == 'I') { + if (cookie[3] == '\0') { + // found: VII depth 12 + wasm_invoke_vii(target_func, margs); + return; + } + else if (cookie[3] == 'F') { + if (cookie[4] == 'F') { + if (cookie[5] == 'I') { + if (cookie[6] == '\0') { + // found: VIIFFI depth 16 + wasm_invoke_viiffi(target_func, margs); + return; + } + } + } + } + else if (cookie[3] == 'I') { + if (cookie[4] == '\0') { + // found: VIII depth 15 + wasm_invoke_viii(target_func, margs); + return; + } + else if (cookie[4] == 'I') { + if (cookie[5] == '\0') { + // found: VIIII depth 17 + wasm_invoke_viiii(target_func, margs); + return; + } + else if (cookie[5] == 'I') { + if (cookie[6] == '\0') { + // found: VIIIII depth 19 + wasm_invoke_viiiii(target_func, margs); + return; + } + else if (cookie[6] == 'I') { + if (cookie[7] == '\0') { + // found: VIIIIII depth 21 + wasm_invoke_viiiiii(target_func, margs); + return; + } + else if (cookie[7] == 'I') { + if (cookie[8] == '\0') { + // found: VIIIIIII depth 23 + wasm_invoke_viiiiiii(target_func, margs); + return; + } + else if (cookie[8] == 'I') { + if (cookie[9] == '\0') { + // found: VIIIIIIII depth 25 + wasm_invoke_viiiiiiii(target_func, margs); + return; + } + else if (cookie[9] == 'I') { + if (cookie[10] == '\0') { + // found: VIIIIIIIII depth 27 + wasm_invoke_viiiiiiiii(target_func, margs); + return; + } + else if (cookie[10] == 'I') { + if (cookie[11] == '\0') { + // found: VIIIIIIIIII depth 29 + wasm_invoke_viiiiiiiiii(target_func, margs); + return; + } + } + } + } + } + } + } + } + } + } + else if (cookie[2] == 'L') { + if (cookie[3] == '\0') { + // found: VIL depth 13 + wasm_invoke_vil(target_func, margs); + return; + } + else if (cookie[3] == 'L') { + if (cookie[4] == 'I') { + if (cookie[5] == '\0') { + // found: VILLI depth 16 + wasm_invoke_villi(target_func, margs); + return; + } + } + } + } + } + } + printf ("CANNOT HANDLE COOKIE %s\n", cookie); + g_assert (0); } From 51b4a4fa06fb01e06d3b5cc10f615fc3d19c1fac Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Thu, 2 May 2019 00:17:34 -0500 Subject: [PATCH 2/2] Order the groupings preferentially by length to reduce the worst case Commit migrated from https://github.com/mono/mono/commit/1d86f1a7923dff7421ad82d0ab4216c72521b5f2 --- src/mono/mono/mini/m2n-gen.cs | 84 +- src/mono/mono/mini/wasm_m2n_invoke.g.h | 1097 ++++++++++++------------ 2 files changed, 583 insertions(+), 598 deletions(-) diff --git a/src/mono/mono/mini/m2n-gen.cs b/src/mono/mono/mini/m2n-gen.cs index 3db96cadd588a..73bff524fbe82 100644 --- a/src/mono/mono/mini/m2n-gen.cs +++ b/src/mono/mono/mini/m2n-gen.cs @@ -112,7 +112,6 @@ class Driver { "LII", "VID", "VILLI", - "DID", "DIDD", "FIF", @@ -133,7 +132,7 @@ static string TypeToSigType (char c) { } } - static void Main () { + static void Main (string[] args) { Console.WriteLine ("/*"); Console.WriteLine ("* DON'T EDIT THIS FILE"); Console.WriteLine ("* This file was generated by m2n-gen.cs - use it instead."); @@ -176,72 +175,59 @@ static void Main () { Console.WriteLine ("\n}\n"); } - WriteDispatch (cookies); - } - static void WriteDispatch (string [] items) - { - Array.Sort (items); Console.WriteLine ("static void\nicall_trampoline_dispatch (const char *cookie, void *target_func, InterpMethodArguments *margs)"); Console.WriteLine ("{"); - Partition (items, 0); - Console.WriteLine ("\tprintf (\"CANNOT HANDLE COOKIE %s\\n\", cookie);"); - Console.WriteLine ("\tg_assert (0);"); + + if (args.Any(a => a == "--flat")) { + for (int i = 0; i < cookies.Length; ++i) { + var c = cookies [i]; + Console.Write ("\t"); + if (i > 0) + Console.Write ("else "); + Console.WriteLine ($"if (!strcmp (\"{c}\", cookie))"); + Console.WriteLine ($"\t\twasm_invoke_{c.ToLower ()} (target_func, margs);"); + } + Console.WriteLine ("\telse {"); + Console.WriteLine ("\t\tg_error (\"CANNOT HANDLE COOKIE %s\\n\", cookie);"); + Console.WriteLine ("\t}"); + } else { + Array.Sort (cookies); + WritePartition (cookies, 0); + Console.WriteLine ("\tg_error (\"CANNOT HANDLE COOKIE %s\\n\", cookie);"); + } + Console.WriteLine ("}"); } - static void Partition (IEnumerable set, int pos, int depth = 0) { - const string Indent = "\t"; - var prefix = Indent; + static void WritePartition (IEnumerable set, int pos = 0, int depth = 0) { + var prefix = "\t"; for (var c = 0; c < pos; c++) - prefix += Indent; + prefix += "\t"; var checks = 0; + var groups = set.OrderBy (s => -s.Length).Where (s => s.Length > pos).GroupBy (s => s.Skip(pos).First().ToString()); + foreach (var g in groups) { + Console.WriteLine ($"{prefix}{Elif (checks)} (cookie[{pos}] == '{g.Key}') {{"); + WritePartition (g.ToList (), pos + 1, checks + depth); + Console.WriteLine ($"{prefix}}}"); + checks++; + } + var hits = set.Where (s => s.Length == pos); if (hits.Any ()) { Console.WriteLine ($"{prefix}{Elif (checks++)} (cookie[{pos}] == '\\0') {{"); var h = hits.First (); - Console.WriteLine ($"{prefix}{Indent}// found: {h} depth {pos + checks + depth}"); - Console.WriteLine ($"{prefix}{Indent}wasm_invoke_{h.ToLower ()}(target_func, margs);"); - Console.WriteLine ($"{prefix}{Indent}return;"); + Console.WriteLine ($"{prefix}\t// found: {h} depth {pos + checks + depth}"); + Console.WriteLine ($"{prefix}\twasm_invoke_{h.ToLower ()} (target_func, margs);"); + Console.WriteLine ($"{prefix}\treturn;"); Console.WriteLine ($"{prefix}}}"); } - var groups = set.Where (s => s.Length > pos).GroupBy (s => s.Skip(pos).First().ToString()); - - if (!groups.Any ()) - return; - - foreach (var g in groups) { - Console.WriteLine ($"{prefix}{Elif (checks)} (cookie[{pos}] == '{g.Key}') {{"); - Partition (g.ToList (), pos + 1, checks + depth); - Console.WriteLine ($"{prefix}}}"); - checks++; - } - - string Elif (int c) - { + string Elif (int c) { return c == 0 ? "if" : "else if"; } } - - static void WriteFlat () { - Console.WriteLine ("static void\nicall_trampoline_dispatch (const char *cookie, void *target_func, InterpMethodArguments *margs)"); - Console.WriteLine ("{"); - for (int i = 0; i < cookies.Length; ++i) { - var c = cookies [i]; - Console.Write ("\t"); - if (i > 0) - Console.Write ("else "); - Console.WriteLine ($"if (!strcmp (\"{c}\", cookie))"); - Console.WriteLine ($"\t\twasm_invoke_{c.ToLower ()} (target_func, margs);"); - } - Console.WriteLine ("\telse {"); - Console.WriteLine ("\t\tprintf (\"CANNOT HANDLE COOKIE %s\\n\", cookie);"); - Console.WriteLine ("\t\tg_assert (0);"); - Console.WriteLine ("\t}"); - Console.WriteLine ("}"); - } } diff --git a/src/mono/mono/mini/wasm_m2n_invoke.g.h b/src/mono/mono/mini/wasm_m2n_invoke.g.h index b9dd39ab2cb45..978bca46455d8 100644 --- a/src/mono/mono/mini/wasm_m2n_invoke.g.h +++ b/src/mono/mono/mini/wasm_m2n_invoke.g.h @@ -886,362 +886,171 @@ wasm_invoke_vil (void *target_func, InterpMethodArguments *margs) static void icall_trampoline_dispatch (const char *cookie, void *target_func, InterpMethodArguments *margs) { - if (cookie[0] == 'D') { - if (cookie[1] == 'D') { - if (cookie[2] == '\0') { - // found: DD depth 3 - wasm_invoke_dd(target_func, margs); - return; - } - else if (cookie[2] == 'D') { - if (cookie[3] == '\0') { - // found: DDD depth 5 - wasm_invoke_ddd(target_func, margs); - return; - } - } - else if (cookie[2] == 'I') { - if (cookie[3] == '\0') { - // found: DDI depth 6 - wasm_invoke_ddi(target_func, margs); - return; - } - } - } - else if (cookie[1] == 'I') { - if (cookie[2] == '\0') { - // found: DI depth 4 - wasm_invoke_di(target_func, margs); - return; - } - else if (cookie[2] == 'D') { - if (cookie[3] == '\0') { - // found: DID depth 6 - wasm_invoke_did(target_func, margs); - return; - } - else if (cookie[3] == 'D') { - if (cookie[4] == '\0') { - // found: DIDD depth 8 - wasm_invoke_didd(target_func, margs); - return; - } - } - } - } - } - else if (cookie[0] == 'F') { - if (cookie[1] == 'F') { - if (cookie[2] == '\0') { - // found: FF depth 4 - wasm_invoke_ff(target_func, margs); - return; - } - else if (cookie[2] == 'F') { - if (cookie[3] == '\0') { - // found: FFF depth 6 - wasm_invoke_fff(target_func, margs); - return; - } - } - } - else if (cookie[1] == 'I') { - if (cookie[2] == '\0') { - // found: FI depth 5 - wasm_invoke_fi(target_func, margs); - return; - } - else if (cookie[2] == 'F') { - if (cookie[3] == '\0') { - // found: FIF depth 7 - wasm_invoke_fif(target_func, margs); - return; - } - else if (cookie[3] == 'F') { - if (cookie[4] == '\0') { - // found: FIFF depth 9 - wasm_invoke_fiff(target_func, margs); - return; - } - } - } - } - } - else if (cookie[0] == 'I') { - if (cookie[1] == '\0') { - // found: I depth 4 - wasm_invoke_i(target_func, margs); - return; - } - else if (cookie[1] == 'D') { + if (cookie[0] == 'I') { + if (cookie[1] == 'I') { if (cookie[2] == 'I') { - if (cookie[3] == 'I') { - if (cookie[4] == 'I') { - if (cookie[5] == '\0') { - // found: IDIII depth 9 - wasm_invoke_idiii(target_func, margs); - return; - } - } - } - } - } - else if (cookie[1] == 'F') { - if (cookie[2] == 'F') { if (cookie[3] == 'F') { if (cookie[4] == 'F') { if (cookie[5] == 'F') { - if (cookie[6] == 'F') { - if (cookie[7] == 'I') { - if (cookie[8] == '\0') { - // found: IFFFFFFI depth 13 - wasm_invoke_iffffffi(target_func, margs); - return; - } - } - } - } - } - } - else if (cookie[3] == 'I') { - if (cookie[4] == 'I') { - if (cookie[5] == '\0') { - // found: IFFII depth 11 - wasm_invoke_iffii(target_func, margs); - return; - } - } - } - } - } - else if (cookie[1] == 'I') { - if (cookie[2] == '\0') { - // found: II depth 8 - wasm_invoke_ii(target_func, margs); - return; - } - else if (cookie[2] == 'F') { - if (cookie[3] == '\0') { - // found: IIF depth 10 - wasm_invoke_iif(target_func, margs); - return; - } - else if (cookie[3] == 'F') { - if (cookie[4] == '\0') { - // found: IIFF depth 12 - wasm_invoke_iiff(target_func, margs); - return; - } - else if (cookie[4] == 'F') { - if (cookie[5] == '\0') { - // found: IIFFF depth 14 - wasm_invoke_iifff(target_func, margs); - return; - } - else if (cookie[5] == 'F') { if (cookie[6] == 'F') { if (cookie[7] == 'F') { - if (cookie[8] == '\0') { - // found: IIFFFFFF depth 18 - wasm_invoke_iiffffff(target_func, margs); - return; - } - else if (cookie[8] == 'F') { + if (cookie[8] == 'F') { if (cookie[9] == 'F') { - if (cookie[10] == '\0') { - // found: IIFFFFFFFF depth 21 - wasm_invoke_iiffffffff(target_func, margs); - return; + if (cookie[10] == 'F') { + if (cookie[11] == 'I') { + if (cookie[12] == 'I') { + if (cookie[13] == 'I') { + if (cookie[14] == '\0') { + // found: IIIFFFFFFFFIII depth 15 + wasm_invoke_iiiffffffffiii (target_func, margs); + return; + } + } + } + } + else if (cookie[11] == '\0') { + // found: IIIFFFFFFFF depth 13 + wasm_invoke_iiiffffffff (target_func, margs); + return; + } } } + else if (cookie[9] == '\0') { + // found: IIIFFFFFF depth 11 + wasm_invoke_iiiffffff (target_func, margs); + return; + } } - } - } - else if (cookie[6] == 'I') { - if (cookie[7] == '\0') { - // found: IIFFFFI depth 18 - wasm_invoke_iiffffi(target_func, margs); - return; - } - else if (cookie[7] == 'I') { - if (cookie[8] == '\0') { - // found: IIFFFFII depth 20 - wasm_invoke_iiffffii(target_func, margs); + else if (cookie[8] == '\0') { + // found: IIIFFFFF depth 10 + wasm_invoke_iiifffff (target_func, margs); return; } } - } - } - else if (cookie[5] == 'I') { - if (cookie[6] == '\0') { - // found: IIFFFI depth 17 - wasm_invoke_iifffi(target_func, margs); - return; + else if (cookie[7] == '\0') { + // found: IIIFFFF depth 9 + wasm_invoke_iiiffff (target_func, margs); + return; + } } } } else if (cookie[4] == 'I') { - if (cookie[5] == '\0') { - // found: IIFFI depth 15 - wasm_invoke_iiffi(target_func, margs); - return; - } - else if (cookie[5] == 'I') { - if (cookie[6] == '\0') { - // found: IIFFII depth 17 - wasm_invoke_iiffii(target_func, margs); - return; - } - else if (cookie[6] == 'I') { + if (cookie[5] == 'I') { + if (cookie[6] == 'I') { if (cookie[7] == '\0') { - // found: IIFFIII depth 19 - wasm_invoke_iiffiii(target_func, margs); + // found: IIIFIII depth 9 + wasm_invoke_iiifiii (target_func, margs); return; } } - } - } - } - else if (cookie[3] == 'I') { - if (cookie[4] == '\0') { - // found: IIFI depth 13 - wasm_invoke_iifi(target_func, margs); - return; - } - else if (cookie[4] == 'I') { - if (cookie[5] == '\0') { - // found: IIFII depth 15 - wasm_invoke_iifii(target_func, margs); - return; - } - else if (cookie[5] == 'I') { - if (cookie[6] == '\0') { - // found: IIFIII depth 17 - wasm_invoke_iifiii(target_func, margs); + else if (cookie[6] == '\0') { + // found: IIIFII depth 9 + wasm_invoke_iiifii (target_func, margs); return; } } + else if (cookie[5] == '\0') { + // found: IIIFI depth 8 + wasm_invoke_iiifi (target_func, margs); + return; + } } - } - } - else if (cookie[2] == 'I') { - if (cookie[3] == '\0') { - // found: III depth 11 - wasm_invoke_iii(target_func, margs); - return; - } - else if (cookie[3] == 'F') { - if (cookie[4] == '\0') { - // found: IIIF depth 13 - wasm_invoke_iiif(target_func, margs); + else if (cookie[4] == '\0') { + // found: IIIF depth 7 + wasm_invoke_iiif (target_func, margs); return; } - else if (cookie[4] == 'F') { - if (cookie[5] == 'F') { - if (cookie[6] == 'F') { - if (cookie[7] == '\0') { - // found: IIIFFFF depth 17 - wasm_invoke_iiiffff(target_func, margs); - return; - } - else if (cookie[7] == 'F') { - if (cookie[8] == '\0') { - // found: IIIFFFFF depth 19 - wasm_invoke_iiifffff(target_func, margs); - return; - } - else if (cookie[8] == 'F') { - if (cookie[9] == '\0') { - // found: IIIFFFFFF depth 21 - wasm_invoke_iiiffffff(target_func, margs); - return; - } - else if (cookie[9] == 'F') { - if (cookie[10] == 'F') { - if (cookie[11] == '\0') { - // found: IIIFFFFFFFF depth 24 - wasm_invoke_iiiffffffff(target_func, margs); - return; - } - else if (cookie[11] == 'I') { + } + else if (cookie[3] == 'I') { + if (cookie[4] == 'I') { + if (cookie[5] == 'I') { + if (cookie[6] == 'I') { + if (cookie[7] == 'I') { + if (cookie[8] == 'I') { + if (cookie[9] == 'I') { + if (cookie[10] == 'I') { + if (cookie[11] == 'I') { if (cookie[12] == 'I') { if (cookie[13] == 'I') { if (cookie[14] == '\0') { - // found: IIIFFFFFFFFIII depth 28 - wasm_invoke_iiiffffffffiii(target_func, margs); + // found: IIIIIIIIIIIIII depth 16 + wasm_invoke_iiiiiiiiiiiiii (target_func, margs); return; } } + else if (cookie[13] == '\0') { + // found: IIIIIIIIIIIII depth 16 + wasm_invoke_iiiiiiiiiiiii (target_func, margs); + return; + } + } + else if (cookie[12] == '\0') { + // found: IIIIIIIIIIII depth 15 + wasm_invoke_iiiiiiiiiiii (target_func, margs); + return; } } + else if (cookie[11] == '\0') { + // found: IIIIIIIIIII depth 14 + wasm_invoke_iiiiiiiiiii (target_func, margs); + return; + } } + else if (cookie[10] == '\0') { + // found: IIIIIIIIII depth 13 + wasm_invoke_iiiiiiiiii (target_func, margs); + return; + } + } + else if (cookie[9] == '\0') { + // found: IIIIIIIII depth 12 + wasm_invoke_iiiiiiiii (target_func, margs); + return; } } + else if (cookie[8] == '\0') { + // found: IIIIIIII depth 11 + wasm_invoke_iiiiiiii (target_func, margs); + return; + } } - } - } - } - else if (cookie[4] == 'I') { - if (cookie[5] == '\0') { - // found: IIIFI depth 16 - wasm_invoke_iiifi(target_func, margs); - return; - } - else if (cookie[5] == 'I') { - if (cookie[6] == '\0') { - // found: IIIFII depth 18 - wasm_invoke_iiifii(target_func, margs); - return; - } - else if (cookie[6] == 'I') { - if (cookie[7] == '\0') { - // found: IIIFIII depth 20 - wasm_invoke_iiifiii(target_func, margs); - return; + else if (cookie[7] == 'F') { + if (cookie[8] == 'F') { + if (cookie[9] == '\0') { + // found: IIIIIIIFF depth 12 + wasm_invoke_iiiiiiiff (target_func, margs); + return; + } + } + else if (cookie[8] == '\0') { + // found: IIIIIIIF depth 12 + wasm_invoke_iiiiiiif (target_func, margs); + return; + } } - } - } - } - } - else if (cookie[3] == 'I') { - if (cookie[4] == '\0') { - // found: IIII depth 14 - wasm_invoke_iiii(target_func, margs); - return; - } - else if (cookie[4] == 'F') { - if (cookie[5] == '\0') { - // found: IIIIF depth 16 - wasm_invoke_iiiif(target_func, margs); - return; - } - else if (cookie[5] == 'I') { - if (cookie[6] == '\0') { - // found: IIIIFI depth 18 - wasm_invoke_iiiifi(target_func, margs); - return; - } - else if (cookie[6] == 'I') { - if (cookie[7] == '\0') { - // found: IIIIFII depth 20 - wasm_invoke_iiiifii(target_func, margs); + else if (cookie[7] == '\0') { + // found: IIIIIII depth 11 + wasm_invoke_iiiiiii (target_func, margs); return; } - else if (cookie[7] == 'I') { - if (cookie[8] == '\0') { - // found: IIIIFIII depth 22 - wasm_invoke_iiiifiii(target_func, margs); - return; + } + else if (cookie[6] == 'F') { + if (cookie[7] == 'I') { + if (cookie[8] == 'I') { + if (cookie[9] == '\0') { + // found: IIIIIIFII depth 12 + wasm_invoke_iiiiiifii (target_func, margs); + return; + } } } } - } - } - else if (cookie[4] == 'I') { - if (cookie[5] == '\0') { - // found: IIIII depth 17 - wasm_invoke_iiiii(target_func, margs); - return; + else if (cookie[6] == '\0') { + // found: IIIIII depth 10 + wasm_invoke_iiiiii (target_func, margs); + return; + } } else if (cookie[5] == 'F') { if (cookie[6] == 'F') { @@ -1252,8 +1061,8 @@ icall_trampoline_dispatch (const char *cookie, void *target_func, InterpMethodAr if (cookie[11] == 'I') { if (cookie[12] == 'I') { if (cookie[13] == '\0') { - // found: IIIIIFFFFIIII depth 26 - wasm_invoke_iiiiiffffiiii(target_func, margs); + // found: IIIIIFFFFIIII depth 16 + wasm_invoke_iiiiiffffiiii (target_func, margs); return; } } @@ -1264,338 +1073,528 @@ icall_trampoline_dispatch (const char *cookie, void *target_func, InterpMethodAr } } } - else if (cookie[5] == 'I') { - if (cookie[6] == '\0') { - // found: IIIIII depth 20 - wasm_invoke_iiiiii(target_func, margs); - return; - } - else if (cookie[6] == 'F') { + else if (cookie[5] == '\0') { + // found: IIIII depth 9 + wasm_invoke_iiiii (target_func, margs); + return; + } + } + else if (cookie[4] == 'F') { + if (cookie[5] == 'I') { + if (cookie[6] == 'I') { if (cookie[7] == 'I') { - if (cookie[8] == 'I') { - if (cookie[9] == '\0') { - // found: IIIIIIFII depth 24 - wasm_invoke_iiiiiifii(target_func, margs); - return; - } + if (cookie[8] == '\0') { + // found: IIIIFIII depth 11 + wasm_invoke_iiiifiii (target_func, margs); + return; } } - } - else if (cookie[6] == 'I') { - if (cookie[7] == '\0') { - // found: IIIIIII depth 23 - wasm_invoke_iiiiiii(target_func, margs); + else if (cookie[7] == '\0') { + // found: IIIIFII depth 11 + wasm_invoke_iiiifii (target_func, margs); return; } - else if (cookie[7] == 'F') { - if (cookie[8] == '\0') { - // found: IIIIIIIF depth 25 - wasm_invoke_iiiiiiif(target_func, margs); - return; - } - else if (cookie[8] == 'F') { - if (cookie[9] == '\0') { - // found: IIIIIIIFF depth 27 - wasm_invoke_iiiiiiiff(target_func, margs); - return; + } + else if (cookie[6] == '\0') { + // found: IIIIFI depth 10 + wasm_invoke_iiiifi (target_func, margs); + return; + } + } + else if (cookie[5] == '\0') { + // found: IIIIF depth 9 + wasm_invoke_iiiif (target_func, margs); + return; + } + } + else if (cookie[4] == '\0') { + // found: IIII depth 8 + wasm_invoke_iiii (target_func, margs); + return; + } + } + else if (cookie[3] == '\0') { + // found: III depth 6 + wasm_invoke_iii (target_func, margs); + return; + } + } + else if (cookie[2] == 'F') { + if (cookie[3] == 'F') { + if (cookie[4] == 'F') { + if (cookie[5] == 'F') { + if (cookie[6] == 'F') { + if (cookie[7] == 'F') { + if (cookie[8] == 'F') { + if (cookie[9] == 'F') { + if (cookie[10] == '\0') { + // found: IIFFFFFFFF depth 12 + wasm_invoke_iiffffffff (target_func, margs); + return; + } } } + else if (cookie[8] == '\0') { + // found: IIFFFFFF depth 11 + wasm_invoke_iiffffff (target_func, margs); + return; + } } - else if (cookie[7] == 'I') { + } + else if (cookie[6] == 'I') { + if (cookie[7] == 'I') { if (cookie[8] == '\0') { - // found: IIIIIIII depth 26 - wasm_invoke_iiiiiiii(target_func, margs); + // found: IIFFFFII depth 11 + wasm_invoke_iiffffii (target_func, margs); return; } - else if (cookie[8] == 'I') { - if (cookie[9] == '\0') { - // found: IIIIIIIII depth 28 - wasm_invoke_iiiiiiiii(target_func, margs); - return; - } - else if (cookie[9] == 'I') { - if (cookie[10] == '\0') { - // found: IIIIIIIIII depth 30 - wasm_invoke_iiiiiiiiii(target_func, margs); - return; - } - else if (cookie[10] == 'I') { - if (cookie[11] == '\0') { - // found: IIIIIIIIIII depth 32 - wasm_invoke_iiiiiiiiiii(target_func, margs); - return; - } - else if (cookie[11] == 'I') { - if (cookie[12] == '\0') { - // found: IIIIIIIIIIII depth 34 - wasm_invoke_iiiiiiiiiiii(target_func, margs); - return; - } - else if (cookie[12] == 'I') { - if (cookie[13] == '\0') { - // found: IIIIIIIIIIIII depth 36 - wasm_invoke_iiiiiiiiiiiii(target_func, margs); - return; - } - else if (cookie[13] == 'I') { - if (cookie[14] == '\0') { - // found: IIIIIIIIIIIIII depth 38 - wasm_invoke_iiiiiiiiiiiiii(target_func, margs); - return; - } - } - } - } - } - } - } } + else if (cookie[7] == '\0') { + // found: IIFFFFI depth 11 + wasm_invoke_iiffffi (target_func, margs); + return; + } + } + } + else if (cookie[5] == 'I') { + if (cookie[6] == '\0') { + // found: IIFFFI depth 9 + wasm_invoke_iifffi (target_func, margs); + return; } } + else if (cookie[5] == '\0') { + // found: IIFFF depth 9 + wasm_invoke_iifff (target_func, margs); + return; + } + } + else if (cookie[4] == 'I') { + if (cookie[5] == 'I') { + if (cookie[6] == 'I') { + if (cookie[7] == '\0') { + // found: IIFFIII depth 10 + wasm_invoke_iiffiii (target_func, margs); + return; + } + } + else if (cookie[6] == '\0') { + // found: IIFFII depth 10 + wasm_invoke_iiffii (target_func, margs); + return; + } + } + else if (cookie[5] == '\0') { + // found: IIFFI depth 9 + wasm_invoke_iiffi (target_func, margs); + return; + } + } + else if (cookie[4] == '\0') { + // found: IIFF depth 8 + wasm_invoke_iiff (target_func, margs); + return; } - } - } - else if (cookie[2] == 'L') { - if (cookie[3] == '\0') { - // found: IIL depth 12 - wasm_invoke_iil(target_func, margs); - return; } else if (cookie[3] == 'I') { - if (cookie[4] == '\0') { - // found: IILI depth 14 - wasm_invoke_iili(target_func, margs); + if (cookie[4] == 'I') { + if (cookie[5] == 'I') { + if (cookie[6] == '\0') { + // found: IIFIII depth 9 + wasm_invoke_iifiii (target_func, margs); + return; + } + } + else if (cookie[5] == '\0') { + // found: IIFII depth 9 + wasm_invoke_iifii (target_func, margs); + return; + } + } + else if (cookie[4] == '\0') { + // found: IIFI depth 8 + wasm_invoke_iifi (target_func, margs); return; } - else if (cookie[4] == 'I') { + } + else if (cookie[3] == '\0') { + // found: IIF depth 7 + wasm_invoke_iif (target_func, margs); + return; + } + } + else if (cookie[2] == 'L') { + if (cookie[3] == 'I') { + if (cookie[4] == 'I') { if (cookie[5] == 'I') { if (cookie[6] == 'I') { if (cookie[7] == '\0') { - // found: IILIIII depth 18 - wasm_invoke_iiliiii(target_func, margs); + // found: IILIIII depth 10 + wasm_invoke_iiliiii (target_func, margs); return; } } } } + else if (cookie[4] == '\0') { + // found: IILI depth 8 + wasm_invoke_iili (target_func, margs); + return; + } } else if (cookie[3] == 'L') { if (cookie[4] == 'L') { if (cookie[5] == 'I') { if (cookie[6] == '\0') { - // found: IILLLI depth 17 - wasm_invoke_iillli(target_func, margs); + // found: IILLLI depth 10 + wasm_invoke_iillli (target_func, margs); return; } } } } - } - } - else if (cookie[1] == 'L') { - if (cookie[2] == 'I') { - if (cookie[3] == '\0') { - // found: ILI depth 10 - wasm_invoke_ili(target_func, margs); + else if (cookie[3] == '\0') { + // found: IIL depth 8 + wasm_invoke_iil (target_func, margs); return; } } - } - } - else if (cookie[0] == 'L') { - if (cookie[1] == '\0') { - // found: L depth 5 - wasm_invoke_l(target_func, margs); - return; - } - else if (cookie[1] == 'I') { - if (cookie[2] == '\0') { - // found: LI depth 7 - wasm_invoke_li(target_func, margs); + else if (cookie[2] == '\0') { + // found: II depth 6 + wasm_invoke_ii (target_func, margs); return; } - else if (cookie[2] == 'I') { - if (cookie[3] == '\0') { - // found: LII depth 9 - wasm_invoke_lii(target_func, margs); - return; - } - } - else if (cookie[2] == 'L') { - if (cookie[3] == '\0') { - // found: LIL depth 10 - wasm_invoke_lil(target_func, margs); - return; + } + else if (cookie[1] == 'F') { + if (cookie[2] == 'F') { + if (cookie[3] == 'F') { + if (cookie[4] == 'F') { + if (cookie[5] == 'F') { + if (cookie[6] == 'F') { + if (cookie[7] == 'I') { + if (cookie[8] == '\0') { + // found: IFFFFFFI depth 10 + wasm_invoke_iffffffi (target_func, margs); + return; + } + } + } + } + } } else if (cookie[3] == 'I') { if (cookie[4] == 'I') { if (cookie[5] == '\0') { - // found: LILII depth 13 - wasm_invoke_lilii(target_func, margs); + // found: IFFII depth 8 + wasm_invoke_iffii (target_func, margs); return; } } } - else if (cookie[3] == 'L') { - if (cookie[4] == '\0') { - // found: LILL depth 13 - wasm_invoke_lill(target_func, margs); - return; + } + } + else if (cookie[1] == 'D') { + if (cookie[2] == 'I') { + if (cookie[3] == 'I') { + if (cookie[4] == 'I') { + if (cookie[5] == '\0') { + // found: IDIII depth 8 + wasm_invoke_idiii (target_func, margs); + return; + } } } } } else if (cookie[1] == 'L') { - if (cookie[2] == '\0') { - // found: LL depth 8 - wasm_invoke_ll(target_func, margs); - return; - } - } - } - else if (cookie[0] == 'V') { - if (cookie[1] == '\0') { - // found: V depth 6 - wasm_invoke_v(target_func, margs); - return; - } - else if (cookie[1] == 'I') { - if (cookie[2] == '\0') { - // found: VI depth 8 - wasm_invoke_vi(target_func, margs); - return; - } - else if (cookie[2] == 'D') { + if (cookie[2] == 'I') { if (cookie[3] == '\0') { - // found: VID depth 10 - wasm_invoke_vid(target_func, margs); + // found: ILI depth 7 + wasm_invoke_ili (target_func, margs); return; } } - else if (cookie[2] == 'F') { - if (cookie[3] == '\0') { - // found: VIF depth 11 - wasm_invoke_vif(target_func, margs); - return; - } - else if (cookie[3] == 'F') { - if (cookie[4] == '\0') { - // found: VIFF depth 13 - wasm_invoke_viff(target_func, margs); - return; - } - else if (cookie[4] == 'F') { - if (cookie[5] == 'F') { - if (cookie[6] == '\0') { - // found: VIFFFF depth 16 - wasm_invoke_viffff(target_func, margs); - return; - } - else if (cookie[6] == 'F') { + } + else if (cookie[1] == '\0') { + // found: I depth 6 + wasm_invoke_i (target_func, margs); + return; + } + } + else if (cookie[0] == 'V') { + if (cookie[1] == 'I') { + if (cookie[2] == 'I') { + if (cookie[3] == 'I') { + if (cookie[4] == 'I') { + if (cookie[5] == 'I') { + if (cookie[6] == 'I') { if (cookie[7] == 'I') { - if (cookie[8] == '\0') { - // found: VIFFFFFI depth 19 - wasm_invoke_vifffffi(target_func, margs); + if (cookie[8] == 'I') { + if (cookie[9] == 'I') { + if (cookie[10] == 'I') { + if (cookie[11] == '\0') { + // found: VIIIIIIIIII depth 13 + wasm_invoke_viiiiiiiiii (target_func, margs); + return; + } + } + else if (cookie[10] == '\0') { + // found: VIIIIIIIII depth 13 + wasm_invoke_viiiiiiiii (target_func, margs); + return; + } + } + else if (cookie[9] == '\0') { + // found: VIIIIIIII depth 12 + wasm_invoke_viiiiiiii (target_func, margs); + return; + } + } + else if (cookie[8] == '\0') { + // found: VIIIIIII depth 11 + wasm_invoke_viiiiiii (target_func, margs); return; } } + else if (cookie[7] == '\0') { + // found: VIIIIII depth 10 + wasm_invoke_viiiiii (target_func, margs); + return; + } + } + else if (cookie[6] == '\0') { + // found: VIIIII depth 9 + wasm_invoke_viiiii (target_func, margs); + return; } } + else if (cookie[5] == '\0') { + // found: VIIII depth 8 + wasm_invoke_viiii (target_func, margs); + return; + } + } + else if (cookie[4] == '\0') { + // found: VIII depth 7 + wasm_invoke_viii (target_func, margs); + return; } - } - } - else if (cookie[2] == 'I') { - if (cookie[3] == '\0') { - // found: VII depth 12 - wasm_invoke_vii(target_func, margs); - return; } else if (cookie[3] == 'F') { if (cookie[4] == 'F') { if (cookie[5] == 'I') { if (cookie[6] == '\0') { - // found: VIIFFI depth 16 - wasm_invoke_viiffi(target_func, margs); + // found: VIIFFI depth 9 + wasm_invoke_viiffi (target_func, margs); return; } } } } - else if (cookie[3] == 'I') { - if (cookie[4] == '\0') { - // found: VIII depth 15 - wasm_invoke_viii(target_func, margs); - return; - } - else if (cookie[4] == 'I') { - if (cookie[5] == '\0') { - // found: VIIII depth 17 - wasm_invoke_viiii(target_func, margs); - return; - } - else if (cookie[5] == 'I') { - if (cookie[6] == '\0') { - // found: VIIIII depth 19 - wasm_invoke_viiiii(target_func, margs); - return; - } - else if (cookie[6] == 'I') { - if (cookie[7] == '\0') { - // found: VIIIIII depth 21 - wasm_invoke_viiiiii(target_func, margs); - return; - } - else if (cookie[7] == 'I') { + else if (cookie[3] == '\0') { + // found: VII depth 7 + wasm_invoke_vii (target_func, margs); + return; + } + } + else if (cookie[2] == 'F') { + if (cookie[3] == 'F') { + if (cookie[4] == 'F') { + if (cookie[5] == 'F') { + if (cookie[6] == 'F') { + if (cookie[7] == 'I') { if (cookie[8] == '\0') { - // found: VIIIIIII depth 23 - wasm_invoke_viiiiiii(target_func, margs); + // found: VIFFFFFI depth 11 + wasm_invoke_vifffffi (target_func, margs); return; } - else if (cookie[8] == 'I') { - if (cookie[9] == '\0') { - // found: VIIIIIIII depth 25 - wasm_invoke_viiiiiiii(target_func, margs); - return; - } - else if (cookie[9] == 'I') { - if (cookie[10] == '\0') { - // found: VIIIIIIIII depth 27 - wasm_invoke_viiiiiiiii(target_func, margs); - return; - } - else if (cookie[10] == 'I') { - if (cookie[11] == '\0') { - // found: VIIIIIIIIII depth 29 - wasm_invoke_viiiiiiiiii(target_func, margs); - return; - } - } - } - } } } + else if (cookie[6] == '\0') { + // found: VIFFFF depth 10 + wasm_invoke_viffff (target_func, margs); + return; + } } } + else if (cookie[4] == '\0') { + // found: VIFF depth 8 + wasm_invoke_viff (target_func, margs); + return; + } + } + else if (cookie[3] == '\0') { + // found: VIF depth 7 + wasm_invoke_vif (target_func, margs); + return; } } else if (cookie[2] == 'L') { + if (cookie[3] == 'L') { + if (cookie[4] == 'I') { + if (cookie[5] == '\0') { + // found: VILLI depth 9 + wasm_invoke_villi (target_func, margs); + return; + } + } + } + else if (cookie[3] == '\0') { + // found: VIL depth 8 + wasm_invoke_vil (target_func, margs); + return; + } + } + else if (cookie[2] == 'D') { if (cookie[3] == '\0') { - // found: VIL depth 13 - wasm_invoke_vil(target_func, margs); + // found: VID depth 8 + wasm_invoke_vid (target_func, margs); return; } - else if (cookie[3] == 'L') { + } + else if (cookie[2] == '\0') { + // found: VI depth 8 + wasm_invoke_vi (target_func, margs); + return; + } + } + else if (cookie[1] == '\0') { + // found: V depth 4 + wasm_invoke_v (target_func, margs); + return; + } + } + else if (cookie[0] == 'L') { + if (cookie[1] == 'I') { + if (cookie[2] == 'L') { + if (cookie[3] == 'I') { if (cookie[4] == 'I') { if (cookie[5] == '\0') { - // found: VILLI depth 16 - wasm_invoke_villi(target_func, margs); + // found: LILII depth 8 + wasm_invoke_lilii (target_func, margs); return; } } } + else if (cookie[3] == 'L') { + if (cookie[4] == '\0') { + // found: LILL depth 8 + wasm_invoke_lill (target_func, margs); + return; + } + } + else if (cookie[3] == '\0') { + // found: LIL depth 8 + wasm_invoke_lil (target_func, margs); + return; + } + } + else if (cookie[2] == 'I') { + if (cookie[3] == '\0') { + // found: LII depth 7 + wasm_invoke_lii (target_func, margs); + return; + } + } + else if (cookie[2] == '\0') { + // found: LI depth 7 + wasm_invoke_li (target_func, margs); + return; + } + } + else if (cookie[1] == 'L') { + if (cookie[2] == '\0') { + // found: LL depth 6 + wasm_invoke_ll (target_func, margs); + return; + } + } + else if (cookie[1] == '\0') { + // found: L depth 6 + wasm_invoke_l (target_func, margs); + return; + } + } + else if (cookie[0] == 'D') { + if (cookie[1] == 'I') { + if (cookie[2] == 'D') { + if (cookie[3] == 'D') { + if (cookie[4] == '\0') { + // found: DIDD depth 8 + wasm_invoke_didd (target_func, margs); + return; + } + } + else if (cookie[3] == '\0') { + // found: DID depth 8 + wasm_invoke_did (target_func, margs); + return; + } + } + else if (cookie[2] == '\0') { + // found: DI depth 7 + wasm_invoke_di (target_func, margs); + return; + } + } + else if (cookie[1] == 'D') { + if (cookie[2] == 'D') { + if (cookie[3] == '\0') { + // found: DDD depth 8 + wasm_invoke_ddd (target_func, margs); + return; + } + } + else if (cookie[2] == 'I') { + if (cookie[3] == '\0') { + // found: DDI depth 9 + wasm_invoke_ddi (target_func, margs); + return; + } + } + else if (cookie[2] == '\0') { + // found: DD depth 9 + wasm_invoke_dd (target_func, margs); + return; + } + } + } + else if (cookie[0] == 'F') { + if (cookie[1] == 'I') { + if (cookie[2] == 'F') { + if (cookie[3] == 'F') { + if (cookie[4] == '\0') { + // found: FIFF depth 9 + wasm_invoke_fiff (target_func, margs); + return; + } + } + else if (cookie[3] == '\0') { + // found: FIF depth 9 + wasm_invoke_fif (target_func, margs); + return; + } + } + else if (cookie[2] == '\0') { + // found: FI depth 8 + wasm_invoke_fi (target_func, margs); + return; + } + } + else if (cookie[1] == 'F') { + if (cookie[2] == 'F') { + if (cookie[3] == '\0') { + // found: FFF depth 9 + wasm_invoke_fff (target_func, margs); + return; + } + } + else if (cookie[2] == '\0') { + // found: FF depth 9 + wasm_invoke_ff (target_func, margs); + return; } } } - printf ("CANNOT HANDLE COOKIE %s\n", cookie); - g_assert (0); + g_error ("CANNOT HANDLE COOKIE %s\n", cookie); }