@markw65/monkeyc-optimizer 1.1.51 → 1.1.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/build/api.cjs +34 -34
- package/build/{chunk-HKWBVOEL.cjs → chunk-32NRMXAJ.cjs} +552 -142
- package/build/optimizer.cjs +16 -16
- package/build/sdk-util.cjs +14 -14
- package/build/src/optimizer-types.d.ts +1 -2
- package/build/src/readprg/bytecode.d.ts +1 -0
- package/build/src/readprg/header.d.ts +1 -0
- package/build/src/readprg/opcodes.d.ts +104 -3
- package/build/src/sdk-util.d.ts +1 -0
- package/build/worker-thread.cjs +3 -3
- package/package.json +2 -2
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_32NRMXAJ_exports = {};
|
|
30
|
+
__export(chunk_32NRMXAJ_exports, {
|
|
31
31
|
EnumTagsConst: () => EnumTagsConst,
|
|
32
32
|
LastTypeTag: () => LastTypeTag,
|
|
33
33
|
ObjectLikeTagsConst: () => ObjectLikeTagsConst,
|
|
@@ -133,7 +133,7 @@ __export(chunk_HKWBVOEL_exports, {
|
|
|
133
133
|
visitorNode: () => visitorNode,
|
|
134
134
|
xml_util_exports: () => xml_util_exports
|
|
135
135
|
});
|
|
136
|
-
module.exports = __toCommonJS(
|
|
136
|
+
module.exports = __toCommonJS(chunk_32NRMXAJ_exports);
|
|
137
137
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
138
138
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
139
139
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
@@ -5311,26 +5311,35 @@ function parseData(view, symbols) {
|
|
|
5311
5311
|
let current = 0;
|
|
5312
5312
|
while (current < view.byteLength) {
|
|
5313
5313
|
const code = view.getInt32(current);
|
|
5314
|
-
if (code === -1046127121) {
|
|
5315
|
-
current = skipClassDef(view, current + 4, symbols);
|
|
5314
|
+
if (code === -1046127121 || code === -1029349905) {
|
|
5315
|
+
current = skipClassDef(view, current + 4, symbols, code);
|
|
5316
5316
|
} else if (view.getUint8(current) === 1) {
|
|
5317
5317
|
current = symbols.parseSymbol(view, current, current + 1);
|
|
5318
|
+
} else if (view.getUint8(current) === 3) {
|
|
5319
|
+
current += view.getUint32(current + 1) + 6;
|
|
5318
5320
|
} else {
|
|
5319
5321
|
throw new Error(`Unknown code: ${code}`);
|
|
5320
5322
|
}
|
|
5321
5323
|
}
|
|
5322
5324
|
}
|
|
5323
|
-
function skipClassDef(view, current, symbols) {
|
|
5324
|
-
|
|
5325
|
-
current
|
|
5326
|
-
|
|
5327
|
-
|
|
5325
|
+
function skipClassDef(view, current, symbols, code) {
|
|
5326
|
+
const isVariableSized = code === -1029349905;
|
|
5327
|
+
const flags = isVariableSized ? view.getUint8(current++) : -1;
|
|
5328
|
+
if (flags & 1)
|
|
5329
|
+
current += 4;
|
|
5330
|
+
if (flags & 2)
|
|
5331
|
+
current += 4;
|
|
5332
|
+
if (flags & 4)
|
|
5333
|
+
current += 4;
|
|
5334
|
+
if (flags & 8)
|
|
5335
|
+
current += 4;
|
|
5328
5336
|
current += 2;
|
|
5329
|
-
let fields = view.getUint8(current++);
|
|
5337
|
+
let fields = isVariableSized ? view.getUint16((current += 2) - 2) : view.getUint8(current++);
|
|
5330
5338
|
while (fields--) {
|
|
5331
5339
|
const f1 = view.getUint32((current += 4) - 4);
|
|
5340
|
+
const type = isVariableSized ? view.getUint8(current++) : f1 & 15;
|
|
5332
5341
|
const addr = view.getUint32((current += 4) - 4);
|
|
5333
|
-
if (
|
|
5342
|
+
if (type !== 6)
|
|
5334
5343
|
continue;
|
|
5335
5344
|
const section = addr >>> 28;
|
|
5336
5345
|
if (section === 1) {
|
|
@@ -5362,26 +5371,35 @@ function fixupData(context, offsetMap) {
|
|
|
5362
5371
|
let current = 0;
|
|
5363
5372
|
while (current < view.byteLength) {
|
|
5364
5373
|
const code = view.getInt32(current);
|
|
5365
|
-
if (code === -1046127121) {
|
|
5366
|
-
current = fixupClassDef(view, current + 4, offsetMap);
|
|
5374
|
+
if (code === -1046127121 || code === -1029349905) {
|
|
5375
|
+
current = fixupClassDef(view, current + 4, offsetMap, code);
|
|
5367
5376
|
} else if (view.getUint8(current) === 1) {
|
|
5368
5377
|
current = symbols.parseSymbol(view, current, current + 1);
|
|
5378
|
+
} else if (view.getUint8(current) === 3) {
|
|
5379
|
+
current += view.getUint32(current + 1) + 6;
|
|
5369
5380
|
} else {
|
|
5370
5381
|
throw new Error(`Unknown code: ${code}`);
|
|
5371
5382
|
}
|
|
5372
5383
|
}
|
|
5373
5384
|
}
|
|
5374
|
-
function fixupClassDef(view, current, offsetMap) {
|
|
5375
|
-
|
|
5376
|
-
current
|
|
5377
|
-
|
|
5378
|
-
|
|
5385
|
+
function fixupClassDef(view, current, offsetMap, code) {
|
|
5386
|
+
const isVariableSized = code === -1029349905;
|
|
5387
|
+
const flags = isVariableSized ? view.getUint8(current++) : -1;
|
|
5388
|
+
if (flags & 1)
|
|
5389
|
+
current += 4;
|
|
5390
|
+
if (flags & 2)
|
|
5391
|
+
current += 4;
|
|
5392
|
+
if (flags & 4)
|
|
5393
|
+
current += 4;
|
|
5394
|
+
if (flags & 8)
|
|
5395
|
+
current += 4;
|
|
5379
5396
|
current += 2;
|
|
5380
|
-
let fields = view.getUint8(current++);
|
|
5397
|
+
let fields = isVariableSized ? view.getUint16((current += 2) - 2) : view.getUint8(current++);
|
|
5381
5398
|
while (fields--) {
|
|
5382
5399
|
const f1 = view.getUint32((current += 4) - 4);
|
|
5400
|
+
const type = isVariableSized ? view.getUint8(current++) : f1 & 15;
|
|
5383
5401
|
const addr = view.getUint32((current += 4) - 4);
|
|
5384
|
-
if (
|
|
5402
|
+
if (type !== 6)
|
|
5385
5403
|
continue;
|
|
5386
5404
|
const section = addr >>> 28;
|
|
5387
5405
|
if (section === 1) {
|
|
@@ -16656,7 +16674,11 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
16656
16674
|
const ret = preEvaluate(istate, node);
|
|
16657
16675
|
switch (node.type) {
|
|
16658
16676
|
case "EnumDeclaration":
|
|
16659
|
-
return [];
|
|
16677
|
+
return ["body"];
|
|
16678
|
+
case "EnumStringBody":
|
|
16679
|
+
return ["members"];
|
|
16680
|
+
case "EnumStringMember":
|
|
16681
|
+
return ["init"];
|
|
16660
16682
|
case "ForStatement": {
|
|
16661
16683
|
const map2 = topLocals().map;
|
|
16662
16684
|
if (map2) {
|
|
@@ -17083,20 +17105,18 @@ function cleanup(state, node, ast) {
|
|
|
17083
17105
|
const name = "name" in m ? m.name : m.id.name;
|
|
17084
17106
|
return (0, import_chunk_MBTLUWXR.hasProperty)(state.index, name) && !(0, import_chunk_MBTLUWXR.hasProperty)(state.exposed, name) && !(0, import_chunk_MBTLUWXR.hasProperty)(state.usedByName, name);
|
|
17085
17107
|
})) {
|
|
17086
|
-
|
|
17087
|
-
|
|
17088
|
-
|
|
17089
|
-
|
|
17090
|
-
|
|
17091
|
-
|
|
17092
|
-
|
|
17093
|
-
|
|
17094
|
-
|
|
17095
|
-
|
|
17096
|
-
|
|
17097
|
-
|
|
17098
|
-
].join(" or ");
|
|
17099
|
-
node.members.splice(0);
|
|
17108
|
+
const enumType = new Set(
|
|
17109
|
+
node.members.map((m) => {
|
|
17110
|
+
if (!("init" in m))
|
|
17111
|
+
return "Number";
|
|
17112
|
+
const [node2, type] = (0, import_chunk_MBTLUWXR.getNodeValue)(m.init);
|
|
17113
|
+
return node2 ? type : null;
|
|
17114
|
+
})
|
|
17115
|
+
);
|
|
17116
|
+
if (!enumType.has(null)) {
|
|
17117
|
+
node.enumType = [...enumType].join(" or ");
|
|
17118
|
+
node.members.splice(0);
|
|
17119
|
+
}
|
|
17100
17120
|
}
|
|
17101
17121
|
break;
|
|
17102
17122
|
case "EnumDeclaration":
|
|
@@ -18705,17 +18725,16 @@ function stateFuncs() {
|
|
|
18705
18725
|
}
|
|
18706
18726
|
const name = m.id.name;
|
|
18707
18727
|
const init = (0, import_chunk_MBTLUWXR.getLiteralNode)(m.init);
|
|
18708
|
-
if (
|
|
18709
|
-
|
|
18710
|
-
|
|
18711
|
-
|
|
18712
|
-
|
|
18713
|
-
init
|
|
18728
|
+
if (init) {
|
|
18729
|
+
if (init !== m.init) {
|
|
18730
|
+
if (m.init.enumType) {
|
|
18731
|
+
init.enumType = m.init.enumType;
|
|
18732
|
+
}
|
|
18733
|
+
m.init = init;
|
|
18734
|
+
}
|
|
18735
|
+
if (init.type === "Literal" && init.raw && import_prettier_plugin_monkeyc4.LiteralIntegerRe.test(init.raw)) {
|
|
18736
|
+
prev = init.value;
|
|
18714
18737
|
}
|
|
18715
|
-
m.init = init;
|
|
18716
|
-
}
|
|
18717
|
-
if (init.type === "Literal" && init.raw && import_prettier_plugin_monkeyc4.LiteralIntegerRe.test(init.raw)) {
|
|
18718
|
-
prev = init.value;
|
|
18719
18738
|
}
|
|
18720
18739
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(values, name)) {
|
|
18721
18740
|
values[name] = [];
|
|
@@ -19758,6 +19777,16 @@ function parseCode(view, lineTable) {
|
|
|
19758
19777
|
case 47:
|
|
19759
19778
|
case 10:
|
|
19760
19779
|
case 11:
|
|
19780
|
+
case 55:
|
|
19781
|
+
case 59:
|
|
19782
|
+
case 60:
|
|
19783
|
+
case 61:
|
|
19784
|
+
case 72:
|
|
19785
|
+
case 62:
|
|
19786
|
+
case 63:
|
|
19787
|
+
case 68:
|
|
19788
|
+
case 73:
|
|
19789
|
+
case 75:
|
|
19761
19790
|
return { op, offset, size: 1 };
|
|
19762
19791
|
case 1:
|
|
19763
19792
|
case 15:
|
|
@@ -19766,6 +19795,7 @@ function parseCode(view, lineTable) {
|
|
|
19766
19795
|
case 43:
|
|
19767
19796
|
case 46:
|
|
19768
19797
|
case 53:
|
|
19798
|
+
case 56:
|
|
19769
19799
|
return { op, arg: view.getUint8(current++), offset, size: 2 };
|
|
19770
19800
|
case 25:
|
|
19771
19801
|
case 35:
|
|
@@ -19777,11 +19807,60 @@ function parseCode(view, lineTable) {
|
|
|
19777
19807
|
offset,
|
|
19778
19808
|
size: 3
|
|
19779
19809
|
};
|
|
19810
|
+
case 57:
|
|
19811
|
+
return {
|
|
19812
|
+
op,
|
|
19813
|
+
arg: view.getInt16((current += 2) - 2),
|
|
19814
|
+
offset,
|
|
19815
|
+
size: 3
|
|
19816
|
+
};
|
|
19817
|
+
case 58:
|
|
19818
|
+
return {
|
|
19819
|
+
op,
|
|
19820
|
+
arg: view.getInt32((current += 3) - 3) >> 8,
|
|
19821
|
+
offset,
|
|
19822
|
+
size: 4
|
|
19823
|
+
};
|
|
19780
19824
|
case 24:
|
|
19825
|
+
case 64:
|
|
19826
|
+
case 65:
|
|
19827
|
+
case 66:
|
|
19781
19828
|
case 37:
|
|
19782
19829
|
case 39:
|
|
19783
19830
|
case 52:
|
|
19831
|
+
case 71:
|
|
19832
|
+
case 67:
|
|
19784
19833
|
return { op, arg: view.getInt32((current += 4) - 4), offset, size: 5 };
|
|
19834
|
+
case 69:
|
|
19835
|
+
return {
|
|
19836
|
+
op,
|
|
19837
|
+
arg: {
|
|
19838
|
+
module: view.getInt32((current += 4) - 4),
|
|
19839
|
+
var: view.getInt32((current += 4) - 4)
|
|
19840
|
+
},
|
|
19841
|
+
offset,
|
|
19842
|
+
size: 9
|
|
19843
|
+
};
|
|
19844
|
+
case 70:
|
|
19845
|
+
return {
|
|
19846
|
+
op,
|
|
19847
|
+
arg: {
|
|
19848
|
+
local: view.getUint8(current++),
|
|
19849
|
+
var: view.getInt32((current += 4) - 4)
|
|
19850
|
+
},
|
|
19851
|
+
offset,
|
|
19852
|
+
size: 6
|
|
19853
|
+
};
|
|
19854
|
+
case 74:
|
|
19855
|
+
return {
|
|
19856
|
+
op,
|
|
19857
|
+
arg: {
|
|
19858
|
+
argc: view.getUint8(current++),
|
|
19859
|
+
incsp: view.getUint8(current++)
|
|
19860
|
+
},
|
|
19861
|
+
offset,
|
|
19862
|
+
size: 3
|
|
19863
|
+
};
|
|
19785
19864
|
case 49:
|
|
19786
19865
|
return {
|
|
19787
19866
|
op,
|
|
@@ -19857,6 +19936,16 @@ function opcodeSize(op) {
|
|
|
19857
19936
|
case 20:
|
|
19858
19937
|
case 54:
|
|
19859
19938
|
case 47:
|
|
19939
|
+
case 55:
|
|
19940
|
+
case 59:
|
|
19941
|
+
case 60:
|
|
19942
|
+
case 61:
|
|
19943
|
+
case 72:
|
|
19944
|
+
case 62:
|
|
19945
|
+
case 63:
|
|
19946
|
+
case 68:
|
|
19947
|
+
case 73:
|
|
19948
|
+
case 75:
|
|
19860
19949
|
return 1;
|
|
19861
19950
|
case 1:
|
|
19862
19951
|
case 15:
|
|
@@ -19867,20 +19956,33 @@ function opcodeSize(op) {
|
|
|
19867
19956
|
case 53:
|
|
19868
19957
|
case 10:
|
|
19869
19958
|
case 11:
|
|
19959
|
+
case 56:
|
|
19870
19960
|
return 2;
|
|
19871
19961
|
case 25:
|
|
19872
19962
|
case 35:
|
|
19873
19963
|
case 40:
|
|
19874
19964
|
case 41:
|
|
19965
|
+
case 57:
|
|
19966
|
+
case 74:
|
|
19875
19967
|
return 3;
|
|
19968
|
+
case 58:
|
|
19969
|
+
return 4;
|
|
19970
|
+
case 64:
|
|
19971
|
+
case 65:
|
|
19972
|
+
case 66:
|
|
19876
19973
|
case 24:
|
|
19877
19974
|
case 37:
|
|
19878
19975
|
case 39:
|
|
19879
19976
|
case 52:
|
|
19880
19977
|
case 38:
|
|
19978
|
+
case 71:
|
|
19979
|
+
case 67:
|
|
19881
19980
|
return 5;
|
|
19981
|
+
case 70:
|
|
19982
|
+
return 6;
|
|
19882
19983
|
case 49:
|
|
19883
19984
|
case 50:
|
|
19985
|
+
case 69:
|
|
19884
19986
|
return 9;
|
|
19885
19987
|
case 36:
|
|
19886
19988
|
throw new Error(`Unknown opcode ${op}`);
|
|
@@ -19908,6 +20010,7 @@ function emitBytecode(bytecode, view, offset, linktable, shift_hack) {
|
|
|
19908
20010
|
case 43:
|
|
19909
20011
|
case 46:
|
|
19910
20012
|
case 53:
|
|
20013
|
+
case 56:
|
|
19911
20014
|
view.setUint8(offset++, bytecode.arg);
|
|
19912
20015
|
break;
|
|
19913
20016
|
case 25:
|
|
@@ -19917,12 +20020,36 @@ function emitBytecode(bytecode, view, offset, linktable, shift_hack) {
|
|
|
19917
20020
|
linktable.set(offset, bytecode.arg);
|
|
19918
20021
|
view.setInt16((offset += 2) - 2, 0);
|
|
19919
20022
|
break;
|
|
20023
|
+
case 57:
|
|
20024
|
+
view.setInt16((offset += 2) - 2, bytecode.arg);
|
|
20025
|
+
break;
|
|
20026
|
+
case 58:
|
|
20027
|
+
view.setInt32((offset += 3) - 3, bytecode.arg << 8);
|
|
20028
|
+
break;
|
|
20029
|
+
case 64:
|
|
20030
|
+
case 65:
|
|
20031
|
+
case 66:
|
|
20032
|
+
case 67:
|
|
20033
|
+
case 71:
|
|
19920
20034
|
case 24:
|
|
19921
20035
|
case 37:
|
|
19922
20036
|
case 39:
|
|
19923
|
-
case 52:
|
|
20037
|
+
case 52: {
|
|
19924
20038
|
view.setInt32((offset += 4) - 4, bytecode.arg);
|
|
19925
20039
|
break;
|
|
20040
|
+
}
|
|
20041
|
+
case 69:
|
|
20042
|
+
view.setInt32((offset += 4) - 4, bytecode.arg.module);
|
|
20043
|
+
view.setInt32((offset += 4) - 4, bytecode.arg.var);
|
|
20044
|
+
break;
|
|
20045
|
+
case 70:
|
|
20046
|
+
view.setUint8(offset++, bytecode.arg.local);
|
|
20047
|
+
view.setInt32((offset += 4) - 4, bytecode.arg.var);
|
|
20048
|
+
break;
|
|
20049
|
+
case 74:
|
|
20050
|
+
view.setUint8(offset++, bytecode.arg.argc);
|
|
20051
|
+
view.setUint8(offset++, bytecode.arg.incsp);
|
|
20052
|
+
break;
|
|
19926
20053
|
case 49:
|
|
19927
20054
|
view.setBigInt64((offset += 8) - 8, bytecode.arg);
|
|
19928
20055
|
break;
|
|
@@ -19943,6 +20070,7 @@ function getOpInfo(bytecode) {
|
|
|
19943
20070
|
case 23:
|
|
19944
20071
|
case 1:
|
|
19945
20072
|
case 53:
|
|
20073
|
+
case 74:
|
|
19946
20074
|
case 25:
|
|
19947
20075
|
case 35:
|
|
19948
20076
|
return { pop: 0, push: 0 };
|
|
@@ -19978,27 +20106,49 @@ function getOpInfo(bytecode) {
|
|
|
19978
20106
|
case 14:
|
|
19979
20107
|
case 17:
|
|
19980
20108
|
return { pop: 3, push: 0 };
|
|
20109
|
+
case 73:
|
|
20110
|
+
return { pop: 3, push: 1 };
|
|
19981
20111
|
case 21:
|
|
19982
20112
|
case 32:
|
|
20113
|
+
case 75:
|
|
19983
20114
|
case 45:
|
|
19984
20115
|
case 48:
|
|
19985
20116
|
case 20:
|
|
19986
20117
|
case 54:
|
|
19987
20118
|
case 47:
|
|
20119
|
+
case 71:
|
|
19988
20120
|
return { pop: 1, push: 1 };
|
|
20121
|
+
case 64:
|
|
20122
|
+
case 65:
|
|
20123
|
+
case 66:
|
|
20124
|
+
case 67:
|
|
20125
|
+
case 68:
|
|
20126
|
+
case 69:
|
|
20127
|
+
case 70:
|
|
19989
20128
|
case 42:
|
|
19990
20129
|
case 44:
|
|
19991
20130
|
case 43:
|
|
20131
|
+
case 62:
|
|
20132
|
+
case 63:
|
|
19992
20133
|
case 18:
|
|
19993
20134
|
case 46:
|
|
19994
20135
|
case 24:
|
|
19995
20136
|
case 37:
|
|
20137
|
+
case 55:
|
|
20138
|
+
case 56:
|
|
20139
|
+
case 57:
|
|
20140
|
+
case 58:
|
|
19996
20141
|
case 38:
|
|
20142
|
+
case 59:
|
|
19997
20143
|
case 39:
|
|
19998
20144
|
case 52:
|
|
19999
20145
|
case 49:
|
|
20146
|
+
case 60:
|
|
20000
20147
|
case 50:
|
|
20148
|
+
case 61:
|
|
20001
20149
|
return { pop: 0, push: 1 };
|
|
20150
|
+
case 72:
|
|
20151
|
+
return { pop: 1, push: 1 };
|
|
20002
20152
|
case 15:
|
|
20003
20153
|
return { pop: bytecode.arg + 1, push: 1 };
|
|
20004
20154
|
case 36:
|
|
@@ -20014,15 +20164,27 @@ function getOpEffects(bytecode) {
|
|
|
20014
20164
|
case 14:
|
|
20015
20165
|
return 2;
|
|
20016
20166
|
case 17:
|
|
20167
|
+
case 73:
|
|
20017
20168
|
return 4;
|
|
20018
20169
|
case 21:
|
|
20019
20170
|
return 2 | 4;
|
|
20020
20171
|
case 15:
|
|
20172
|
+
case 72:
|
|
20021
20173
|
return 8 | 2 | 4;
|
|
20174
|
+
case 13:
|
|
20175
|
+
case 67:
|
|
20176
|
+
case 69:
|
|
20177
|
+
case 70:
|
|
20178
|
+
case 71:
|
|
20179
|
+
case 16:
|
|
20180
|
+
return 0;
|
|
20181
|
+
case 18:
|
|
20182
|
+
return 0;
|
|
20022
20183
|
case 0:
|
|
20023
20184
|
case 23:
|
|
20024
20185
|
case 1:
|
|
20025
20186
|
case 53:
|
|
20187
|
+
case 74:
|
|
20026
20188
|
case 25:
|
|
20027
20189
|
case 35:
|
|
20028
20190
|
case 2:
|
|
@@ -20048,9 +20210,9 @@ function getOpEffects(bytecode) {
|
|
|
20048
20210
|
case 31:
|
|
20049
20211
|
case 34:
|
|
20050
20212
|
case 33:
|
|
20051
|
-
case
|
|
20052
|
-
case 16:
|
|
20213
|
+
case 68:
|
|
20053
20214
|
case 32:
|
|
20215
|
+
case 75:
|
|
20054
20216
|
case 45:
|
|
20055
20217
|
case 48:
|
|
20056
20218
|
case 20:
|
|
@@ -20058,16 +20220,27 @@ function getOpEffects(bytecode) {
|
|
|
20058
20220
|
case 47:
|
|
20059
20221
|
case 42:
|
|
20060
20222
|
case 44:
|
|
20223
|
+
case 64:
|
|
20224
|
+
case 65:
|
|
20225
|
+
case 66:
|
|
20061
20226
|
case 43:
|
|
20062
|
-
case
|
|
20227
|
+
case 62:
|
|
20228
|
+
case 63:
|
|
20063
20229
|
case 46:
|
|
20064
20230
|
case 24:
|
|
20065
20231
|
case 37:
|
|
20232
|
+
case 55:
|
|
20233
|
+
case 56:
|
|
20234
|
+
case 57:
|
|
20235
|
+
case 58:
|
|
20066
20236
|
case 38:
|
|
20237
|
+
case 59:
|
|
20067
20238
|
case 39:
|
|
20068
20239
|
case 52:
|
|
20069
20240
|
case 49:
|
|
20241
|
+
case 60:
|
|
20070
20242
|
case 50:
|
|
20243
|
+
case 61:
|
|
20071
20244
|
return 0;
|
|
20072
20245
|
case 36:
|
|
20073
20246
|
throw new Error(`Unknown opcode ${bytecode.op}`);
|
|
@@ -20075,6 +20248,93 @@ function getOpEffects(bytecode) {
|
|
|
20075
20248
|
unhandledType(bytecode);
|
|
20076
20249
|
}
|
|
20077
20250
|
}
|
|
20251
|
+
function opReadsLocal(bytecode) {
|
|
20252
|
+
switch (bytecode.op) {
|
|
20253
|
+
case 67:
|
|
20254
|
+
case 68:
|
|
20255
|
+
case 42:
|
|
20256
|
+
return 0;
|
|
20257
|
+
case 70:
|
|
20258
|
+
return bytecode.arg.local;
|
|
20259
|
+
case 18:
|
|
20260
|
+
return bytecode.arg;
|
|
20261
|
+
case 19:
|
|
20262
|
+
case 14:
|
|
20263
|
+
case 17:
|
|
20264
|
+
case 73:
|
|
20265
|
+
case 21:
|
|
20266
|
+
case 15:
|
|
20267
|
+
case 72:
|
|
20268
|
+
case 13:
|
|
20269
|
+
case 69:
|
|
20270
|
+
case 71:
|
|
20271
|
+
case 16:
|
|
20272
|
+
case 0:
|
|
20273
|
+
case 23:
|
|
20274
|
+
case 1:
|
|
20275
|
+
case 53:
|
|
20276
|
+
case 74:
|
|
20277
|
+
case 25:
|
|
20278
|
+
case 35:
|
|
20279
|
+
case 2:
|
|
20280
|
+
case 22:
|
|
20281
|
+
case 51:
|
|
20282
|
+
case 40:
|
|
20283
|
+
case 41:
|
|
20284
|
+
case 3:
|
|
20285
|
+
case 4:
|
|
20286
|
+
case 5:
|
|
20287
|
+
case 6:
|
|
20288
|
+
case 7:
|
|
20289
|
+
case 8:
|
|
20290
|
+
case 9:
|
|
20291
|
+
case 10:
|
|
20292
|
+
case 11:
|
|
20293
|
+
case 12:
|
|
20294
|
+
case 26:
|
|
20295
|
+
case 27:
|
|
20296
|
+
case 28:
|
|
20297
|
+
case 29:
|
|
20298
|
+
case 30:
|
|
20299
|
+
case 31:
|
|
20300
|
+
case 34:
|
|
20301
|
+
case 33:
|
|
20302
|
+
case 32:
|
|
20303
|
+
case 75:
|
|
20304
|
+
case 45:
|
|
20305
|
+
case 48:
|
|
20306
|
+
case 20:
|
|
20307
|
+
case 54:
|
|
20308
|
+
case 47:
|
|
20309
|
+
case 44:
|
|
20310
|
+
case 64:
|
|
20311
|
+
case 65:
|
|
20312
|
+
case 66:
|
|
20313
|
+
case 43:
|
|
20314
|
+
case 62:
|
|
20315
|
+
case 63:
|
|
20316
|
+
case 46:
|
|
20317
|
+
case 24:
|
|
20318
|
+
case 37:
|
|
20319
|
+
case 55:
|
|
20320
|
+
case 56:
|
|
20321
|
+
case 57:
|
|
20322
|
+
case 58:
|
|
20323
|
+
case 38:
|
|
20324
|
+
case 59:
|
|
20325
|
+
case 39:
|
|
20326
|
+
case 52:
|
|
20327
|
+
case 49:
|
|
20328
|
+
case 60:
|
|
20329
|
+
case 50:
|
|
20330
|
+
case 61:
|
|
20331
|
+
return null;
|
|
20332
|
+
case 36:
|
|
20333
|
+
throw new Error(`Unknown opcode ${bytecode.op}`);
|
|
20334
|
+
default:
|
|
20335
|
+
unhandledType(bytecode);
|
|
20336
|
+
}
|
|
20337
|
+
}
|
|
20078
20338
|
function isBoolOp(op) {
|
|
20079
20339
|
switch (op) {
|
|
20080
20340
|
case 32:
|
|
@@ -20159,6 +20419,27 @@ var init_opcodes = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
20159
20419
|
Opcodes2[Opcodes2["cpush"] = 52] = "cpush";
|
|
20160
20420
|
Opcodes2[Opcodes2["argc"] = 53] = "argc";
|
|
20161
20421
|
Opcodes2[Opcodes2["newba"] = 54] = "newba";
|
|
20422
|
+
Opcodes2[Opcodes2["ipushz"] = 55] = "ipushz";
|
|
20423
|
+
Opcodes2[Opcodes2["ipush1"] = 56] = "ipush1";
|
|
20424
|
+
Opcodes2[Opcodes2["ipush2"] = 57] = "ipush2";
|
|
20425
|
+
Opcodes2[Opcodes2["ipush3"] = 58] = "ipush3";
|
|
20426
|
+
Opcodes2[Opcodes2["fpushz"] = 59] = "fpushz";
|
|
20427
|
+
Opcodes2[Opcodes2["lpushz"] = 60] = "lpushz";
|
|
20428
|
+
Opcodes2[Opcodes2["dpushz"] = 61] = "dpushz";
|
|
20429
|
+
Opcodes2[Opcodes2["btpush"] = 62] = "btpush";
|
|
20430
|
+
Opcodes2[Opcodes2["bfpush"] = 63] = "bfpush";
|
|
20431
|
+
Opcodes2[Opcodes2["apush"] = 64] = "apush";
|
|
20432
|
+
Opcodes2[Opcodes2["bapush"] = 65] = "bapush";
|
|
20433
|
+
Opcodes2[Opcodes2["hpush"] = 66] = "hpush";
|
|
20434
|
+
Opcodes2[Opcodes2["getselfv"] = 67] = "getselfv";
|
|
20435
|
+
Opcodes2[Opcodes2["getself"] = 68] = "getself";
|
|
20436
|
+
Opcodes2[Opcodes2["getmv"] = 69] = "getmv";
|
|
20437
|
+
Opcodes2[Opcodes2["getlocalv"] = 70] = "getlocalv";
|
|
20438
|
+
Opcodes2[Opcodes2["getsv"] = 71] = "getsv";
|
|
20439
|
+
Opcodes2[Opcodes2["invokemz"] = 72] = "invokemz";
|
|
20440
|
+
Opcodes2[Opcodes2["aputvdup"] = 73] = "aputvdup";
|
|
20441
|
+
Opcodes2[Opcodes2["argcincsp"] = 74] = "argcincsp";
|
|
20442
|
+
Opcodes2[Opcodes2["isnotnull"] = 75] = "isnotnull";
|
|
20162
20443
|
return Opcodes2;
|
|
20163
20444
|
})(Opcodes || {});
|
|
20164
20445
|
}
|
|
@@ -20330,7 +20611,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
|
|
|
20330
20611
|
i = -1;
|
|
20331
20612
|
continue;
|
|
20332
20613
|
}
|
|
20333
|
-
if (top.exsucc && (bc.op === 15 || bc.op === 51)) {
|
|
20614
|
+
if (top.exsucc && (bc.op === 15 || bc.op === 72 || bc.op === 51)) {
|
|
20334
20615
|
doMerge(top.exsucc, true);
|
|
20335
20616
|
}
|
|
20336
20617
|
}
|
|
@@ -20616,8 +20897,11 @@ function interpBytecode(bc, localState, context) {
|
|
|
20616
20897
|
localState.stack.splice(-2, 2, { type });
|
|
20617
20898
|
};
|
|
20618
20899
|
switch (bc.op) {
|
|
20900
|
+
case 68:
|
|
20619
20901
|
case 18: {
|
|
20620
|
-
|
|
20902
|
+
const localNum = opReadsLocal(bc);
|
|
20903
|
+
(0, import_node_assert7.default)(localNum != null);
|
|
20904
|
+
let local = localState.locals[localNum];
|
|
20621
20905
|
if (local) {
|
|
20622
20906
|
local = { ...local };
|
|
20623
20907
|
delete local.equivs;
|
|
@@ -20628,7 +20912,7 @@ function interpBytecode(bc, localState, context) {
|
|
|
20628
20912
|
} };
|
|
20629
20913
|
}
|
|
20630
20914
|
localState.stack.push(local);
|
|
20631
|
-
addEquiv2(localState, -localState.stack.length,
|
|
20915
|
+
addEquiv2(localState, -localState.stack.length, localNum);
|
|
20632
20916
|
break;
|
|
20633
20917
|
}
|
|
20634
20918
|
case 46: {
|
|
@@ -20676,18 +20960,33 @@ function interpBytecode(bc, localState, context) {
|
|
|
20676
20960
|
localState.locals[bc.arg].type = value2.type;
|
|
20677
20961
|
break;
|
|
20678
20962
|
}
|
|
20963
|
+
case 55:
|
|
20964
|
+
xpush(8, 0);
|
|
20965
|
+
break;
|
|
20679
20966
|
case 37:
|
|
20967
|
+
case 56:
|
|
20968
|
+
case 57:
|
|
20969
|
+
case 58:
|
|
20680
20970
|
xpush(8, bc.arg);
|
|
20681
20971
|
break;
|
|
20682
20972
|
case 49:
|
|
20683
20973
|
xpush(16, bc.arg);
|
|
20684
20974
|
break;
|
|
20975
|
+
case 60:
|
|
20976
|
+
xpush(16, 0n);
|
|
20977
|
+
break;
|
|
20685
20978
|
case 38:
|
|
20686
20979
|
xpush(32, roundToFloat(bc.arg));
|
|
20687
20980
|
break;
|
|
20981
|
+
case 59:
|
|
20982
|
+
xpush(32, 0);
|
|
20983
|
+
break;
|
|
20688
20984
|
case 50:
|
|
20689
20985
|
xpush(64, bc.arg);
|
|
20690
20986
|
break;
|
|
20987
|
+
case 61:
|
|
20988
|
+
xpush(64, 0);
|
|
20989
|
+
break;
|
|
20691
20990
|
case 52:
|
|
20692
20991
|
xpush(128, String.fromCharCode(bc.arg));
|
|
20693
20992
|
break;
|
|
@@ -20697,6 +20996,18 @@ function interpBytecode(bc, localState, context) {
|
|
|
20697
20996
|
/* False */
|
|
20698
20997
|
);
|
|
20699
20998
|
break;
|
|
20999
|
+
case 62:
|
|
21000
|
+
xpush(
|
|
21001
|
+
4
|
|
21002
|
+
/* True */
|
|
21003
|
+
);
|
|
21004
|
+
break;
|
|
21005
|
+
case 63:
|
|
21006
|
+
xpush(
|
|
21007
|
+
2
|
|
21008
|
+
/* False */
|
|
21009
|
+
);
|
|
21010
|
+
break;
|
|
20700
21011
|
case 44:
|
|
20701
21012
|
xpush(
|
|
20702
21013
|
1
|
|
@@ -21150,31 +21461,31 @@ function instForType(type, offset) {
|
|
|
21150
21461
|
op: 43,
|
|
21151
21462
|
arg: type.type === 2 ? 0 : 1,
|
|
21152
21463
|
offset,
|
|
21153
|
-
size:
|
|
21464
|
+
size: 2
|
|
21154
21465
|
};
|
|
21155
21466
|
case 8:
|
|
21156
|
-
return { op: 37, arg: type.value, offset, size:
|
|
21467
|
+
return { op: 37, arg: type.value, offset, size: 5 };
|
|
21157
21468
|
case 16:
|
|
21158
|
-
return { op: 49, arg: type.value, offset, size:
|
|
21469
|
+
return { op: 49, arg: type.value, offset, size: 9 };
|
|
21159
21470
|
case 32:
|
|
21160
|
-
return { op: 38, arg: type.value, offset, size:
|
|
21471
|
+
return { op: 38, arg: type.value, offset, size: 5 };
|
|
21161
21472
|
case 64:
|
|
21162
|
-
return { op: 50, arg: type.value, offset, size:
|
|
21473
|
+
return { op: 50, arg: type.value, offset, size: 9 };
|
|
21163
21474
|
case 128:
|
|
21164
21475
|
return {
|
|
21165
21476
|
op: 52,
|
|
21166
21477
|
arg: type.value.charCodeAt(0),
|
|
21167
21478
|
offset,
|
|
21168
|
-
size:
|
|
21479
|
+
size: 5
|
|
21169
21480
|
};
|
|
21170
21481
|
case 131072: {
|
|
21171
21482
|
const match = type.value.match(/<(\d+)>$/);
|
|
21172
21483
|
(0, import_node_assert7.default)(match);
|
|
21173
21484
|
return {
|
|
21174
|
-
op:
|
|
21485
|
+
op: 39,
|
|
21175
21486
|
arg: parseInt(match[1], 10),
|
|
21176
21487
|
offset,
|
|
21177
|
-
size:
|
|
21488
|
+
size: 5
|
|
21178
21489
|
};
|
|
21179
21490
|
}
|
|
21180
21491
|
}
|
|
@@ -21626,23 +21937,42 @@ function localDCE(func, context) {
|
|
|
21626
21937
|
}
|
|
21627
21938
|
break;
|
|
21628
21939
|
}
|
|
21940
|
+
case 70:
|
|
21941
|
+
case 68:
|
|
21942
|
+
case 67:
|
|
21629
21943
|
case 18:
|
|
21944
|
+
case 62:
|
|
21945
|
+
case 63:
|
|
21946
|
+
case 42:
|
|
21947
|
+
case 64:
|
|
21948
|
+
case 65:
|
|
21949
|
+
case 66:
|
|
21630
21950
|
case 44:
|
|
21631
21951
|
case 43:
|
|
21632
21952
|
case 24:
|
|
21633
21953
|
case 37:
|
|
21954
|
+
case 55:
|
|
21955
|
+
case 56:
|
|
21956
|
+
case 57:
|
|
21957
|
+
case 58:
|
|
21634
21958
|
case 38:
|
|
21959
|
+
case 59:
|
|
21635
21960
|
case 39:
|
|
21636
21961
|
case 52:
|
|
21637
21962
|
case 49:
|
|
21638
|
-
case
|
|
21963
|
+
case 60:
|
|
21964
|
+
case 50:
|
|
21965
|
+
case 61: {
|
|
21639
21966
|
const item = dceInfo.stack.pop();
|
|
21640
21967
|
if (item?.dead) {
|
|
21641
21968
|
item.deps.push(i);
|
|
21642
21969
|
reportNop(item);
|
|
21643
21970
|
item.deps.forEach((index) => makeNop(block.bytecodes[index]));
|
|
21644
|
-
} else
|
|
21645
|
-
|
|
21971
|
+
} else {
|
|
21972
|
+
const local = opReadsLocal(bytecode);
|
|
21973
|
+
if (local != null) {
|
|
21974
|
+
dceInfo.locals.add(local);
|
|
21975
|
+
}
|
|
21646
21976
|
}
|
|
21647
21977
|
break;
|
|
21648
21978
|
}
|
|
@@ -21680,6 +22010,7 @@ function localDCE(func, context) {
|
|
|
21680
22010
|
}
|
|
21681
22011
|
case 21:
|
|
21682
22012
|
case 32:
|
|
22013
|
+
case 75:
|
|
21683
22014
|
case 45:
|
|
21684
22015
|
case 48:
|
|
21685
22016
|
case 20:
|
|
@@ -21698,10 +22029,26 @@ function localDCE(func, context) {
|
|
|
21698
22029
|
}
|
|
21699
22030
|
case 51:
|
|
21700
22031
|
case 15:
|
|
22032
|
+
case 72:
|
|
21701
22033
|
if (block.exsucc) {
|
|
21702
22034
|
liveInLocals.get(block.exsucc)?.forEach((local) => dceInfo.locals.add(local));
|
|
21703
22035
|
}
|
|
21704
|
-
|
|
22036
|
+
case 17:
|
|
22037
|
+
case 73:
|
|
22038
|
+
case 53:
|
|
22039
|
+
case 1:
|
|
22040
|
+
case 74:
|
|
22041
|
+
case 41:
|
|
22042
|
+
case 40:
|
|
22043
|
+
case 69:
|
|
22044
|
+
case 71:
|
|
22045
|
+
case 25:
|
|
22046
|
+
case 35:
|
|
22047
|
+
case 0:
|
|
22048
|
+
case 14:
|
|
22049
|
+
case 23:
|
|
22050
|
+
case 22:
|
|
22051
|
+
case 36: {
|
|
21705
22052
|
let { push, pop } = getOpInfo(bytecode);
|
|
21706
22053
|
while (push-- > 0) {
|
|
21707
22054
|
dceInfo.stack.pop();
|
|
@@ -21709,7 +22056,10 @@ function localDCE(func, context) {
|
|
|
21709
22056
|
while (pop-- > 0) {
|
|
21710
22057
|
dceInfo.stack.push({ dead: false });
|
|
21711
22058
|
}
|
|
22059
|
+
break;
|
|
21712
22060
|
}
|
|
22061
|
+
default:
|
|
22062
|
+
unhandledType(bytecode);
|
|
21713
22063
|
}
|
|
21714
22064
|
}
|
|
21715
22065
|
if (changes) {
|
|
@@ -21732,18 +22082,22 @@ function computeLiveLocals(func) {
|
|
|
21732
22082
|
(block) => new Set(liveOutLocals.get(block.offset)),
|
|
21733
22083
|
(block, bc, locals) => {
|
|
21734
22084
|
switch (bc.op) {
|
|
21735
|
-
case 18:
|
|
21736
|
-
locals.add(bc.arg);
|
|
21737
|
-
break;
|
|
21738
22085
|
case 19:
|
|
21739
22086
|
locals.delete(bc.arg);
|
|
21740
22087
|
break;
|
|
21741
22088
|
case 51:
|
|
21742
22089
|
case 15:
|
|
22090
|
+
case 72:
|
|
21743
22091
|
if (block.exsucc) {
|
|
21744
22092
|
liveInLocals.get(block.exsucc)?.forEach((local) => locals.add(local));
|
|
21745
22093
|
}
|
|
21746
22094
|
break;
|
|
22095
|
+
default: {
|
|
22096
|
+
const local = opReadsLocal(bc);
|
|
22097
|
+
if (local != null) {
|
|
22098
|
+
locals.add(local);
|
|
22099
|
+
}
|
|
22100
|
+
}
|
|
21747
22101
|
}
|
|
21748
22102
|
},
|
|
21749
22103
|
(block, locals) => {
|
|
@@ -21767,6 +22121,7 @@ function computeLiveLocals(func) {
|
|
|
21767
22121
|
var init_dce = (0, import_chunk_ABYVSU2C.__esm)({
|
|
21768
22122
|
"src/readprg/dce.ts"() {
|
|
21769
22123
|
"use strict";
|
|
22124
|
+
init_data_flow();
|
|
21770
22125
|
(0, import_chunk_SG7ODKRM.init_util)();
|
|
21771
22126
|
init_bytecode();
|
|
21772
22127
|
init_cflow();
|
|
@@ -21796,6 +22151,13 @@ function mergeInto2(from, to) {
|
|
|
21796
22151
|
});
|
|
21797
22152
|
return changed;
|
|
21798
22153
|
}
|
|
22154
|
+
function getLocalNum(key) {
|
|
22155
|
+
if (key.op === 19)
|
|
22156
|
+
return key.arg;
|
|
22157
|
+
const local = opReadsLocal(key);
|
|
22158
|
+
(0, import_node_assert9.default)(local !== null);
|
|
22159
|
+
return local;
|
|
22160
|
+
}
|
|
21799
22161
|
function minimizeLocals2(func, equivSets, context) {
|
|
21800
22162
|
const splitRanges = computeSplitRanges(func, equivSets);
|
|
21801
22163
|
const locals = mergeSplitRanges(splitRanges);
|
|
@@ -21805,21 +22167,22 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21805
22167
|
const colors = /* @__PURE__ */ new Map();
|
|
21806
22168
|
const merge = [];
|
|
21807
22169
|
locals.forEach((local, key) => {
|
|
21808
|
-
|
|
21809
|
-
|
|
21810
|
-
|
|
21811
|
-
|
|
22170
|
+
const localNum = getLocalNum(key);
|
|
22171
|
+
if (key.op !== 19 || localNum === 0) {
|
|
22172
|
+
colors.set(key, localNum);
|
|
22173
|
+
const merged = merge[localNum];
|
|
22174
|
+
if (argc == null || localNum < argc) {
|
|
21812
22175
|
if (merged) {
|
|
21813
|
-
(0, import_node_assert9.default)(!
|
|
22176
|
+
(0, import_node_assert9.default)(!localNum);
|
|
21814
22177
|
merged.push(key);
|
|
21815
22178
|
} else {
|
|
21816
|
-
merge[
|
|
22179
|
+
merge[localNum] = [key];
|
|
21817
22180
|
}
|
|
21818
22181
|
}
|
|
21819
22182
|
}
|
|
21820
22183
|
});
|
|
21821
22184
|
locals.forEach((local, key) => {
|
|
21822
|
-
if (key.op
|
|
22185
|
+
if (key.op !== 19)
|
|
21823
22186
|
return;
|
|
21824
22187
|
let inUse = 0n;
|
|
21825
22188
|
local.conflicts.forEach((conflict) => {
|
|
@@ -21846,10 +22209,13 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21846
22209
|
if (argc != null && i <= argc)
|
|
21847
22210
|
break;
|
|
21848
22211
|
const merged = merge[i];
|
|
21849
|
-
if (merged
|
|
21850
|
-
|
|
22212
|
+
if (!merged)
|
|
22213
|
+
continue;
|
|
22214
|
+
const firstLocal = getLocalNum(merged[0]);
|
|
22215
|
+
if (firstLocal < i && (argc == null || firstLocal >= argc) && merged.every((elem) => getLocalNum(elem) === firstLocal)) {
|
|
22216
|
+
const j = firstLocal;
|
|
21851
22217
|
const other = merge[j];
|
|
21852
|
-
if (other.every((elem) => elem
|
|
22218
|
+
if (other.every((elem) => getLocalNum(elem) !== j)) {
|
|
21853
22219
|
merge[i] = other;
|
|
21854
22220
|
merge[j] = merged;
|
|
21855
22221
|
merged.forEach((elem) => colors.set(elem, j));
|
|
@@ -21904,6 +22270,20 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21904
22270
|
let filter = false;
|
|
21905
22271
|
block.bytecodes.forEach((bc) => {
|
|
21906
22272
|
switch (bc.op) {
|
|
22273
|
+
case 74: {
|
|
22274
|
+
argc = bc.arg.argc;
|
|
22275
|
+
const newinc = merge.length - argc;
|
|
22276
|
+
if (newinc > 0) {
|
|
22277
|
+
bc.arg.incsp = newinc;
|
|
22278
|
+
} else {
|
|
22279
|
+
const argCount = bc;
|
|
22280
|
+
argCount.op = 53;
|
|
22281
|
+
argCount.arg = argc;
|
|
22282
|
+
argCount.size = 2;
|
|
22283
|
+
filter = true;
|
|
22284
|
+
}
|
|
22285
|
+
break;
|
|
22286
|
+
}
|
|
21907
22287
|
case 53:
|
|
21908
22288
|
argc = bc.arg;
|
|
21909
22289
|
break;
|
|
@@ -21925,11 +22305,16 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21925
22305
|
}
|
|
21926
22306
|
break;
|
|
21927
22307
|
}
|
|
22308
|
+
case 70:
|
|
21928
22309
|
case 18:
|
|
21929
22310
|
case 19: {
|
|
21930
22311
|
const info = fixupMap.get(bc);
|
|
21931
22312
|
(0, import_node_assert9.default)(info != null);
|
|
21932
|
-
bc.
|
|
22313
|
+
if (bc.op === 70) {
|
|
22314
|
+
bc.arg.local = info.color;
|
|
22315
|
+
} else {
|
|
22316
|
+
bc.arg = info.color;
|
|
22317
|
+
}
|
|
21933
22318
|
if (info.range) {
|
|
21934
22319
|
bc.range = info.range;
|
|
21935
22320
|
} else {
|
|
@@ -21937,6 +22322,17 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21937
22322
|
}
|
|
21938
22323
|
break;
|
|
21939
22324
|
}
|
|
22325
|
+
case 42:
|
|
22326
|
+
case 68:
|
|
22327
|
+
case 67: {
|
|
22328
|
+
const info = fixupMap.get(bc);
|
|
22329
|
+
if (info) {
|
|
22330
|
+
(0, import_node_assert9.default)(!info.color);
|
|
22331
|
+
}
|
|
22332
|
+
break;
|
|
22333
|
+
}
|
|
22334
|
+
default:
|
|
22335
|
+
(0, import_node_assert9.default)(!fixupMap.get(bc));
|
|
21940
22336
|
}
|
|
21941
22337
|
});
|
|
21942
22338
|
if (filter) {
|
|
@@ -21952,43 +22348,34 @@ function computeSplitRanges(func, equivSets) {
|
|
|
21952
22348
|
const liveOutLocals = /* @__PURE__ */ new Map();
|
|
21953
22349
|
const liveInLocals = /* @__PURE__ */ new Map();
|
|
21954
22350
|
const splitRanges = /* @__PURE__ */ new Map();
|
|
21955
|
-
const
|
|
21956
|
-
const
|
|
22351
|
+
const recordLocalRead = (locals, bc) => {
|
|
22352
|
+
const localid = opReadsLocal(bc);
|
|
22353
|
+
(0, import_node_assert9.default)(localid != null);
|
|
22354
|
+
const bcs = locals.get(localid);
|
|
21957
22355
|
if (!bcs) {
|
|
21958
|
-
locals.set(
|
|
22356
|
+
locals.set(localid, /* @__PURE__ */ new Set([bc]));
|
|
21959
22357
|
} else {
|
|
21960
22358
|
bcs.add(bc);
|
|
21961
22359
|
}
|
|
21962
22360
|
};
|
|
21963
|
-
const fakeLgetvs = /* @__PURE__ */ new Map();
|
|
21964
22361
|
postOrderPropagate(
|
|
21965
22362
|
func,
|
|
21966
22363
|
(block) => cloneLive(liveOutLocals.get(block.offset)),
|
|
21967
22364
|
(block, bc, locals) => {
|
|
21968
22365
|
switch (bc.op) {
|
|
21969
|
-
case
|
|
21970
|
-
|
|
21971
|
-
|
|
21972
|
-
|
|
21973
|
-
op: 18,
|
|
21974
|
-
arg: 0,
|
|
21975
|
-
size: 2,
|
|
21976
|
-
offset: bc.offset
|
|
21977
|
-
};
|
|
21978
|
-
fakeLgetvs.set(bc, fakeLgetv);
|
|
21979
|
-
}
|
|
21980
|
-
recordLgetv(locals, fakeLgetv);
|
|
21981
|
-
break;
|
|
21982
|
-
}
|
|
22366
|
+
case 68:
|
|
22367
|
+
case 67:
|
|
22368
|
+
case 70:
|
|
22369
|
+
case 42:
|
|
21983
22370
|
case 18:
|
|
21984
|
-
|
|
22371
|
+
recordLocalRead(locals, bc);
|
|
21985
22372
|
break;
|
|
21986
22373
|
case 19: {
|
|
21987
22374
|
let bcs = locals.get(bc.arg);
|
|
21988
22375
|
if (!bcs) {
|
|
21989
22376
|
bcs = /* @__PURE__ */ new Set();
|
|
21990
22377
|
}
|
|
21991
|
-
|
|
22378
|
+
const ranges = splitRanges.get(bc.arg);
|
|
21992
22379
|
const equiv = equivSets.get(bc);
|
|
21993
22380
|
const conflicts = /* @__PURE__ */ new Set();
|
|
21994
22381
|
locals.forEach((liveBcs, local) => {
|
|
@@ -21999,10 +22386,7 @@ function computeSplitRanges(func, equivSets) {
|
|
|
21999
22386
|
liveBcs.forEach((lbc) => conflicts.add(lbc));
|
|
22000
22387
|
});
|
|
22001
22388
|
if (!ranges) {
|
|
22002
|
-
splitRanges.set(
|
|
22003
|
-
bc.arg,
|
|
22004
|
-
ranges = /* @__PURE__ */ new Map([[bc, { live: bcs, conflicts }]])
|
|
22005
|
-
);
|
|
22389
|
+
splitRanges.set(bc.arg, /* @__PURE__ */ new Map([[bc, { live: bcs, conflicts }]]));
|
|
22006
22390
|
} else {
|
|
22007
22391
|
ranges.set(bc, { live: bcs, conflicts });
|
|
22008
22392
|
}
|
|
@@ -22011,6 +22395,7 @@ function computeSplitRanges(func, equivSets) {
|
|
|
22011
22395
|
}
|
|
22012
22396
|
case 51:
|
|
22013
22397
|
case 15:
|
|
22398
|
+
case 72:
|
|
22014
22399
|
if (block.exsucc) {
|
|
22015
22400
|
const from = liveInLocals.get(block.exsucc);
|
|
22016
22401
|
if (from) {
|
|
@@ -22018,6 +22403,8 @@ function computeSplitRanges(func, equivSets) {
|
|
|
22018
22403
|
}
|
|
22019
22404
|
}
|
|
22020
22405
|
break;
|
|
22406
|
+
default:
|
|
22407
|
+
(0, import_node_assert9.default)(opReadsLocal(bc) == null);
|
|
22021
22408
|
}
|
|
22022
22409
|
},
|
|
22023
22410
|
(block, locals) => {
|
|
@@ -22080,7 +22467,7 @@ function mergeSplitRanges(splitRanges) {
|
|
|
22080
22467
|
let lputv = null;
|
|
22081
22468
|
let singleRange = null;
|
|
22082
22469
|
pvSet.forEach((pv) => {
|
|
22083
|
-
if (!lputv || pv.op
|
|
22470
|
+
if (!lputv || pv.op !== 19)
|
|
22084
22471
|
lputv = pv;
|
|
22085
22472
|
});
|
|
22086
22473
|
pvSet.forEach((pv) => {
|
|
@@ -22109,6 +22496,7 @@ function mergeSplitRanges(splitRanges) {
|
|
|
22109
22496
|
v.conflicts = new Set(
|
|
22110
22497
|
Array.from(v.conflicts).flatMap((bc) => {
|
|
22111
22498
|
const r = bcToLiveRange.get(bc);
|
|
22499
|
+
(0, import_node_assert9.default)(r);
|
|
22112
22500
|
if (!r) {
|
|
22113
22501
|
(0, import_node_assert9.default)(bc.arg === 0);
|
|
22114
22502
|
return [];
|
|
@@ -22262,7 +22650,7 @@ function sizeBasedPRE2(func, context) {
|
|
|
22262
22650
|
const bcs = canonicalMap.get(key);
|
|
22263
22651
|
(0, import_node_assert10.default)(bcs);
|
|
22264
22652
|
let index = block.bytecodes.findIndex(
|
|
22265
|
-
(bc2) => bcs.has(bc2) || block.exsucc && (bc2.op === 15 || bc2.op === 51)
|
|
22653
|
+
(bc2) => bcs.has(bc2) || block.exsucc && (bc2.op === 15 || bc2.op === 72 || bc2.op === 51)
|
|
22266
22654
|
);
|
|
22267
22655
|
if (index < 0) {
|
|
22268
22656
|
if (block.next && !block.taken) {
|
|
@@ -23177,6 +23565,7 @@ function getLocalsInfo(func) {
|
|
|
23177
23565
|
break;
|
|
23178
23566
|
case 51:
|
|
23179
23567
|
case 15:
|
|
23568
|
+
case 72:
|
|
23180
23569
|
if (block.exsucc) {
|
|
23181
23570
|
const from = liveInLocals.get(block.exsucc);
|
|
23182
23571
|
if (from) {
|
|
@@ -23270,8 +23659,11 @@ var init_exceptions = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
23270
23659
|
});
|
|
23271
23660
|
function parseHeader(view) {
|
|
23272
23661
|
let offset = 0;
|
|
23273
|
-
const
|
|
23662
|
+
const word = view.getUint32((offset += 4) - 4);
|
|
23663
|
+
const ciqVersion = word & 16777215;
|
|
23664
|
+
const headerVersion = word >>> 24;
|
|
23274
23665
|
const header = {
|
|
23666
|
+
headerVersion,
|
|
23275
23667
|
ciqVersion,
|
|
23276
23668
|
backgroundOffsets: { data: 0, code: 0 },
|
|
23277
23669
|
appLock: false,
|
|
@@ -23296,10 +23688,13 @@ function parseHeader(view) {
|
|
|
23296
23688
|
return header;
|
|
23297
23689
|
}
|
|
23298
23690
|
function fixupHeader(context, updateInfo) {
|
|
23299
|
-
const view = context.sections[
|
|
23691
|
+
const view = (context.sections[
|
|
23300
23692
|
-805253120
|
|
23301
23693
|
/* HEADER */
|
|
23302
|
-
].
|
|
23694
|
+
] ?? context.sections[
|
|
23695
|
+
-805253107
|
|
23696
|
+
/* HEADER_VERSIONED */
|
|
23697
|
+
]).view;
|
|
23303
23698
|
if (context.header.backgroundOffsets.code !== 0) {
|
|
23304
23699
|
const offset = updateInfo.offsetMap.get(
|
|
23305
23700
|
context.header.backgroundOffsets.code
|
|
@@ -23716,6 +24111,16 @@ function lineInfoToString(lineInfo, context) {
|
|
|
23716
24111
|
}
|
|
23717
24112
|
function bytecodeToString(bytecode, symbolTable) {
|
|
23718
24113
|
let arg = null;
|
|
24114
|
+
const symbol = (arg2) => {
|
|
24115
|
+
const argSym = symbolTable?.symbolToLabelMap.get(arg2);
|
|
24116
|
+
if (argSym) {
|
|
24117
|
+
const symbol2 = symbolTable?.symbols.get(argSym);
|
|
24118
|
+
if (symbol2) {
|
|
24119
|
+
return `${symbol2.str} (${arg2})`;
|
|
24120
|
+
}
|
|
24121
|
+
}
|
|
24122
|
+
return arg2.toString();
|
|
24123
|
+
};
|
|
23719
24124
|
switch (bytecode.op) {
|
|
23720
24125
|
case 18:
|
|
23721
24126
|
case 19:
|
|
@@ -23723,30 +24128,31 @@ function bytecodeToString(bytecode, symbolTable) {
|
|
|
23723
24128
|
arg = `${bytecode.range.name} ${bytecode.arg}${bytecode.range.isParam ? " (param)" : ""}`;
|
|
23724
24129
|
}
|
|
23725
24130
|
break;
|
|
23726
|
-
case 39:
|
|
23727
|
-
|
|
23728
|
-
if (argSym) {
|
|
23729
|
-
const symbol = symbolTable?.symbols.get(argSym);
|
|
23730
|
-
if (symbol) {
|
|
23731
|
-
arg = `${symbol.str} (${bytecode.arg})`;
|
|
23732
|
-
}
|
|
23733
|
-
}
|
|
24131
|
+
case 39:
|
|
24132
|
+
arg = symbol(bytecode.arg);
|
|
23734
24133
|
break;
|
|
23735
|
-
}
|
|
23736
24134
|
case 24: {
|
|
23737
|
-
const
|
|
23738
|
-
if (
|
|
23739
|
-
arg = `${JSON.stringify(
|
|
24135
|
+
const symbol2 = symbolTable?.symbols.get(bytecode.arg);
|
|
24136
|
+
if (symbol2) {
|
|
24137
|
+
arg = `${JSON.stringify(symbol2.str)} (${bytecode.arg})`;
|
|
23740
24138
|
}
|
|
23741
24139
|
break;
|
|
23742
24140
|
}
|
|
23743
24141
|
case 40:
|
|
23744
24142
|
case 41:
|
|
23745
24143
|
case 25:
|
|
23746
|
-
case 35:
|
|
24144
|
+
case 35:
|
|
23747
24145
|
arg = offsetToString(bytecode.arg);
|
|
23748
24146
|
break;
|
|
23749
|
-
|
|
24147
|
+
case 70:
|
|
24148
|
+
arg = `${bytecode.range ? `${bytecode.range.name} ${bytecode.arg}${bytecode.range.isParam ? " (param)" : ""}` : bytecode.arg.local} ${symbol(bytecode.arg.var)}`;
|
|
24149
|
+
break;
|
|
24150
|
+
case 69:
|
|
24151
|
+
arg = `${symbol(bytecode.arg.module)} ${symbol(bytecode.arg.var)}`;
|
|
24152
|
+
break;
|
|
24153
|
+
case 74:
|
|
24154
|
+
arg = `${bytecode.arg.argc} ${bytecode.arg.incsp}`;
|
|
24155
|
+
break;
|
|
23750
24156
|
}
|
|
23751
24157
|
if (arg == null && (0, import_chunk_MBTLUWXR.hasProperty)(bytecode, "arg")) {
|
|
23752
24158
|
arg = `${bytecode.arg}`;
|
|
@@ -23801,6 +24207,7 @@ function findFunctions({
|
|
|
23801
24207
|
next = void 0;
|
|
23802
24208
|
break;
|
|
23803
24209
|
case 15:
|
|
24210
|
+
case 72:
|
|
23804
24211
|
mayThrow2 = true;
|
|
23805
24212
|
break;
|
|
23806
24213
|
case 22:
|
|
@@ -23989,8 +24396,8 @@ function splitBlock(func, block, offset) {
|
|
|
23989
24396
|
const fixEx = (block2, isNew) => {
|
|
23990
24397
|
if (block2.exsucc) {
|
|
23991
24398
|
if (!block2.bytecodes.some(
|
|
23992
|
-
(bc) => bc.op === 51 || bc.op === 15
|
|
23993
|
-
/*
|
|
24399
|
+
(bc) => bc.op === 51 || bc.op === 15 || bc.op === 72
|
|
24400
|
+
/* invokemz */
|
|
23994
24401
|
)) {
|
|
23995
24402
|
if (!isNew) {
|
|
23996
24403
|
removePred(func, block2.exsucc, block2.offset);
|
|
@@ -24084,6 +24491,7 @@ var init_bytecode = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
24084
24491
|
init_optimize2();
|
|
24085
24492
|
SectionKinds = /* @__PURE__ */ ((SectionKinds2) => {
|
|
24086
24493
|
SectionKinds2[SectionKinds2["HEADER"] = -805253120] = "HEADER";
|
|
24494
|
+
SectionKinds2[SectionKinds2["HEADER_VERSIONED"] = -805253107] = "HEADER_VERSIONED";
|
|
24087
24495
|
SectionKinds2[SectionKinds2["TEXT"] = -1059145026] = "TEXT";
|
|
24088
24496
|
SectionKinds2[SectionKinds2["DATA"] = -629491010] = "DATA";
|
|
24089
24497
|
SectionKinds2[SectionKinds2["SYMBOLS"] = 1461170197] = "SYMBOLS";
|
|
@@ -28181,12 +28589,13 @@ async function generateOptimizedProject(options) {
|
|
|
28181
28589
|
);
|
|
28182
28590
|
await createLocalBarrels(targets, config);
|
|
28183
28591
|
const buildConfigs = {};
|
|
28184
|
-
|
|
28592
|
+
const pick_one = config.products ? config.products.indexOf("pick-one") : -1;
|
|
28593
|
+
if (pick_one >= 0) {
|
|
28594
|
+
let preferredProduct = 0;
|
|
28595
|
+
options.products = [...options.products];
|
|
28596
|
+
options.products[pick_one] = targets[preferredProduct].product;
|
|
28597
|
+
}
|
|
28185
28598
|
if (config.skipOptimization) {
|
|
28186
|
-
if (pick_one >= 0) {
|
|
28187
|
-
options.products = [...options.products];
|
|
28188
|
-
options.products[pick_one] = targets[0].product;
|
|
28189
|
-
}
|
|
28190
28599
|
return {
|
|
28191
28600
|
jungleFiles: config.jungleFiles,
|
|
28192
28601
|
xml,
|
|
@@ -28209,12 +28618,7 @@ async function generateOptimizedProject(options) {
|
|
|
28209
28618
|
}
|
|
28210
28619
|
buildConfigs[key] = null;
|
|
28211
28620
|
}
|
|
28212
|
-
if (
|
|
28213
|
-
if (pick_one >= 0) {
|
|
28214
|
-
options.products = [...options.products];
|
|
28215
|
-
options.products[pick_one] = p.product;
|
|
28216
|
-
pick_one = -1;
|
|
28217
|
-
}
|
|
28621
|
+
if (!options.products || options.products.includes(p.product) || p.shape && options.products.includes(p.shape)) {
|
|
28218
28622
|
if (!buildConfigs[key]) {
|
|
28219
28623
|
buildConfigs[key] = p.group.optimizerConfig;
|
|
28220
28624
|
configsToBuild++;
|
|
@@ -28565,7 +28969,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
28565
28969
|
const opt_time = await (0, import_chunk_SG7ODKRM.first_modified)(
|
|
28566
28970
|
Object.values(fnMap).map((v) => v.output)
|
|
28567
28971
|
);
|
|
28568
|
-
if (source_time < opt_time &&
|
|
28972
|
+
if (source_time < opt_time && 1712549362694 < opt_time) {
|
|
28569
28973
|
return {
|
|
28570
28974
|
hasTests,
|
|
28571
28975
|
diagnostics: prevDiagnostics,
|
|
@@ -28604,7 +29008,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
28604
29008
|
hasTests: hasTests2,
|
|
28605
29009
|
diagnostics,
|
|
28606
29010
|
sdkVersion,
|
|
28607
|
-
optimizerVersion: "1.1.
|
|
29011
|
+
optimizerVersion: "1.1.53",
|
|
28608
29012
|
...Object.fromEntries(
|
|
28609
29013
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
28610
29014
|
)
|
|
@@ -29063,10 +29467,15 @@ function optimizeProgramBuffer(filepath, view, debugXml, apiDebugXml, key, confi
|
|
|
29063
29467
|
if (apiDebugXml) {
|
|
29064
29468
|
symbolTable.parseXml(apiDebugXml);
|
|
29065
29469
|
}
|
|
29066
|
-
const header = parseHeader(
|
|
29067
|
-
|
|
29068
|
-
|
|
29069
|
-
|
|
29470
|
+
const header = parseHeader(
|
|
29471
|
+
(sections[
|
|
29472
|
+
-805253120
|
|
29473
|
+
/* HEADER */
|
|
29474
|
+
] ?? sections[
|
|
29475
|
+
-805253107
|
|
29476
|
+
/* HEADER_VERSIONED */
|
|
29477
|
+
]).view
|
|
29478
|
+
);
|
|
29070
29479
|
parseData(sections[
|
|
29071
29480
|
-629491010
|
|
29072
29481
|
/* DATA */
|
|
@@ -29370,9 +29779,10 @@ async function getDeviceInfo() {
|
|
|
29370
29779
|
(part) => part.languages.map((lang) => [lang.code, true])
|
|
29371
29780
|
).flat(1)
|
|
29372
29781
|
);
|
|
29782
|
+
const ciqVersions = partNumbers.map((part) => part.connectIQVersion);
|
|
29373
29783
|
return [
|
|
29374
29784
|
deviceId,
|
|
29375
|
-
{ appTypes, deviceFamily, displayName, languages }
|
|
29785
|
+
{ appTypes, deviceFamily, displayName, languages, ciqVersions }
|
|
29376
29786
|
];
|
|
29377
29787
|
});
|
|
29378
29788
|
})
|