Merge branch 'native_boot'

This commit is contained in:
2026-02-22 20:48:19 -06:00
19 changed files with 59808 additions and 22461 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -161,7 +161,7 @@
["lt", 2, 4, 6, 67, 25],
["jump_false", 2, "while_end_26", 67, 25],
["load_field", 2, 1, "list", 68, 22],
["load_index", 6, 2, 4, 68, 32],
["load_dynamic", 6, 2, 4, 68, 32],
["get", 2, 13, 1, 68, 14],
["frame", 7, 2, 1, 68, 14],
["setarg", 7, 1, 6, 68, 14],
@@ -192,12 +192,12 @@
["lt", 2, 4, 6, 75, 25],
["jump_false", 2, "while_end_32", 75, 25],
["load_field", 2, 1, "list", 76, 13],
["load_index", 6, 2, 4, 76, 23],
["load_dynamic", 6, 2, 4, 76, 23],
["load_field", 2, 6, "computed", 76, 23],
["move", 6, 2, 76, 23],
["wary_false", 2, "and_end_35", 76, 23],
["load_field", 2, 1, "list", 76, 47],
["load_index", 7, 2, 4, 76, 57],
["load_dynamic", 7, 2, 4, 76, 57],
["load_field", 2, 7, "left", 76, 57],
["get", 7, 13, 1, 76, 39],
["frame", 8, 7, 1, 76, 39],
@@ -213,7 +213,7 @@
"if_else_33",
"if_end_34",
["load_field", 2, 1, "list", 77, 22],
["load_index", 6, 2, 4, 77, 32],
["load_dynamic", 6, 2, 4, 77, 32],
["load_field", 2, 6, "right", 77, 32],
["get", 6, 13, 1, 77, 14],
["frame", 7, 6, 1, 77, 14],
@@ -335,7 +335,7 @@
["lt", 2, 4, 3, 92, 27],
["jump_false", 2, "while_end_55", 92, 27],
["load_field", 2, 1, "list", 93, 24],
["load_index", 3, 2, 4, 93, 34],
["load_dynamic", 3, 2, 4, 93, 34],
["get", 2, 13, 1, 93, 16],
["frame", 5, 2, 1, 93, 16],
["setarg", 5, 1, 3, 93, 16],
@@ -621,12 +621,12 @@
["lt", 4, 2, 3, 149, 16],
["jump_false", 4, "while_end_74", 149, 16],
["get", 3, 3, 1, 150, 11],
["load_index", 4, 3, 2, 150, 18],
["load_dynamic", 4, 3, 2, 150, 18],
["load_field", 3, 4, "function_nr", 150, 18],
["eq", 4, 3, 1, 150, 36],
["jump_false", 4, "if_else_75", 150, 36],
["get", 3, 3, 1, 150, 50],
["load_index", 4, 3, 2, 150, 57],
["load_dynamic", 4, 3, 2, 150, 57],
["return", 4, 150, 57],
"_nop_ur_1",
"if_else_75",
@@ -871,7 +871,7 @@
["length", 11, 1, 211, 23],
["lt", 12, 3, 11, 211, 23],
["jump_false", 12, "while_end_92", 211, 23],
["load_index", 11, 1, 3, 212, 20],
["load_dynamic", 11, 1, 3, 212, 20],
["move", 5, 11, 212, 20],
["load_field", 12, 11, "kind", 213, 14],
["move", 6, 12, 213, 14],
@@ -1097,7 +1097,7 @@
["lt", 11, 4, 12, 249, 27],
["jump_false", 11, "while_end_132", 249, 27],
["load_field", 11, 5, "list", 250, 18],
["load_index", 12, 11, 4, 250, 28],
["load_dynamic", 12, 11, 4, 250, 28],
["move", 9, 12, 250, 28],
["load_field", 11, 12, "kind", 251, 15],
["access", 12, "var", 251, 28],
@@ -1290,7 +1290,7 @@
["lt", 2, 4, 5, 282, 25],
["jump_false", 2, "while_end_161", 282, 25],
["load_field", 2, 1, "list", 283, 27],
["load_index", 5, 2, 4, 283, 37],
["load_dynamic", 5, 2, 4, 283, 37],
["get", 2, 28, 1, 283, 9],
["frame", 6, 2, 1, 283, 9],
["setarg", 6, 1, 5, 283, 9],
@@ -1312,11 +1312,11 @@
["lt", 2, 4, 3, 289, 25],
["jump_false", 2, "while_end_165", 289, 25],
["load_field", 2, 1, "list", 290, 13],
["load_index", 3, 2, 4, 290, 23],
["load_dynamic", 3, 2, 4, 290, 23],
["load_field", 2, 3, "computed", 290, 23],
["wary_false", 2, "if_else_166", 290, 23],
["load_field", 2, 1, "list", 290, 54],
["load_index", 3, 2, 4, 290, 64],
["load_dynamic", 3, 2, 4, 290, 64],
["load_field", 2, 3, "left", 290, 64],
["get", 3, 28, 1, 290, 36],
["frame", 5, 3, 1, 290, 36],
@@ -1326,7 +1326,7 @@
"if_else_166",
"if_end_167",
["load_field", 2, 1, "list", 291, 27],
["load_index", 3, 2, 4, 291, 37],
["load_dynamic", 3, 2, 4, 291, 37],
["load_field", 2, 3, "right", 291, 37],
["get", 3, 28, 1, 291, 9],
["frame", 5, 3, 1, 291, 9],
@@ -1361,7 +1361,7 @@
["length", 7, 1, 303, 23],
["lt", 8, 3, 7, 303, 23],
["jump_false", 8, "while_end_169", 303, 23],
["load_index", 7, 1, 3, 304, 20],
["load_dynamic", 7, 1, 3, 304, 20],
["move", 5, 7, 304, 20],
["load_field", 8, 7, "kind", 305, 14],
["move", 6, 8, 305, 14],
@@ -1391,7 +1391,7 @@
["lt", 7, 4, 8, 310, 27],
["jump_false", 7, "while_end_176", 310, 27],
["load_field", 7, 5, "list", 311, 29],
["load_index", 8, 7, 4, 311, 39],
["load_dynamic", 8, 7, 4, 311, 39],
["load_field", 7, 8, "right", 311, 39],
["get", 8, 28, 1, 311, 11],
["frame", 9, 8, 1, 311, 11],
@@ -1804,14 +1804,14 @@
["lt", 3, 10, 20, 404, 25],
["jump_false", 3, "while_end_224", 404, 25],
["load_field", 3, 1, "list", 405, 34],
["load_index", 20, 3, 10, 405, 44],
["load_dynamic", 20, 3, 10, 405, 44],
["get", 3, 31, 1, 405, 24],
["frame", 21, 3, 2, 405, 24],
["setarg", 21, 1, 20, 405, 24],
["setarg", 21, 2, 2, 405, 24],
["invoke", 21, 3, 405, 24],
["load_field", 20, 1, "list", 405, 9],
["store_index", 20, 3, 10, 405, 19],
["store_dynamic", 20, 3, 10, 405, 19],
["access", 3, 1, 406, 17],
["add", 10, 10, 3, 406, 17],
["jump", "while_start_223", 406, 17],
@@ -1834,14 +1834,14 @@
["lt", 3, 10, 20, 410, 25],
["jump_false", 3, "while_end_229", 410, 25],
["load_field", 3, 1, "list", 411, 34],
["load_index", 20, 3, 10, 411, 44],
["load_dynamic", 20, 3, 10, 411, 44],
["get", 3, 31, 1, 411, 24],
["frame", 21, 3, 2, 411, 24],
["setarg", 21, 1, 20, 411, 24],
["setarg", 21, 2, 2, 411, 24],
["invoke", 21, 3, 411, 24],
["load_field", 20, 1, "list", 411, 9],
["store_index", 20, 3, 10, 411, 19],
["store_dynamic", 20, 3, 10, 411, 19],
["access", 3, 1, 412, 17],
["add", 10, 10, 3, 412, 17],
["jump", "while_start_228", 412, 17],
@@ -1858,11 +1858,11 @@
["lt", 3, 10, 20, 416, 25],
["jump_false", 3, "while_end_233", 416, 25],
["load_field", 3, 1, "list", 417, 13],
["load_index", 20, 3, 10, 417, 23],
["load_dynamic", 20, 3, 10, 417, 23],
["load_field", 3, 20, "computed", 417, 23],
["wary_false", 3, "if_else_234", 417, 23],
["load_field", 3, 1, "list", 418, 41],
["load_index", 20, 3, 10, 418, 51],
["load_dynamic", 20, 3, 10, 418, 51],
["load_field", 3, 20, "left", 418, 51],
["get", 20, 31, 1, 418, 31],
["frame", 21, 20, 2, 418, 31],
@@ -1870,13 +1870,13 @@
["setarg", 21, 2, 2, 418, 31],
["invoke", 21, 3, 418, 31],
["load_field", 20, 1, "list", 418, 11],
["load_index", 21, 20, 10, 418, 21],
["load_dynamic", 21, 20, 10, 418, 21],
["store_field", 21, 3, "left", 418, 21],
["jump", "if_end_235", 418, 21],
"if_else_234",
"if_end_235",
["load_field", 3, 1, "list", 420, 40],
["load_index", 20, 3, 10, 420, 50],
["load_dynamic", 20, 3, 10, 420, 50],
["load_field", 3, 20, "right", 420, 50],
["get", 20, 31, 1, 420, 30],
["frame", 21, 20, 2, 420, 30],
@@ -1884,7 +1884,7 @@
["setarg", 21, 2, 2, 420, 30],
["invoke", 21, 3, 420, 30],
["load_field", 20, 1, "list", 420, 9],
["load_index", 21, 20, 10, 420, 19],
["load_dynamic", 21, 20, 10, 420, 19],
["store_field", 21, 3, "right", 420, 19],
["access", 3, 1, 421, 17],
["add", 10, 10, 3, 421, 17],
@@ -3271,14 +3271,14 @@
["lt", 3, 5, 8, 613, 25],
["jump_false", 3, "while_end_440", 613, 25],
["load_field", 3, 1, "list", 614, 34],
["load_index", 8, 3, 5, 614, 44],
["load_dynamic", 8, 3, 5, 614, 44],
["get", 3, 32, 1, 614, 24],
["frame", 9, 3, 2, 614, 24],
["setarg", 9, 1, 8, 614, 24],
["setarg", 9, 2, 2, 614, 24],
["invoke", 9, 3, 614, 24],
["load_field", 8, 1, "list", 614, 9],
["store_index", 8, 3, 5, 614, 19],
["store_dynamic", 8, 3, 5, 614, 19],
["access", 3, 1, 615, 17],
["add", 5, 5, 3, 615, 17],
["jump", "while_start_439", 615, 17],
@@ -3670,7 +3670,7 @@
["length", 8, 1, 699, 23],
["lt", 9, 3, 8, 699, 23],
["jump_false", 9, "while_end_485", 699, 23],
["load_index", 8, 1, 3, 700, 30],
["load_dynamic", 8, 1, 3, 700, 30],
["get", 9, 32, 1, 700, 14],
["frame", 10, 9, 2, 700, 14],
["setarg", 10, 1, 8, 700, 14],
@@ -4203,13 +4203,13 @@
["lt", 4, 2, 5, 766, 23],
["jump_false", 4, "while_end_533", 766, 23],
["load_field", 4, 1, "list", 767, 11],
["load_index", 5, 4, 2, 767, 21],
["load_dynamic", 5, 4, 2, 767, 21],
["load_field", 4, 5, "expression", 767, 21],
["null", 5, 767, 38],
["ne", 6, 4, 5, 767, 38],
["jump_false", 6, "if_else_534", 767, 38],
["load_field", 4, 1, "list", 768, 45],
["load_index", 5, 4, 2, 768, 55],
["load_dynamic", 5, 4, 2, 768, 55],
["load_field", 4, 5, "expression", 768, 55],
["get", 5, 31, 1, 768, 35],
["frame", 6, 5, 2, 768, 35],
@@ -4217,7 +4217,7 @@
["setarg", 6, 2, 3, 768, 35],
["invoke", 6, 4, 768, 35],
["load_field", 5, 1, "list", 768, 9],
["load_index", 6, 5, 2, 768, 19],
["load_dynamic", 6, 5, 2, 768, 19],
["store_field", 6, 4, "expression", 768, 19],
["jump", "if_end_535", 768, 19],
"if_else_534",
@@ -4322,11 +4322,11 @@
["length", 8, 4, 826, 26],
["lt", 9, 6, 8, 826, 26],
["jump_false", 9, "while_end_562", 826, 26],
["load_index", 8, 4, 6, 827, 18],
["load_dynamic", 8, 4, 6, 827, 18],
["access", 9, "function_nr", 827, 25],
["ne", 10, 8, 9, 827, 25],
["jump_false", 10, "if_else_563", 827, 25],
["load_index", 8, 4, 6, 828, 25],
["load_dynamic", 8, 4, 6, 828, 25],
["load_dynamic", 9, 3, 8, 828, 25],
["move", 7, 9, 828, 25],
["null", 8, 829, 22],
@@ -4482,7 +4482,7 @@
["lt", 2, 4, 5, 860, 27],
["jump_false", 2, "while_end_588", 860, 27],
["load_field", 2, 1, "list", 861, 29],
["load_index", 5, 2, 4, 861, 39],
["load_dynamic", 5, 2, 4, 861, 39],
["get", 2, 4, 1, 861, 11],
["frame", 6, 2, 1, 861, 11],
["setarg", 6, 1, 5, 861, 11],
@@ -4504,11 +4504,11 @@
["lt", 2, 4, 3, 867, 27],
["jump_false", 2, "while_end_592", 867, 27],
["load_field", 2, 1, "list", 868, 15],
["load_index", 3, 2, 4, 868, 25],
["load_dynamic", 3, 2, 4, 868, 25],
["load_field", 2, 3, "computed", 868, 25],
["wary_false", 2, "if_else_593", 868, 25],
["load_field", 2, 1, "list", 868, 56],
["load_index", 3, 2, 4, 868, 66],
["load_dynamic", 3, 2, 4, 868, 66],
["load_field", 2, 3, "left", 868, 66],
["get", 3, 4, 1, 868, 38],
["frame", 5, 3, 1, 868, 38],
@@ -4518,7 +4518,7 @@
"if_else_593",
"if_end_594",
["load_field", 2, 1, "list", 869, 29],
["load_index", 3, 2, 4, 869, 39],
["load_dynamic", 3, 2, 4, 869, 39],
["load_field", 2, 3, "right", 869, 39],
["get", 3, 4, 1, 869, 11],
["frame", 5, 3, 1, 869, 11],
@@ -4561,7 +4561,7 @@
["length", 6, 1, 881, 25],
["lt", 7, 2, 6, 881, 25],
["jump_false", 7, "while_end_598", 881, 25],
["load_index", 6, 1, 2, 882, 22],
["load_dynamic", 6, 1, 2, 882, 22],
["move", 4, 6, 882, 22],
["load_field", 7, 6, "kind", 883, 13],
["move", 5, 7, 883, 13],
@@ -4610,7 +4610,7 @@
["lt", 6, 3, 7, 892, 29],
["jump_false", 6, "while_end_607", 892, 29],
["load_field", 6, 4, "list", 893, 31],
["load_index", 7, 6, 3, 893, 41],
["load_dynamic", 7, 6, 3, 893, 41],
["load_field", 6, 7, "right", 893, 41],
["get", 7, 4, 1, 893, 13],
["frame", 8, 7, 1, 893, 13],
@@ -4936,7 +4936,7 @@
["lt", 2, 4, 5, 950, 27],
["jump_false", 2, "while_end_655", 950, 27],
["load_field", 2, 1, "list", 951, 35],
["load_index", 5, 2, 4, 951, 45],
["load_dynamic", 5, 2, 4, 951, 45],
["get", 2, 7, 1, 951, 11],
["frame", 6, 2, 1, 951, 11],
["setarg", 6, 1, 5, 951, 11],
@@ -4958,11 +4958,11 @@
["lt", 2, 4, 5, 957, 27],
["jump_false", 2, "while_end_659", 957, 27],
["load_field", 2, 1, "list", 958, 15],
["load_index", 5, 2, 4, 958, 25],
["load_dynamic", 5, 2, 4, 958, 25],
["load_field", 2, 5, "computed", 958, 25],
["wary_false", 2, "if_else_660", 958, 25],
["load_field", 2, 1, "list", 958, 62],
["load_index", 5, 2, 4, 958, 72],
["load_dynamic", 5, 2, 4, 958, 72],
["load_field", 2, 5, "left", 958, 72],
["get", 5, 7, 1, 958, 38],
["frame", 6, 5, 1, 958, 38],
@@ -4972,7 +4972,7 @@
"if_else_660",
"if_end_661",
["load_field", 2, 1, "list", 959, 35],
["load_index", 5, 2, 4, 959, 45],
["load_dynamic", 5, 2, 4, 959, 45],
["load_field", 2, 5, "right", 959, 45],
["get", 5, 7, 1, 959, 11],
["frame", 6, 5, 1, 959, 11],
@@ -5005,13 +5005,13 @@
["lt", 2, 4, 3, 967, 27],
["jump_false", 2, "while_end_665", 967, 27],
["load_field", 2, 1, "list", 968, 15],
["load_index", 3, 2, 4, 968, 25],
["load_dynamic", 3, 2, 4, 968, 25],
["load_field", 2, 3, "expression", 968, 25],
["null", 3, 968, 42],
["ne", 5, 2, 3, 968, 42],
["jump_false", 5, "if_else_666", 968, 42],
["load_field", 2, 1, "list", 969, 37],
["load_index", 3, 2, 4, 969, 47],
["load_dynamic", 3, 2, 4, 969, 47],
["load_field", 2, 3, "expression", 969, 47],
["get", 3, 7, 1, 969, 13],
["frame", 5, 3, 1, 969, 13],
@@ -5058,7 +5058,7 @@
["length", 7, 1, 983, 25],
["lt", 8, 2, 7, 983, 25],
["jump_false", 8, "while_end_671", 983, 25],
["load_index", 7, 1, 2, 984, 22],
["load_dynamic", 7, 1, 2, 984, 22],
["move", 5, 7, 984, 22],
["load_field", 8, 7, "kind", 985, 13],
["move", 6, 8, 985, 13],
@@ -5088,7 +5088,7 @@
["lt", 7, 3, 8, 990, 29],
["jump_false", 7, "while_end_678", 990, 29],
["load_field", 7, 5, "list", 991, 37],
["load_index", 8, 7, 3, 991, 47],
["load_dynamic", 8, 7, 3, 991, 47],
["load_field", 7, 8, "right", 991, 47],
["get", 8, 7, 1, 991, 13],
["frame", 9, 8, 1, 991, 13],
@@ -5253,13 +5253,13 @@
["lt", 7, 4, 8, 1021, 30],
["jump_false", 7, "while_end_701", 1021, 30],
["load_field", 7, 5, "list", 1022, 17],
["load_index", 8, 7, 4, 1022, 27],
["load_dynamic", 8, 7, 4, 1022, 27],
["load_field", 7, 8, "expression", 1022, 27],
["null", 8, 1022, 45],
["ne", 9, 7, 8, 1022, 45],
["jump_false", 9, "if_else_702", 1022, 45],
["load_field", 7, 5, "list", 1023, 39],
["load_index", 8, 7, 4, 1023, 49],
["load_dynamic", 8, 7, 4, 1023, 49],
["load_field", 7, 8, "expression", 1023, 49],
["get", 8, 7, 1, 1023, 15],
["frame", 9, 8, 1, 1023, 15],
@@ -5344,7 +5344,7 @@
["lt", 10, 1, 9, 791, 16],
["jump_false", 10, "while_end_541", 791, 16],
["get", 9, 3, 1, 792, 12],
["load_index", 10, 9, 1, 792, 19],
["load_dynamic", 10, 9, 1, 792, 19],
["move", 2, 10, 792, 19],
[
"access",
@@ -5368,7 +5368,7 @@
["length", 9, 3, 797, 25],
["lt", 10, 4, 9, 797, 25],
["jump_false", 10, "while_end_543", 797, 25],
["load_index", 9, 3, 4, 798, 20],
["load_dynamic", 9, 3, 4, 798, 20],
["move", 5, 9, 798, 20],
["access", 10, "function_nr", 799, 20],
["ne", 11, 9, 10, 799, 20],
@@ -5477,14 +5477,14 @@
["jump_false", 10, "while_end_711", 1041, 23],
["get", 8, 1, 1, 1042, 27],
["load_field", 10, 8, "intrinsics", 1042, 27],
["load_index", 8, 10, 1, 1042, 42],
["load_dynamic", 8, 10, 1, 1042, 42],
["load_dynamic", 10, 6, 8, 1042, 42],
["true", 8, 1042, 49],
["eq", 11, 10, 8, 1042, 49],
["jump_false", 11, "if_else_712", 1042, 49],
["get", 8, 1, 1, 1043, 30],
["load_field", 10, 8, "intrinsics", 1043, 30],
["load_index", 8, 10, 1, 1043, 45],
["load_dynamic", 8, 10, 1, 1043, 45],
"_nop_tc_1",
"_nop_tc_2",
["push", 9, 8, 1043, 45],
@@ -5756,7 +5756,7 @@
["lt", 35, 30, 36, 1059, 22],
["jump_false", 35, "while_end_717", 1059, 22],
["load_field", 35, 1, "functions", 1060, 13],
["load_index", 36, 35, 30, 1060, 27],
["load_dynamic", 36, 35, 30, 1060, 27],
["frame", 35, 34, 1, 1060, 5],
["setarg", 35, 1, 36, 1060, 5],
["invoke", 35, 36, 1060, 5],
@@ -5775,7 +5775,7 @@
["lt", 39, 30, 40, 1069, 22],
["jump_false", 39, "while_end_719", 1069, 22],
["load_field", 39, 1, "functions", 1070, 10],
["load_index", 40, 39, 30, 1070, 24],
["load_dynamic", 40, 39, 30, 1070, 24],
["move", 35, 40, 1070, 24],
["load_field", 39, 40, "name", 1071, 9],
["null", 40, 1071, 20],

File diff suppressed because one or more lines are too long

View File

@@ -103,7 +103,7 @@
"_nop_tc_1",
"_nop_tc_2",
["subtract", 4, 3, 2, 42, 35],
["load_index", 2, 1, 4, 42, 35],
["load_dynamic", 2, 1, 4, 42, 35],
["put", 2, 8, 1, 42, 35],
["null", 1, 42, 35],
["return", 1, 42, 35]
@@ -204,7 +204,7 @@
"_nop_tc_3",
"_nop_tc_4",
["subtract", 5, 4, 3, 59, 36],
["load_index", 3, 2, 5, 59, 36],
["load_dynamic", 3, 2, 5, 59, 36],
["return", 3, 59, 36],
"_nop_ur_2",
"_nop_ur_3"
@@ -677,14 +677,14 @@
"num_done_54",
["lt", 4, 23, 44, 205, 32],
["jump_false", 4, "while_end_52", 205, 32],
["load_index", 4, 21, 23, 206, 16],
["load_dynamic", 4, 21, 23, 206, 16],
["access", 43, "$", 206, 23],
["eq", 45, 4, 43, 206, 23],
["move", 4, 45, 206, 23],
["jump_false", 45, "and_end_57", 206, 23],
["access", 43, 1, 206, 38],
["add", 45, 23, 43, 206, 38],
["load_index", 43, 21, 45, 206, 38],
["load_dynamic", 43, 21, 45, 206, 38],
["access", 45, "{", 206, 44],
["eq", 46, 43, 45, 206, 44],
["move", 4, 46, 206, 44],
@@ -696,7 +696,7 @@
["jump_true", 43, "or_end_60", 207, 21],
["access", 43, 1, 207, 34],
["subtract", 45, 23, 43, 207, 34],
["load_index", 43, 21, 45, 207, 34],
["load_dynamic", 43, 21, 45, 207, 34],
["access", 45, "\\", 207, 40],
["ne", 46, 43, 45, 207, 40],
["move", 4, 46, 207, 40],
@@ -765,7 +765,7 @@
"while_start_64",
["lt", 4, 27, 28, 229, 20],
["jump_false", 4, "while_end_65", 229, 20],
["load_index", 4, 21, 27, 230, 16],
["load_dynamic", 4, 21, 27, 230, 16],
["access", 43, "\\", 230, 24],
["eq", 45, 4, 43, 230, 24],
["move", 4, 45, 230, 24],
@@ -778,7 +778,7 @@
["jump_false", 4, "if_else_66", 230, 42],
["access", 4, 1, 231, 29],
["add", 43, 27, 4, 231, 29],
["load_index", 4, 21, 43, 231, 29],
["load_dynamic", 4, 21, 43, 231, 29],
["move", 34, 4, 231, 29],
["get", 43, 7, 1, 232, 21],
["load_dynamic", 45, 43, 4, 232, 41],
@@ -853,7 +853,7 @@
["add", 27, 27, 4, 235, 23],
["jump", "if_end_67", 235, 23],
"if_else_66",
["load_index", 4, 21, 27, 236, 23],
["load_dynamic", 4, 21, 27, 236, 23],
["access", 43, "$", 236, 31],
["eq", 45, 4, 43, 236, 31],
["move", 4, 45, 236, 31],
@@ -867,7 +867,7 @@
["jump_false", 4, "and_end_77", 236, 48],
["access", 4, 1, 236, 66],
["add", 45, 27, 4, 236, 66],
["load_index", 4, 21, 45, 236, 66],
["load_dynamic", 4, 21, 45, 236, 66],
["access", 45, "{", 236, 72],
["eq", 46, 4, 45, 236, 72],
["move", 43, 46, 236, 72],
@@ -887,7 +887,7 @@
["move", 43, 45, 240, 41],
"and_end_81",
["jump_false", 43, "while_end_80", 240, 41],
["load_index", 4, 21, 27, 241, 21],
["load_dynamic", 4, 21, 27, 241, 21],
["move", 32, 4, 241, 21],
["access", 43, "{", 242, 23],
["eq", 45, 4, 43, 242, 23],
@@ -1025,12 +1025,12 @@
["lt", 4, 27, 28, 252, 28],
["move", 43, 4, 252, 28],
["jump_false", 4, "and_end_100", 252, 28],
["load_index", 4, 21, 27, 252, 40],
["load_dynamic", 4, 21, 27, 252, 40],
["ne", 45, 4, 33, 252, 48],
["move", 43, 45, 252, 48],
"and_end_100",
["jump_false", 43, "while_end_99", 252, 48],
["load_index", 4, 21, 27, 253, 24],
["load_dynamic", 4, 21, 27, 253, 24],
["access", 43, "\\", 253, 32],
["eq", 45, 4, 43, 253, 32],
["move", 4, 45, 253, 32],
@@ -1041,7 +1041,7 @@
["move", 4, 43, 253, 50],
"and_end_103",
["jump_false", 4, "if_else_101", 253, 50],
["load_index", 4, 21, 27, 254, 39],
["load_dynamic", 4, 21, 27, 254, 39],
["is_array", 43, 30, 254, 39],
["jump_false", 43, "push_err_104", 254, 39],
["push", 30, 4, 254, 39],
@@ -1077,7 +1077,7 @@
["jump", "if_end_102", 255, 31],
"if_else_101",
"if_end_102",
["load_index", 4, 21, 27, 257, 37],
["load_dynamic", 4, 21, 27, 257, 37],
["is_array", 43, 30, 257, 37],
["jump_false", 43, "push_err_106", 257, 37],
["push", 30, 4, 257, 37],
@@ -1114,7 +1114,7 @@
"while_end_99",
["lt", 4, 27, 28, 260, 25],
["jump_false", 4, "if_else_108", 260, 25],
["load_index", 4, 21, 27, 260, 54],
["load_dynamic", 4, 21, 27, 260, 54],
["is_array", 43, 30, 260, 54],
["jump_false", 43, "push_err_110", 260, 54],
["push", 30, 4, 260, 54],
@@ -1402,7 +1402,7 @@
["add", 26, 26, 4, 282, 23],
["jump", "if_end_76", 282, 23],
"if_else_75",
["load_index", 4, 21, 27, 284, 30],
["load_dynamic", 4, 21, 27, 284, 30],
["is_array", 43, 25, 284, 30],
["jump_false", 43, "push_err_128", 284, 30],
["push", 25, 4, 284, 30],
@@ -7654,15 +7654,15 @@
["lt", 7, 6, 8, 1461, 25],
["jump_false", 7, "while_end_762", 1461, 25],
["load_field", 7, 3, "vars", 1462, 13],
["load_index", 8, 7, 6, 1462, 20],
["load_dynamic", 8, 7, 6, 1462, 20],
["load_field", 7, 8, "name", 1462, 20],
["eq", 8, 7, 2, 1462, 31],
["jump_false", 8, "if_else_763", 1462, 31],
["load_field", 7, 3, "vars", 1463, 22],
["load_index", 8, 7, 6, 1463, 29],
["load_dynamic", 8, 7, 6, 1463, 29],
["store_field", 4, 8, "v", 1463, 11],
["load_field", 7, 3, "vars", 1464, 36],
["load_index", 8, 7, 6, 1464, 43],
["load_dynamic", 8, 7, 6, 1464, 43],
["load_field", 7, 8, "function_nr", 1464, 43],
["store_field", 4, 7, "def_function_nr", 1464, 11],
["return", 4, 1465, 18],
@@ -8101,7 +8101,7 @@
["lt", 7, 5, 8, 1549, 23],
["jump_false", 7, "while_end_824", 1549, 23],
["load_field", 7, 1, "vars", 1550, 11],
["load_index", 8, 7, 5, 1550, 22],
["load_dynamic", 8, 7, 5, 1550, 22],
["move", 6, 8, 1550, 22],
["record", 7, 6],
["load_field", 9, 8, "make", 1552, 15],
@@ -8163,7 +8163,7 @@
["length", 10, 2, 1578, 23],
["lt", 11, 3, 10, 1578, 23],
["jump_false", 11, "while_end_828", 1578, 23],
["load_index", 10, 2, 3, 1579, 20],
["load_dynamic", 10, 2, 3, 1579, 20],
["move", 4, 10, 1579, 20],
["load_field", 11, 10, "kind", 1580, 14],
["move", 5, 11, 1580, 14],
@@ -8248,7 +8248,7 @@
["lt", 10, 9, 11, 1593, 27],
["jump_false", 10, "while_end_842", 1593, 27],
["load_field", 10, 4, "list", 1594, 18],
["load_index", 11, 10, 9, 1594, 28],
["load_dynamic", 11, 10, 9, 1594, 28],
["move", 7, 11, 1594, 28],
["load_field", 10, 11, "kind", 1595, 16],
["move", 8, 10, 1595, 16],
@@ -9790,7 +9790,7 @@
["lt", 8, 6, 17, 1781, 25],
["jump_false", 8, "while_end_1034", 1781, 25],
["load_field", 8, 2, "list", 1782, 31],
["load_index", 17, 8, 6, 1782, 41],
["load_dynamic", 17, 8, 6, 1782, 41],
["get", 8, 45, 1, 1782, 9],
["frame", 19, 8, 2, 1782, 9],
["setarg", 19, 1, 1, 1782, 9],
@@ -9853,7 +9853,7 @@
["lt", 8, 6, 17, 1796, 25],
["jump_false", 8, "while_end_1044", 1796, 25],
["load_field", 8, 2, "list", 1797, 31],
["load_index", 17, 8, 6, 1797, 41],
["load_dynamic", 17, 8, 6, 1797, 41],
["get", 8, 45, 1, 1797, 9],
["frame", 19, 8, 2, 1797, 9],
["setarg", 19, 1, 1, 1797, 9],
@@ -9878,7 +9878,7 @@
["lt", 8, 6, 17, 1805, 25],
["jump_false", 8, "while_end_1048", 1805, 25],
["load_field", 8, 2, "list", 1806, 16],
["load_index", 17, 8, 6, 1806, 26],
["load_dynamic", 17, 8, 6, 1806, 26],
["move", 9, 17, 1806, 26],
["load_field", 8, 17, "right", 1807, 15],
["move", 10, 8, 1807, 15],
@@ -9953,7 +9953,7 @@
["lt", 8, 6, 17, 1826, 25],
["jump_false", 8, "while_end_1058", 1826, 25],
["load_field", 8, 2, "list", 1827, 17],
["load_index", 17, 8, 6, 1827, 27],
["load_dynamic", 17, 8, 6, 1827, 27],
["load_field", 8, 17, "name", 1827, 27],
["move", 13, 8, 1827, 27],
["null", 17, 1828, 22],
@@ -9975,7 +9975,7 @@
"if_else_1059",
"if_end_1060",
["load_field", 8, 2, "list", 1829, 19],
["load_index", 17, 8, 6, 1829, 29],
["load_dynamic", 17, 8, 6, 1829, 29],
["load_field", 8, 17, "expression", 1829, 29],
["move", 14, 8, 1829, 29],
["null", 17, 1830, 24],
@@ -10010,7 +10010,7 @@
["lt", 8, 6, 17, 1836, 27],
["jump_false", 8, "while_end_1066", 1836, 27],
["load_field", 8, 2, "statements", 1837, 36],
["load_index", 17, 8, 6, 1837, 52],
["load_dynamic", 17, 8, 6, 1837, 52],
["get", 8, 63, 1, 1837, 11],
["frame", 19, 8, 2, 1837, 11],
["setarg", 19, 1, 12, 1837, 11],
@@ -10034,7 +10034,7 @@
["lt", 8, 6, 17, 1843, 27],
["jump_false", 8, "while_end_1070", 1843, 27],
["load_field", 8, 2, "disruption", 1844, 36],
["load_index", 17, 8, 6, 1844, 52],
["load_dynamic", 17, 8, 6, 1844, 52],
["get", 8, 63, 1, 1844, 11],
["frame", 19, 8, 2, 1844, 11],
["setarg", 19, 1, 12, 1844, 11],
@@ -10103,7 +10103,7 @@
["lt", 8, 6, 17, 1857, 25],
["jump_false", 8, "while_end_1076", 1857, 25],
["load_field", 8, 2, "list", 1858, 31],
["load_index", 17, 8, 6, 1858, 41],
["load_dynamic", 17, 8, 6, 1858, 41],
["get", 8, 45, 1, 1858, 9],
["frame", 19, 8, 2, 1858, 9],
["setarg", 19, 1, 1, 1858, 9],
@@ -10248,7 +10248,7 @@
["lt", 19, 6, 20, 1910, 25],
["jump_false", 19, "while_end_1094", 1910, 25],
["load_field", 19, 2, "list", 1911, 31],
["load_index", 20, 19, 6, 1911, 41],
["load_dynamic", 20, 19, 6, 1911, 41],
["get", 19, 63, 1, 1911, 9],
["frame", 21, 19, 2, 1911, 9],
["setarg", 21, 1, 1, 1911, 9],
@@ -10620,7 +10620,7 @@
["lt", 5, 6, 18, 1964, 25],
["jump_false", 5, "while_end_1140", 1964, 25],
["load_field", 5, 2, "then", 1965, 31],
["load_index", 18, 5, 6, 1965, 41],
["load_dynamic", 18, 5, 6, 1965, 41],
["get", 5, 63, 1, 1965, 9],
["frame", 19, 5, 2, 1965, 9],
["setarg", 19, 1, 1, 1965, 9],
@@ -10637,7 +10637,7 @@
["lt", 5, 6, 18, 1969, 25],
["jump_false", 5, "while_end_1142", 1969, 25],
["load_field", 5, 2, "list", 1970, 31],
["load_index", 18, 5, 6, 1970, 41],
["load_dynamic", 18, 5, 6, 1970, 41],
["get", 5, 63, 1, 1970, 9],
["frame", 19, 5, 2, 1970, 9],
["setarg", 19, 1, 1, 1970, 9],
@@ -10658,7 +10658,7 @@
["lt", 5, 6, 18, 1975, 27],
["jump_false", 5, "while_end_1146", 1975, 27],
["load_field", 5, 2, "else", 1976, 33],
["load_index", 18, 5, 6, 1976, 43],
["load_dynamic", 18, 5, 6, 1976, 43],
["get", 5, 63, 1, 1976, 11],
["frame", 19, 5, 2, 1976, 11],
["setarg", 19, 1, 1, 1976, 11],
@@ -10703,7 +10703,7 @@
["lt", 5, 6, 18, 1987, 25],
["jump_false", 5, "while_end_1150", 1987, 25],
["load_field", 5, 2, "statements", 1988, 36],
["load_index", 18, 5, 6, 1988, 52],
["load_dynamic", 18, 5, 6, 1988, 52],
["get", 5, 63, 1, 1988, 9],
["frame", 19, 5, 2, 1988, 9],
["setarg", 19, 1, 7, 1988, 9],
@@ -10744,7 +10744,7 @@
["lt", 5, 6, 7, 1998, 25],
["jump_false", 5, "while_end_1154", 1998, 25],
["load_field", 5, 2, "statements", 1999, 34],
["load_index", 7, 5, 6, 1999, 50],
["load_dynamic", 7, 5, 6, 1999, 50],
["get", 5, 63, 1, 1999, 9],
["frame", 18, 5, 2, 1999, 9],
["setarg", 18, 1, 8, 1999, 9],
@@ -10837,7 +10837,7 @@
["lt", 5, 6, 7, 2020, 25],
["jump_false", 5, "while_end_1163", 2020, 25],
["load_field", 5, 2, "statements", 2021, 35],
["load_index", 7, 5, 6, 2021, 51],
["load_dynamic", 7, 5, 6, 2021, 51],
["get", 5, 63, 1, 2021, 9],
["frame", 8, 5, 2, 2021, 9],
["setarg", 8, 1, 9, 2021, 9],
@@ -11037,7 +11037,7 @@
["lt", 5, 6, 7, 2075, 25],
["jump_false", 5, "while_end_1194", 2075, 25],
["load_field", 5, 2, "statements", 2076, 31],
["load_index", 7, 5, 6, 2076, 47],
["load_dynamic", 7, 5, 6, 2076, 47],
["get", 5, 63, 1, 2076, 9],
["frame", 8, 5, 2, 2076, 9],
["setarg", 8, 1, 1, 2076, 9],
@@ -11142,7 +11142,7 @@
["lt", 3, 6, 4, 2098, 25],
["jump_false", 3, "while_end_1207", 2098, 25],
["load_field", 3, 2, "list", 2099, 17],
["load_index", 4, 3, 6, 2099, 27],
["load_dynamic", 4, 3, 6, 2099, 27],
["load_field", 3, 4, "name", 2099, 27],
["move", 13, 3, 2099, 27],
["null", 4, 2100, 22],
@@ -11164,7 +11164,7 @@
"if_else_1208",
"if_end_1209",
["load_field", 3, 2, "list", 2101, 19],
["load_index", 4, 3, 6, 2101, 29],
["load_dynamic", 4, 3, 6, 2101, 29],
["load_field", 3, 4, "expression", 2101, 29],
["move", 14, 3, 2101, 29],
["null", 4, 2102, 24],
@@ -11195,7 +11195,7 @@
["lt", 3, 6, 4, 2107, 25],
["jump_false", 3, "while_end_1213", 2107, 25],
["load_field", 3, 2, "statements", 2108, 34],
["load_index", 4, 3, 6, 2108, 50],
["load_dynamic", 4, 3, 6, 2108, 50],
["get", 3, 63, 1, 2108, 9],
["frame", 5, 3, 2, 2108, 9],
["setarg", 5, 1, 12, 2108, 9],
@@ -11216,7 +11216,7 @@
["lt", 3, 6, 4, 2113, 27],
["jump_false", 3, "while_end_1217", 2113, 27],
["load_field", 3, 2, "disruption", 2114, 36],
["load_index", 4, 3, 6, 2114, 52],
["load_dynamic", 4, 3, 6, 2114, 52],
["get", 3, 63, 1, 2114, 11],
["frame", 5, 3, 2, 2114, 11],
["setarg", 5, 1, 12, 2114, 11],
@@ -11312,7 +11312,7 @@
["lt", 7, 2, 8, 2135, 23],
["jump_false", 7, "while_end_1221", 2135, 23],
["load_field", 7, 1, "functions", 2136, 14],
["load_index", 8, 7, 2, 2136, 28],
["load_dynamic", 8, 7, 2, 2136, 28],
["load_field", 7, 8, "name", 2136, 28],
["move", 4, 7, 2136, 28],
["null", 8, 2137, 19],
@@ -11343,7 +11343,7 @@
["lt", 4, 2, 7, 2142, 23],
["jump_false", 4, "while_end_1225", 2142, 23],
["load_field", 4, 1, "statements", 2143, 36],
["load_index", 7, 4, 2, 2143, 51],
["load_dynamic", 7, 4, 2, 2143, 51],
["get", 4, 63, 1, 2143, 7],
["frame", 8, 4, 2, 2143, 7],
["setarg", 8, 1, 3, 2143, 7],
@@ -11360,7 +11360,7 @@
["lt", 4, 2, 7, 2148, 23],
["jump_false", 4, "while_end_1227", 2148, 23],
["load_field", 4, 1, "functions", 2149, 36],
["load_index", 7, 4, 2, 2149, 50],
["load_dynamic", 7, 4, 2, 2149, 50],
["get", 4, 63, 1, 2149, 7],
["frame", 8, 4, 2, 2149, 7],
["setarg", 8, 1, 3, 2149, 7],
@@ -11386,7 +11386,7 @@
["lt", 3, 2, 4, 2156, 23],
["jump_false", 3, "while_end_1229", 2156, 23],
["get", 3, 47, 1, 2157, 24],
["load_index", 4, 3, 2, 2157, 37],
["load_dynamic", 4, 3, 2, 2157, 37],
["is_array", 3, 6, 2157, 37],
["jump_false", 3, "push_err_1230", 2157, 37],
["push", 6, 4, 2157, 37],

2764
boot/qbe.cm.mcode Normal file

File diff suppressed because it is too large Load Diff

31907
boot/qbe_emit.cm.mcode Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
// Minimal bootstrap — seeds the content-addressed cache
// Only runs on cold start (C runtime couldn't find engine in cache)
// Hidden vars: os, core_path, shop_path
// Hidden vars: os, core_path, shop_path, native_mode (optional)
var load_internal = os.load_internal
function use_embed(name) {
return load_internal("js_core_" + name + "_use")
@@ -89,20 +89,172 @@ function compile_and_cache(name, source_path) {
}
}
// Seed the cache with everything engine needs
var seed_files = [
{name: "tokenize", path: "tokenize.cm"},
{name: "parse", path: "parse.cm"},
{name: "fold", path: "fold.cm"},
{name: "mcode", path: "mcode.cm"},
{name: "streamline", path: "streamline.cm"},
{name: "engine", path: "internal/engine.cm"}
]
var _i = 0
var entry = null
while (_i < length(seed_files)) {
entry = seed_files[_i]
compile_and_cache(entry.name, core_path + '/' + entry.path)
_i = _i + 1
// --- Native compilation support ---
function detect_host_target() {
var platform = os.platform()
var arch = os.arch ? os.arch() : 'arm64'
if (platform == 'macOS' || platform == 'darwin')
return arch == 'x86_64' ? 'macos_x86_64' : 'macos_arm64'
if (platform == 'Linux' || platform == 'linux')
return arch == 'x86_64' ? 'linux' : 'linux_arm64'
if (platform == 'Windows' || platform == 'windows')
return 'windows'
return null
}
function detect_cc() {
var platform = os.platform()
if (platform == 'macOS') return 'clang'
return 'cc'
}
// Compute native dylib cache path matching build.cm's scheme:
// cache_path(native_cache_content(src, target, ''), SALT_NATIVE)
function native_dylib_cache_path(src, target) {
var native_key = src + '\n' + target + '\nnative\n'
var full_key = native_key + '\nnative'
return cache_path(content_hash(full_key))
}
// Compile a module to a native dylib and cache it
var _qbe_mod = null
var _qbe_emit_mod = null
var _host_target = null
var _cc = null
var _is_darwin = false
var _rt_compiled = false
function compile_native_cached(name, source_path) {
var source_blob = fd.slurp(source_path)
var src = text(source_blob)
var dylib_path = native_dylib_cache_path(src, _host_target)
var ast = null
var compiled = null
var il_parts = null
var helpers_il = null
var all_fns = null
var full_il = null
var asm_text = null
var tmp = null
var rc = null
var rt_o = null
var qbe_rt_path = null
var link_cmd = null
if (dylib_path && fd.is_file(dylib_path)) {
os.print("bootstrap: native cache hit: " + name + "\n")
return
}
os.print("bootstrap: compiling native: " + name + "\n")
ast = analyze(src, source_path)
compiled = streamline_mod(mcode_mod(ast))
il_parts = _qbe_emit_mod(compiled, _qbe_mod, null)
helpers_il = (il_parts.helpers && length(il_parts.helpers) > 0)
? text(il_parts.helpers, "\n") : ""
all_fns = text(il_parts.functions, "\n")
full_il = il_parts.data + "\n\n" + helpers_il + "\n\n" + all_fns
asm_text = os.qbe(full_il)
tmp = '/tmp/cell_boot_' + name
fd.slurpwrite(tmp + '.s', stone(blob(asm_text)))
rc = os.system(_cc + ' -c ' + tmp + '.s -o ' + tmp + '.o')
if (rc != 0) {
os.print("error: assembly failed for " + name + "\n")
disrupt
}
// Compile QBE runtime stubs (once)
rt_o = '/tmp/cell_qbe_rt.o'
if (!_rt_compiled && !fd.is_file(rt_o)) {
qbe_rt_path = core_path + '/src/qbe_rt.c'
rc = os.system(_cc + ' -c ' + qbe_rt_path + ' -o ' + rt_o + ' -fPIC')
if (rc != 0) {
os.print("error: qbe_rt compilation failed\n")
disrupt
}
_rt_compiled = true
}
// Link dylib
ensure_build_dir()
link_cmd = _cc + ' -shared -fPIC'
if (_is_darwin)
link_cmd = link_cmd + ' -undefined dynamic_lookup'
link_cmd = link_cmd + ' ' + tmp + '.o ' + rt_o + ' -o ' + dylib_path
rc = os.system(link_cmd)
if (rc != 0) {
os.print("error: linking failed for " + name + "\n")
disrupt
}
}
// --- Main bootstrap logic ---
// Check if native_mode was passed from C runtime
var _native = false
var _check_nm = function() {
if (native_mode) _native = true
} disruption {}
_check_nm()
var _targets = null
var _ti = 0
var _te = null
if (_native) {
// Native path: compile everything to native dylibs
_qbe_mod = boot_load("qbe")
_qbe_emit_mod = boot_load("qbe_emit")
_host_target = detect_host_target()
_cc = detect_cc()
_is_darwin = os.platform() == 'macOS'
if (!_host_target) {
os.print("error: could not detect host target for native compilation\n")
disrupt
}
// Also seed bytecode cache for engine (so non-native path still works)
compile_and_cache("engine", core_path + '/internal/engine.cm')
// Compile pipeline modules + qbe/qbe_emit + engine to native dylibs
_targets = [
{name: "tokenize", path: "tokenize.cm"},
{name: "parse", path: "parse.cm"},
{name: "fold", path: "fold.cm"},
{name: "mcode", path: "mcode.cm"},
{name: "streamline", path: "streamline.cm"},
{name: "qbe", path: "qbe.cm"},
{name: "qbe_emit", path: "qbe_emit.cm"},
{name: "engine", path: "internal/engine.cm"}
]
_ti = 0
while (_ti < length(_targets)) {
_te = _targets[_ti]
compile_native_cached(_te.name, core_path + '/' + _te.path)
_ti = _ti + 1
}
os.print("bootstrap: native cache seeded\n")
} else {
// Bytecode path: seed cache with everything engine needs
_targets = [
{name: "tokenize", path: "tokenize.cm"},
{name: "parse", path: "parse.cm"},
{name: "fold", path: "fold.cm"},
{name: "mcode", path: "mcode.cm"},
{name: "streamline", path: "streamline.cm"},
{name: "engine", path: "internal/engine.cm"}
]
_ti = 0
while (_ti < length(_targets)) {
_te = _targets[_ti]
compile_and_cache(_te.name, core_path + '/' + _te.path)
_ti = _ti + 1
}
os.print("bootstrap: cache seeded\n")
}
os.print("bootstrap: cache seeded\n")

View File

@@ -52,6 +52,38 @@ function ensure_build_dir() {
return dir
}
// --- Native compilation support ---
function detect_host_target() {
var platform = os.platform()
var arch = os.arch ? os.arch() : 'arm64'
if (platform == 'macOS' || platform == 'darwin')
return arch == 'x86_64' ? 'macos_x86_64' : 'macos_arm64'
if (platform == 'Linux' || platform == 'linux')
return arch == 'x86_64' ? 'linux' : 'linux_arm64'
if (platform == 'Windows' || platform == 'windows')
return 'windows'
return null
}
function detect_cc() {
var platform = os.platform()
if (platform == 'macOS') return 'clang'
return 'cc'
}
function native_dylib_cache_path(src, target) {
var native_key = src + '\n' + target + '\nnative\n'
var full_key = native_key + '\nnative'
return cache_path(content_hash(full_key))
}
var _engine_host_target = null
var _engine_cc = null
var _engine_is_darwin = false
var _qbe_mod = null
var _qbe_emit_mod = null
// Load a boot seed module (for compiling pipeline modules on cache miss)
function boot_load(name) {
var mcode_path = core_path + '/boot/' + name + '.cm.mcode'
@@ -85,8 +117,22 @@ function load_pipeline_module(name, env) {
var ast = null
var compiled = null
var mcode_json = null
if (fd.is_file(source_path)) {
var native_path = null
var native_handle = null
// Native mode: check native cache first
if (native_mode && _engine_host_target && fd.is_file(source_path)) {
source_blob = fd.slurp(source_path)
src = text(source_blob)
native_path = native_dylib_cache_path(src, _engine_host_target)
if (native_path && fd.is_file(native_path)) {
native_handle = os.dylib_open(native_path)
return os.native_module_load_named(native_handle, 'cell_main', env)
}
}
if (fd.is_file(source_path)) {
if (!source_blob) source_blob = fd.slurp(source_path)
hash = content_hash(source_blob)
cached = cache_path(hash)
if (cached && fd.is_file(cached))
@@ -99,7 +145,7 @@ function load_pipeline_module(name, env) {
boot_par = boot_load("parse")
boot_fld = boot_load("fold")
boot_mc = boot_load("mcode")
src = text(source_blob)
if (!src) src = text(source_blob)
tok_result = boot_tok(src, source_path)
ast = boot_par(tok_result.tokens, src, source_path, boot_tok)
if (ast.errors != null && length(ast.errors) > 0) {
@@ -112,7 +158,7 @@ function load_pipeline_module(name, env) {
compiled = boot_sl(compiled)
mcode_json = json.encode(compiled)
mach_blob = mach_compile_mcode_bin(name, mcode_json)
if (cached) {
if (!native_mode && cached) {
ensure_build_dir()
fd.slurpwrite(cached, mach_blob)
}
@@ -130,6 +176,13 @@ function load_pipeline_module(name, env) {
disrupt
}
// Initialize native compilation state before pipeline loading
if (native_mode) {
_engine_host_target = detect_host_target()
_engine_cc = detect_cc()
_engine_is_darwin = os.platform() == 'macOS'
}
// Load compilation pipeline
var pipeline_env = stone({use: use_embed})
var tokenize_mod = load_pipeline_module('tokenize', pipeline_env)
@@ -146,6 +199,16 @@ use_cache['core/mcode'] = mcode_mod
use_cache['streamline'] = streamline_mod
use_cache['core/streamline'] = streamline_mod
// Load QBE modules when native mode
if (native_mode) {
_qbe_mod = load_pipeline_module('qbe', pipeline_env)
_qbe_emit_mod = load_pipeline_module('qbe_emit', pipeline_env)
use_cache['qbe'] = _qbe_mod
use_cache['core/qbe'] = _qbe_mod
use_cache['qbe_emit'] = _qbe_emit_mod
use_cache['core/qbe_emit'] = _qbe_emit_mod
}
// analyze: tokenize + parse + fold, check for errors
function analyze(src, filename) {
var tok_result = tokenize_mod(src, filename)
@@ -446,6 +509,70 @@ use_cache['core/internal/os'] = os
// Extra env properties added as engine initializes (log, runtime fns, etc.)
var core_extras = {}
// Compile a core module to a native dylib, return the dylib path
function compile_core_native(name, source_path) {
var source_blob = fd.slurp(source_path)
var src = text(source_blob)
var dylib_path = native_dylib_cache_path(src, _engine_host_target)
var ast = null
var compiled = null
var il_parts = null
var helpers_il = null
var all_fns = null
var full_il = null
var asm_text = null
var tmp = null
var rc = null
var rt_o = null
var qbe_rt_path = null
var link_cmd = null
if (dylib_path && fd.is_file(dylib_path))
return dylib_path
ast = analyze(src, source_path)
compiled = streamline_mod(mcode_mod(ast))
il_parts = _qbe_emit_mod(compiled, _qbe_mod, null)
helpers_il = (il_parts.helpers && length(il_parts.helpers) > 0)
? text(il_parts.helpers, "\n") : ""
all_fns = text(il_parts.functions, "\n")
full_il = il_parts.data + "\n\n" + helpers_il + "\n\n" + all_fns
asm_text = os.qbe(full_il)
tmp = '/tmp/cell_engine_' + replace(name, '/', '_')
fd.slurpwrite(tmp + '.s', stone(blob(asm_text)))
rc = os.system(_engine_cc + ' -c ' + tmp + '.s -o ' + tmp + '.o')
if (rc != 0) {
os.print("error: assembly failed for " + name + "\n")
disrupt
}
rt_o = '/tmp/cell_qbe_rt.o'
if (!fd.is_file(rt_o)) {
qbe_rt_path = core_path + '/src/qbe_rt.c'
rc = os.system(_engine_cc + ' -c ' + qbe_rt_path + ' -o ' + rt_o + ' -fPIC')
if (rc != 0) {
os.print("error: qbe_rt compilation failed\n")
disrupt
}
}
ensure_build_dir()
link_cmd = _engine_cc + ' -shared -fPIC'
if (_engine_is_darwin)
link_cmd = link_cmd + ' -undefined dynamic_lookup'
link_cmd = link_cmd + ' ' + tmp + '.o ' + rt_o + ' -o ' + dylib_path
rc = os.system(link_cmd)
if (rc != 0) {
os.print("error: linking failed for " + name + "\n")
disrupt
}
return dylib_path
}
// Load a core module from the file system
function use_core(path) {
var cache_key = 'core/' + path
@@ -458,6 +585,7 @@ function use_core(path) {
var script = null
var ast = null
var _load_mod = null
var _try_native = null
// Build env: merge core_extras
env = {use: use_core}
@@ -473,8 +601,34 @@ function use_core(path) {
// Compile from source .cm file
file_path = core_path + '/' + path + MOD_EXT
if (fd.is_file(file_path)) {
// Native path: try native cache or compile natively
if (native_mode && _qbe_mod && _qbe_emit_mod) {
_try_native = function() {
var src = null
var native_path = null
var native_handle = null
source_blob = fd.slurp(file_path)
src = text(source_blob)
native_path = native_dylib_cache_path(src, _engine_host_target)
if (native_path && fd.is_file(native_path)) {
native_handle = os.dylib_open(native_path)
result = os.native_module_load_named(native_handle, 'cell_main', env)
return
}
native_path = compile_core_native('core:' + path, file_path)
native_handle = os.dylib_open(native_path)
result = os.native_module_load_named(native_handle, 'cell_main', env)
} disruption {}
_try_native()
if (result != null) {
use_cache[cache_key] = result
return result
}
}
// Bytecode path (fallback or non-native mode)
_load_mod = function() {
source_blob = fd.slurp(file_path)
if (!source_blob) source_blob = fd.slurp(file_path)
hash = content_hash(source_blob)
cached_path = cache_path(hash)
if (cached_path && fd.is_file(cached_path)) {
@@ -483,7 +637,7 @@ function use_core(path) {
script = text(source_blob)
ast = analyze(script, file_path)
mach_blob = compile_to_blob('core:' + path, ast)
if (cached_path) {
if (!native_mode && cached_path) {
ensure_build_dir()
fd.slurpwrite(cached_path, mach_blob)
}

View File

@@ -809,7 +809,7 @@ function resolve_mod_fn(path, pkg) {
if (fd.is_file(cached_mcode_path)) {
mcode_json = text(fd.slurp(cached_mcode_path))
compiled = mach_compile_mcode_bin(path, mcode_json)
put_into_cache(content_key, compiled)
if (!policy.native) put_into_cache(content_key, compiled)
return compiled
}
}
@@ -830,12 +830,14 @@ function resolve_mod_fn(path, pkg) {
mcode_json = shop_json.encode(optimized)
// Cache mcode (architecture-independent) in content-addressed store
fd.ensure_dir(global_shop_path + '/build')
fd.slurpwrite(cached_mcode_path, stone(blob(mcode_json)))
if (!policy.native) {
fd.ensure_dir(global_shop_path + '/build')
fd.slurpwrite(cached_mcode_path, stone(blob(mcode_json)))
}
// Cache mach blob
compiled = mach_compile_mcode_bin(path, mcode_json)
put_into_cache(content_key, compiled)
if (!policy.native) put_into_cache(content_key, compiled)
return compiled
}

View File

@@ -2363,7 +2363,7 @@ var mcode = function(ast) {
obj = operand.left
prop = operand.right
obj_slot = gen_expr(obj, -1)
push(s_instructions, ["delete", slot, obj_slot, prop])
add_instr(["delete", slot, obj_slot, prop])
} else if (operand_kind == "[") {
obj = operand.left
idx = operand.right

View File

@@ -681,10 +681,15 @@ ${sw("w", "%fp", "%dest", "%r")}
ret %fp
}`
// get_intrinsic(ctx, fp, dest, lit_idx)
h[] = `export function l $__get_intrinsic_ss(l %ctx, l %fp, l %dest, l %lit_idx) ${lb}
// access_env(ctx, fp, dest, lit_idx) — read env from frame->function->env_record
h[] = `export function l $__access_env_ss(l %ctx, l %fp, l %dest, l %lit_idx) ${lb}
@entry
%r =l call $cell_rt_get_intrinsic_lit(l %ctx, l %lit_idx)
%fn_p =l sub %fp, 24
%fn =l loadl %fn_p
%fn_ptr =l and %fn, -8
%env_p =l add %fn_ptr, 32
%env =l loadl %env_p
%r =l call $cell_rt_access_env(l %ctx, l %env, l %lit_idx)
${alloc_tail("%r")}
}`
@@ -1479,7 +1484,7 @@ var qbe_emit = function(ir, qbe, export_name) {
} else if (is_object(a2)) {
if (a2.make == "intrinsic") {
sl = intern_str(a2.name)
emit(` %fp =l call $__get_intrinsic_ss(l %ctx, l %fp, l ${text(a1)}, l ${text(sl.idx)})`)
emit(` %fp =l call $__access_env_ss(l %ctx, l %fp, l ${text(a1)}, l ${text(sl.idx)})`)
emit_exc_check()
} else if (a2.kind == "number") {
if (a2.number != null && is_integer(a2.number)) {

View File

@@ -42,7 +42,7 @@ for (i = 0; i < length(args); i++) {
var core_dir = shop.get_package_dir('core')
var boot_dir = core_dir + '/boot'
var pipeline_modules = ['tokenize', 'parse', 'fold', 'mcode', 'streamline']
var pipeline_modules = ['tokenize', 'parse', 'fold', 'mcode', 'streamline', 'qbe', 'qbe_emit']
var generated = 0
var name = null
var src_path = null

View File

@@ -20,6 +20,7 @@
#include <signal.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dlfcn.h>
#include "monocypher.h"
/* Test suite declarations */
@@ -249,6 +250,54 @@ static char *try_engine_cache(size_t *out_size) {
return NULL;
}
static const char *detect_host_target(void) {
#if defined(__APPLE__) && defined(__aarch64__)
return "macos_arm64";
#elif defined(__APPLE__) && defined(__x86_64__)
return "macos_x86_64";
#elif defined(__linux__) && defined(__x86_64__)
return "linux";
#elif defined(__linux__) && defined(__aarch64__)
return "linux_arm64";
#elif defined(_WIN32)
return "windows";
#else
return NULL;
#endif
}
static char *try_engine_native_cache(void) {
const char *target = detect_host_target();
if (!target) return NULL;
size_t src_size;
char *src = load_core_file(ENGINE_SRC, &src_size);
if (!src) return NULL;
size_t target_len = strlen(target);
size_t key_len = src_size + 1 + target_len + 8 + 7;
char *key = malloc(key_len + 1);
if (!key) { free(src); return NULL; }
memcpy(key, src, src_size);
size_t pos = src_size;
key[pos++] = '\n';
memcpy(key + pos, target, target_len);
pos += target_len;
memcpy(key + pos, "\nnative\n", 8);
pos += 8;
memcpy(key + pos, "\nnative", 7);
pos += 7;
key[pos] = '\0';
free(src);
char *hex = compute_blake2_hex(key, pos);
free(key);
if (!hex) return NULL;
char *cpath = build_cache_path(hex);
free(hex);
if (!cpath) return NULL;
struct stat st;
if (stat(cpath, &st) != 0) { free(cpath); return NULL; }
return cpath;
}
// Get the core path for use by scripts
const char* cell_get_core_path(void) {
return core_path;
@@ -327,6 +376,8 @@ void script_startup(cell_rt *prt)
}
btmp = shop_path ? JS_NewString(js, shop_path) : JS_NULL;
JS_SetPropertyStr(js, boot_env_ref.val, "shop_path", btmp);
if (native_mode)
JS_SetPropertyStr(js, boot_env_ref.val, "native_mode", JS_NewBool(js, 1));
JSValue boot_env = JS_Stone(js, boot_env_ref.val);
JS_DeleteGCRef(js, &boot_env_ref);
@@ -465,6 +516,8 @@ static void print_usage(const char *prog)
printf("Run the 'help' script like 'cell help' to see available scripts\n");
}
JSValue cell_rt_native_module_load_named(JSContext *ctx, void *dl_handle, const char *sym_name, JSValue env);
int cell_init(int argc, char **argv)
{
/* Check for --help flag */
@@ -604,12 +657,21 @@ int cell_init(int argc, char **argv)
JS_FreeValue(ctx, js_core_blob_use(ctx));
int exit_code = 0;
int use_native_engine = 0;
char *native_dylib_path = NULL;
void *native_handle = NULL;
// Native mode: try native engine cache first
if (native_mode)
native_dylib_path = try_engine_native_cache();
// Try engine fast-path: load engine.cm from source-hash cache
size_t bin_size;
char *bin_data = try_engine_cache(&bin_size);
char *bin_data = NULL;
if (!native_dylib_path)
bin_data = try_engine_cache(&bin_size);
if (!bin_data) {
if (!native_dylib_path && !bin_data) {
// Cold path: run bootstrap to seed cache, then retry
size_t boot_size;
char *boot_data = load_core_file(BOOTSTRAP_MCODE, &boot_size);
@@ -640,6 +702,8 @@ int cell_init(int argc, char **argv)
JS_SetPropertyStr(ctx, boot_env_ref.val, "actorsym", JS_DupValue(ctx, cli_rt->actor_sym_ref.val));
btmp = js_core_json_use(ctx);
JS_SetPropertyStr(ctx, boot_env_ref.val, "json", btmp);
if (native_mode)
JS_SetPropertyStr(ctx, boot_env_ref.val, "native_mode", JS_NewBool(ctx, 1));
JS_SetPropertyStr(ctx, boot_env_ref.val, "init", JS_NULL);
JSGCRef boot_args_ref;
JS_AddGCRef(ctx, &boot_args_ref);
@@ -661,14 +725,32 @@ int cell_init(int argc, char **argv)
return 1;
}
// Retry engine from cache (new-style bootstrap seeds it)
bin_data = try_engine_cache(&bin_size);
if (!bin_data) {
// Old-style bootstrap already ran the program — skip engine load
goto check_actors;
// After bootstrap, retry cache
if (native_mode)
native_dylib_path = try_engine_native_cache();
if (!native_dylib_path) {
bin_data = try_engine_cache(&bin_size);
if (!bin_data) {
// Old-style bootstrap already ran the program — skip engine load
goto check_actors;
}
}
}
// Open native dylib if we have a path
if (native_dylib_path) {
native_handle = dlopen(native_dylib_path, RTLD_NOW | RTLD_GLOBAL);
if (native_handle) {
use_native_engine = 1;
} else {
// Fall back to bytecode
if (!bin_data)
bin_data = try_engine_cache(&bin_size);
}
free(native_dylib_path);
native_dylib_path = NULL;
}
{
// Build engine environment
JSGCRef env_ref;
@@ -713,10 +795,15 @@ int cell_init(int argc, char **argv)
JSValue hidden_env = JS_Stone(ctx, env_ref.val);
g_crash_ctx = ctx;
JSValue result = JS_RunMachBin(ctx, (const uint8_t *)bin_data, bin_size, hidden_env);
JSValue result;
if (use_native_engine) {
result = cell_rt_native_module_load_named(ctx, native_handle, "cell_main", hidden_env);
} else {
result = JS_RunMachBin(ctx, (const uint8_t *)bin_data, bin_size, hidden_env);
free(bin_data);
}
g_crash_ctx = NULL;
JS_DeleteGCRef(ctx, &env_ref);
free(bin_data);
if (JS_IsException(result)) {
JS_GetException(ctx);

View File

@@ -965,7 +965,7 @@ JSValue js_new_register_function(JSContext *ctx, JSCodeRegister *code, JSValue e
return out;
}
JSValue js_new_native_function_with_code(JSContext *ctx, JSValue code_obj, int arity, JSValue outer_frame) {
JSValue js_new_native_function_with_code(JSContext *ctx, JSValue code_obj, int arity, JSValue outer_frame, JSValue env_record) {
JSGCRef frame_ref;
JSGCRef fn_ref;
JSFunction *fn;
@@ -988,7 +988,7 @@ JSValue js_new_native_function_with_code(JSContext *ctx, JSValue code_obj, int a
fn->name = JS_NULL;
fn = JS_VALUE_GET_FUNCTION(fn_ref.val);
fn->u.cell.code = code_obj;
fn->u.cell.env_record = JS_NULL;
fn->u.cell.env_record = env_record;
fn->u.cell.outer_frame = frame_ref.val;
JSValue out = fn_ref.val;
@@ -999,11 +999,11 @@ JSValue js_new_native_function_with_code(JSContext *ctx, JSValue code_obj, int a
/* Create a native (QBE-compiled) function */
JSValue js_new_native_function(JSContext *ctx, void *fn_ptr, void *dl_handle,
uint16_t nr_slots, int arity, JSValue outer_frame) {
uint16_t nr_slots, int arity, JSValue outer_frame, JSValue env) {
JSValue code_obj = js_new_native_code(ctx, fn_ptr, dl_handle, nr_slots, arity);
if (JS_IsException(code_obj))
return JS_EXCEPTION;
return js_new_native_function_with_code(ctx, code_obj, arity, outer_frame);
return js_new_native_function_with_code(ctx, code_obj, arity, outer_frame, env);
}
/* Binary operations helper */

View File

@@ -212,9 +212,6 @@ typedef struct {
AOTCodeCacheEntry *code_cache;
int code_cache_count;
int code_cache_cap;
JSGCRef native_env_ref;
int has_native_env;
int native_env_ref_inited;
AOTGCRefChunk **gc_ref_chunks;
int gc_ref_chunk_count;
int aot_depth;
@@ -392,51 +389,22 @@ int cell_rt_store_dynamic(JSContext *ctx, JSValue val, JSValue obj,
}
}
/* --- Intrinsic/global lookup --- */
/* --- Env-based variable lookup (env at frame slot 0) --- */
void cell_rt_set_native_env(JSContext *ctx, JSValue env) {
NativeRTState *st = native_state(ctx);
if (!st) return;
if (!JS_IsNull(env) && !JS_IsStone(env)) {
fprintf(stderr, "cell_rt_set_native_env: ERROR env not stone\n");
abort();
JSValue cell_rt_access_env(JSContext *ctx, JSValue env, int64_t lit_idx) {
JSValue key = aot_lit_from_index(ctx, lit_idx);
if (JS_IsException(key))
return JS_EXCEPTION;
/* Try env first (linear scan for stoned records) */
if (!JS_IsNull(env) && JS_IsRecord(env)) {
JSRecord *rec = (JSRecord *)chase(env);
uint64_t mask = objhdr_cap56(rec->mist_hdr);
for (uint64_t i = 1; i <= mask; i++) {
if (js_key_equal(rec->slots[i].key, key))
return rec->slots[i].val;
}
}
/* Drop module literal pool roots before switching native env/module. */
aot_clear_lit_pool(ctx, st);
/* Native module boundary: clear per-actor key cache so stale keys
cannot survive across context/module lifetimes. */
free(st->key_cache);
st->key_cache = NULL;
st->key_cache_count = 0;
st->key_cache_cap = 0;
if (st->has_native_env && st->native_env_ref_inited) {
JS_DeleteGCRef(ctx, &st->native_env_ref);
st->native_env_ref_inited = 0;
}
if (!JS_IsNull(env)) {
JS_AddGCRef(ctx, &st->native_env_ref);
st->native_env_ref_inited = 1;
st->native_env_ref.val = env;
st->has_native_env = 1;
} else {
st->has_native_env = 0;
st->native_env_ref.val = JS_NULL;
}
}
static JSValue cell_rt_get_intrinsic_key(JSContext *ctx, JSValue key) {
NativeRTState *st = native_state(ctx);
if (!st) return JS_EXCEPTION;
/* Check native env first (runtime-provided functions like log) */
if (st->has_native_env) {
JSValue v = JS_GetProperty(ctx, st->native_env_ref.val, key);
if (!JS_IsNull(v))
return v;
}
/* Linear scan of global object — avoids hash mismatch issues with
stoned records whose keys may be in cold storage */
/* Fallback to global object */
JSValue gobj = ctx->global_obj;
if (JS_IsRecord(gobj)) {
JSRecord *rec = (JSRecord *)chase(gobj);
@@ -446,24 +414,12 @@ static JSValue cell_rt_get_intrinsic_key(JSContext *ctx, JSValue key) {
return rec->slots[i].val;
}
}
JS_RaiseDisrupt(ctx, "name is not defined");
const char *kstr = JS_ToCString(ctx, key);
JS_RaiseDisrupt(ctx, "'%s' is not defined", kstr ? kstr : "?");
if (kstr) JS_FreeCString(ctx, kstr);
return JS_EXCEPTION;
}
JSValue cell_rt_get_intrinsic(JSContext *ctx, const char *name) {
JSValue key = aot_key_from_cstr(ctx, name);
if (JS_IsException(key))
return JS_EXCEPTION;
return cell_rt_get_intrinsic_key(ctx, key);
}
JSValue cell_rt_get_intrinsic_lit(JSContext *ctx, int64_t lit_idx) {
JSValue key = aot_lit_from_index(ctx, lit_idx);
if (JS_IsException(key))
return JS_EXCEPTION;
return cell_rt_get_intrinsic_key(ctx, key);
}
/* --- GC-managed AOT frame stack ---
Each native dispatch loop pushes a GC ref so the GC can find and
update the current frame pointer when it moves objects.
@@ -1046,7 +1002,6 @@ static JSValue aot_get_or_create_native_code(JSContext *ctx, NativeRTState *st,
Called from QBE-generated code during function creation. */
JSValue cell_rt_make_function(JSContext *ctx, int64_t fn_idx, void *outer_fp,
int64_t nr_args, int64_t nr_slots) {
(void)outer_fp;
NativeRTState *st = native_state(ctx);
if (!st) return JS_EXCEPTION;
if (!st->current_dl_handle)
@@ -1062,7 +1017,18 @@ JSValue cell_rt_make_function(JSContext *ctx, int64_t fn_idx, void *outer_fp,
if (st->aot_depth > 0)
outer_frame = aot_gc_ref_at(st, st->aot_depth - 1)->val;
return js_new_native_function_with_code(ctx, code_obj, (int)nr_args, outer_frame);
/* Read env from the parent frame's function object */
JSValue env = JS_NULL;
if (outer_fp) {
JSFrameRegister *parent = (JSFrameRegister *)((char *)outer_fp - offsetof(JSFrameRegister, slots));
if (JS_IsFunction(parent->function)) {
JSFunction *parent_fn = JS_VALUE_GET_FUNCTION(parent->function);
if (parent_fn->kind == JS_FUNC_KIND_NATIVE)
env = parent_fn->u.cell.env_record;
}
}
return js_new_native_function_with_code(ctx, code_obj, (int)nr_args, outer_frame, env);
}
/* --- Frame-based function calling ---
@@ -1209,15 +1175,16 @@ JSValue cell_rt_regexp(JSContext *ctx, const char *pattern, const char *flags) {
Creates a temporary JS_FUNC_KIND_NATIVE function so that the full
dispatch loop (tail calls, closures, etc.) works for module-level code. */
static JSValue native_module_run(JSContext *ctx, void *dl_handle,
cell_compiled_fn entry, int nr_slots) {
cell_compiled_fn entry, int nr_slots,
JSValue env) {
NativeRTState *st = native_state(ctx);
if (!st) return JS_EXCEPTION;
void *prev_handle = st->current_dl_handle;
st->current_dl_handle = dl_handle;
/* Create a native function object for the entry point */
/* Create a native function object for the entry point, with env on the function */
JSValue func_obj = js_new_native_function(ctx, (void *)entry, dl_handle,
(uint16_t)nr_slots, 0, JS_NULL);
(uint16_t)nr_slots, 0, JS_NULL, env);
if (JS_IsException(func_obj)) {
st->current_dl_handle = prev_handle;
return JS_EXCEPTION;
@@ -1237,14 +1204,11 @@ JSValue cell_rt_native_module_load(JSContext *ctx, void *dl_handle, JSValue env)
if (!fn)
return JS_RaiseDisrupt(ctx, "cell_main not found in native module dylib");
/* Make env available for cell_rt_get_intrinsic lookups */
cell_rt_set_native_env(ctx, env);
/* Try to read nr_slots from the module (exported by emitter) */
int *slots_ptr = (int *)dlsym(dl_handle, "cell_main_nr_slots");
int nr_slots = slots_ptr ? *slots_ptr : 512;
return native_module_run(ctx, dl_handle, fn, nr_slots);
return native_module_run(ctx, dl_handle, fn, nr_slots, env);
}
/* Load a native module from a dylib handle, trying a named symbol first.
@@ -1263,16 +1227,13 @@ JSValue cell_rt_native_module_load_named(JSContext *ctx, void *dl_handle, const
if (!fn)
return JS_RaiseDisrupt(ctx, "symbol not found in native module dylib");
/* Make env available for cell_rt_get_intrinsic lookups */
cell_rt_set_native_env(ctx, env);
/* Try to read nr_slots from the module */
char slots_sym[128];
snprintf(slots_sym, sizeof(slots_sym), "%s_nr_slots", used_name);
int *slots_ptr = (int *)dlsym(dl_handle, slots_sym);
int nr_slots = slots_ptr ? *slots_ptr : 512;
return native_module_run(ctx, dl_handle, fn, nr_slots);
return native_module_run(ctx, dl_handle, fn, nr_slots, env);
}
void cell_rt_free_native_state(JSContext *ctx) {
@@ -1281,12 +1242,6 @@ void cell_rt_free_native_state(JSContext *ctx) {
aot_clear_lit_pool(ctx, st);
if (st->has_native_env && st->native_env_ref_inited) {
JS_DeleteGCRef(ctx, &st->native_env_ref);
st->native_env_ref_inited = 0;
st->native_env_ref.val = JS_NULL;
}
for (int ci = 0; ci < st->gc_ref_chunk_count; ci++) {
AOTGCRefChunk *chunk = st->gc_ref_chunks[ci];
if (!chunk) continue;

View File

@@ -1287,8 +1287,8 @@ JSValue js_key_from_string (JSContext *ctx, JSValue val);
/* mach.c exports */
JSValue JS_CallRegisterVM(JSContext *ctx, JSCodeRegister *code, JSValue this_obj, int argc, JSValue *argv, JSValue env, JSValue outer_frame);
JSValue js_new_native_function(JSContext *ctx, void *fn_ptr, void *dl_handle, uint16_t nr_slots, int arity, JSValue outer_frame);
JSValue js_new_native_function_with_code(JSContext *ctx, JSValue code_obj, int arity, JSValue outer_frame);
JSValue js_new_native_function(JSContext *ctx, void *fn_ptr, void *dl_handle, uint16_t nr_slots, int arity, JSValue outer_frame, JSValue env);
JSValue js_new_native_function_with_code(JSContext *ctx, JSValue code_obj, int arity, JSValue outer_frame, JSValue env_record);
JSFrameRegister *alloc_frame_register(JSContext *ctx, int slot_count);
void cell_rt_free_native_state(JSContext *ctx);

View File

@@ -1834,6 +1834,7 @@ var streamline = function(ir, log) {
move: [1], load_field: [1], load_index: [1], load_dynamic: [1],
pop: [1], frame: [1], goframe: [1],
setarg: [], store_field: [], store_index: [], store_dynamic: [],
delete: [1],
push: [], set_var: [], stone_text: [],
jump: [], jump_true: [], jump_false: [], jump_not_null: [],
wary_true: [], wary_false: [], jump_null: [], jump_empty: [],
@@ -1847,7 +1848,7 @@ var streamline = function(ir, log) {
move: [2], load_field: [2], load_index: [2, 3], load_dynamic: [2, 3],
pop: [2], frame: [2], goframe: [2],
setarg: [1, 3], store_field: [1, 3], store_index: [1, 2, 3],
store_dynamic: [1, 2, 3],
store_dynamic: [1, 2, 3], delete: [2],
push: [1, 2], set_var: [1], stone_text: [1],
jump: [], jump_true: [1], jump_false: [1], jump_not_null: [1],
wary_true: [1], wary_false: [1], jump_null: [1], jump_empty: [1],

View File

@@ -3461,6 +3461,16 @@ run("delete nonexistent", function() {
if (obj.a != 1) fail("delete nonexistent should not affect object")
})
run("delete then nested closure", function() {
var r = {a: 1, b: 2}
delete r.b
var f = function(x) {
return function() { return x }
}
var g = f(10)
assert_eq(g(), 10, "nested closure after delete")
})
// ============================================================================
// TYPEOF-LIKE BEHAVIOR
// ============================================================================