@@ -13,7 +13,10 @@ require dastest/testing_boost
1313let OUTPUT_DIR = "{ get_das_root ()} /build/tests"
1414let PROBE_PATH = "{ OUTPUT_DIR } /dll_cache_probe.das"
1515
16- def write_probe (body_expr : string) : bool {
16+ def write_probe (table_value : int) : bool {
17+ // Probe uses table[k] so jit_table_at_tString lands in the emitted globals,
18+ // exercising the codegen path that #2802 fixed (DLLExport linkage on the
19+ // table accessor slots so ResolveExternVisitor can fix them up on reload).
1720 mkdir_rec (OUTPUT_DIR )
1821 var ok = false
1922 fopen (PROBE_PATH , "w" ) $ (f) {
@@ -22,7 +25,9 @@ def write_probe(body_expr : string) : bool {
2225 fprint (f , "require daslib/just_in_time\n\n " )
2326 fprint (f , "[jit, sideeffects, export]\n " )
2427 fprint (f , "def probe(x : int) : int \{\n " )
25- fprint (f , " return { body_expr } \n " )
28+ fprint (f , " var tab : table<string; int>\n " )
29+ fprint (f , " tab[\" a\" ] = { table_value } \n " )
30+ fprint (f , " return x + tab[\" a\" ]\n " )
2631 fprint (f , "\}\n " )
2732 fprint (f , "\n [export]\n def main() \{\n let _ = probe(0)\n\}\n " )
2833 ok = true
@@ -62,20 +67,15 @@ def list_dlls(subdir : string) : array<string> {
6267
6368def clear_subdir (subdir : string) {
6469 dir (subdir ) $ (fname) {
65- if (fname == "." || fname == ".." ) {
66- return
67- }
70+ return if (fname == "." || fname == ".." )
6871 var err : string
6972 remove ("{ subdir } /{ fname } " , err )
7073 }
7174}
7275
7376def test_dll_cache (t : T?) {
74- if (! jit_enabled () || ! das_is_dll_build ()) {
75- return
76- }
77- // first compile seeds the namespace so we can locate the per-script subdir
78- t | > equal (write_probe ("x + 1" ), true )
77+ return if (! jit_enabled () || ! das_is_dll_build ())
78+ t | > equal (write_probe (1 ), true )
7979 let ns = compile_probe ()
8080 t | > equal (empty (ns ), false )
8181 let subdir = ".jitted_scripts/{ ns } "
@@ -94,7 +94,7 @@ def test_dll_cache(t : T?) {
9494 t | > strictEqual (dlls2 [0 ], first_dll , "cache hit keeps same DLL filename" )
9595
9696 // compile 3 with different body: miss, new DLL, old artifacts GC'd
97- t | > equal (write_probe ("x + 2" ), true )
97+ t | > equal (write_probe (2 ), true )
9898 compile_probe ()
9999 let dlls3 < - list_dlls (subdir )
100100 t | > equal (length (dlls3 ), 1 )
0 commit comments