@markw65/monkeyc-optimizer 1.1.51 → 1.1.52
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 +4 -0
- package/build/api.cjs +34 -34
- package/build/{chunk-HKWBVOEL.cjs → chunk-J5XJWBYV.cjs} +531 -109
- package/build/optimizer.cjs +16 -16
- package/build/sdk-util.cjs +14 -14
- 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 +1 -1
|
@@ -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_J5XJWBYV_exports = {};
|
|
30
|
+
__export(chunk_J5XJWBYV_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_J5XJWBYV_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) {
|
|
@@ -19758,6 +19776,16 @@ function parseCode(view, lineTable) {
|
|
|
19758
19776
|
case 47:
|
|
19759
19777
|
case 10:
|
|
19760
19778
|
case 11:
|
|
19779
|
+
case 55:
|
|
19780
|
+
case 59:
|
|
19781
|
+
case 60:
|
|
19782
|
+
case 61:
|
|
19783
|
+
case 72:
|
|
19784
|
+
case 62:
|
|
19785
|
+
case 63:
|
|
19786
|
+
case 68:
|
|
19787
|
+
case 73:
|
|
19788
|
+
case 75:
|
|
19761
19789
|
return { op, offset, size: 1 };
|
|
19762
19790
|
case 1:
|
|
19763
19791
|
case 15:
|
|
@@ -19766,6 +19794,7 @@ function parseCode(view, lineTable) {
|
|
|
19766
19794
|
case 43:
|
|
19767
19795
|
case 46:
|
|
19768
19796
|
case 53:
|
|
19797
|
+
case 56:
|
|
19769
19798
|
return { op, arg: view.getUint8(current++), offset, size: 2 };
|
|
19770
19799
|
case 25:
|
|
19771
19800
|
case 35:
|
|
@@ -19777,11 +19806,60 @@ function parseCode(view, lineTable) {
|
|
|
19777
19806
|
offset,
|
|
19778
19807
|
size: 3
|
|
19779
19808
|
};
|
|
19809
|
+
case 57:
|
|
19810
|
+
return {
|
|
19811
|
+
op,
|
|
19812
|
+
arg: view.getInt16((current += 2) - 2),
|
|
19813
|
+
offset,
|
|
19814
|
+
size: 3
|
|
19815
|
+
};
|
|
19816
|
+
case 58:
|
|
19817
|
+
return {
|
|
19818
|
+
op,
|
|
19819
|
+
arg: view.getInt32((current += 3) - 3) >> 8,
|
|
19820
|
+
offset,
|
|
19821
|
+
size: 4
|
|
19822
|
+
};
|
|
19780
19823
|
case 24:
|
|
19824
|
+
case 64:
|
|
19825
|
+
case 65:
|
|
19826
|
+
case 66:
|
|
19781
19827
|
case 37:
|
|
19782
19828
|
case 39:
|
|
19783
19829
|
case 52:
|
|
19830
|
+
case 71:
|
|
19831
|
+
case 67:
|
|
19784
19832
|
return { op, arg: view.getInt32((current += 4) - 4), offset, size: 5 };
|
|
19833
|
+
case 69:
|
|
19834
|
+
return {
|
|
19835
|
+
op,
|
|
19836
|
+
arg: {
|
|
19837
|
+
module: view.getInt32((current += 4) - 4),
|
|
19838
|
+
var: view.getInt32((current += 4) - 4)
|
|
19839
|
+
},
|
|
19840
|
+
offset,
|
|
19841
|
+
size: 9
|
|
19842
|
+
};
|
|
19843
|
+
case 70:
|
|
19844
|
+
return {
|
|
19845
|
+
op,
|
|
19846
|
+
arg: {
|
|
19847
|
+
local: view.getUint8(current++),
|
|
19848
|
+
var: view.getInt32((current += 4) - 4)
|
|
19849
|
+
},
|
|
19850
|
+
offset,
|
|
19851
|
+
size: 6
|
|
19852
|
+
};
|
|
19853
|
+
case 74:
|
|
19854
|
+
return {
|
|
19855
|
+
op,
|
|
19856
|
+
arg: {
|
|
19857
|
+
argc: view.getUint8(current++),
|
|
19858
|
+
incsp: view.getUint8(current++)
|
|
19859
|
+
},
|
|
19860
|
+
offset,
|
|
19861
|
+
size: 3
|
|
19862
|
+
};
|
|
19785
19863
|
case 49:
|
|
19786
19864
|
return {
|
|
19787
19865
|
op,
|
|
@@ -19857,6 +19935,16 @@ function opcodeSize(op) {
|
|
|
19857
19935
|
case 20:
|
|
19858
19936
|
case 54:
|
|
19859
19937
|
case 47:
|
|
19938
|
+
case 55:
|
|
19939
|
+
case 59:
|
|
19940
|
+
case 60:
|
|
19941
|
+
case 61:
|
|
19942
|
+
case 72:
|
|
19943
|
+
case 62:
|
|
19944
|
+
case 63:
|
|
19945
|
+
case 68:
|
|
19946
|
+
case 73:
|
|
19947
|
+
case 75:
|
|
19860
19948
|
return 1;
|
|
19861
19949
|
case 1:
|
|
19862
19950
|
case 15:
|
|
@@ -19867,20 +19955,33 @@ function opcodeSize(op) {
|
|
|
19867
19955
|
case 53:
|
|
19868
19956
|
case 10:
|
|
19869
19957
|
case 11:
|
|
19958
|
+
case 56:
|
|
19870
19959
|
return 2;
|
|
19871
19960
|
case 25:
|
|
19872
19961
|
case 35:
|
|
19873
19962
|
case 40:
|
|
19874
19963
|
case 41:
|
|
19964
|
+
case 57:
|
|
19965
|
+
case 74:
|
|
19875
19966
|
return 3;
|
|
19967
|
+
case 58:
|
|
19968
|
+
return 4;
|
|
19969
|
+
case 64:
|
|
19970
|
+
case 65:
|
|
19971
|
+
case 66:
|
|
19876
19972
|
case 24:
|
|
19877
19973
|
case 37:
|
|
19878
19974
|
case 39:
|
|
19879
19975
|
case 52:
|
|
19880
19976
|
case 38:
|
|
19977
|
+
case 71:
|
|
19978
|
+
case 67:
|
|
19881
19979
|
return 5;
|
|
19980
|
+
case 70:
|
|
19981
|
+
return 6;
|
|
19882
19982
|
case 49:
|
|
19883
19983
|
case 50:
|
|
19984
|
+
case 69:
|
|
19884
19985
|
return 9;
|
|
19885
19986
|
case 36:
|
|
19886
19987
|
throw new Error(`Unknown opcode ${op}`);
|
|
@@ -19908,6 +20009,7 @@ function emitBytecode(bytecode, view, offset, linktable, shift_hack) {
|
|
|
19908
20009
|
case 43:
|
|
19909
20010
|
case 46:
|
|
19910
20011
|
case 53:
|
|
20012
|
+
case 56:
|
|
19911
20013
|
view.setUint8(offset++, bytecode.arg);
|
|
19912
20014
|
break;
|
|
19913
20015
|
case 25:
|
|
@@ -19917,12 +20019,36 @@ function emitBytecode(bytecode, view, offset, linktable, shift_hack) {
|
|
|
19917
20019
|
linktable.set(offset, bytecode.arg);
|
|
19918
20020
|
view.setInt16((offset += 2) - 2, 0);
|
|
19919
20021
|
break;
|
|
20022
|
+
case 57:
|
|
20023
|
+
view.setInt16((offset += 2) - 2, bytecode.arg);
|
|
20024
|
+
break;
|
|
20025
|
+
case 58:
|
|
20026
|
+
view.setInt32((offset += 3) - 3, bytecode.arg << 8);
|
|
20027
|
+
break;
|
|
20028
|
+
case 64:
|
|
20029
|
+
case 65:
|
|
20030
|
+
case 66:
|
|
20031
|
+
case 67:
|
|
20032
|
+
case 71:
|
|
19920
20033
|
case 24:
|
|
19921
20034
|
case 37:
|
|
19922
20035
|
case 39:
|
|
19923
|
-
case 52:
|
|
20036
|
+
case 52: {
|
|
19924
20037
|
view.setInt32((offset += 4) - 4, bytecode.arg);
|
|
19925
20038
|
break;
|
|
20039
|
+
}
|
|
20040
|
+
case 69:
|
|
20041
|
+
view.setInt32((offset += 4) - 4, bytecode.arg.module);
|
|
20042
|
+
view.setInt32((offset += 4) - 4, bytecode.arg.var);
|
|
20043
|
+
break;
|
|
20044
|
+
case 70:
|
|
20045
|
+
view.setUint8(offset++, bytecode.arg.local);
|
|
20046
|
+
view.setInt32((offset += 4) - 4, bytecode.arg.var);
|
|
20047
|
+
break;
|
|
20048
|
+
case 74:
|
|
20049
|
+
view.setUint8(offset++, bytecode.arg.argc);
|
|
20050
|
+
view.setUint8(offset++, bytecode.arg.incsp);
|
|
20051
|
+
break;
|
|
19926
20052
|
case 49:
|
|
19927
20053
|
view.setBigInt64((offset += 8) - 8, bytecode.arg);
|
|
19928
20054
|
break;
|
|
@@ -19943,6 +20069,7 @@ function getOpInfo(bytecode) {
|
|
|
19943
20069
|
case 23:
|
|
19944
20070
|
case 1:
|
|
19945
20071
|
case 53:
|
|
20072
|
+
case 74:
|
|
19946
20073
|
case 25:
|
|
19947
20074
|
case 35:
|
|
19948
20075
|
return { pop: 0, push: 0 };
|
|
@@ -19978,27 +20105,49 @@ function getOpInfo(bytecode) {
|
|
|
19978
20105
|
case 14:
|
|
19979
20106
|
case 17:
|
|
19980
20107
|
return { pop: 3, push: 0 };
|
|
20108
|
+
case 73:
|
|
20109
|
+
return { pop: 3, push: 1 };
|
|
19981
20110
|
case 21:
|
|
19982
20111
|
case 32:
|
|
20112
|
+
case 75:
|
|
19983
20113
|
case 45:
|
|
19984
20114
|
case 48:
|
|
19985
20115
|
case 20:
|
|
19986
20116
|
case 54:
|
|
19987
20117
|
case 47:
|
|
20118
|
+
case 71:
|
|
19988
20119
|
return { pop: 1, push: 1 };
|
|
20120
|
+
case 64:
|
|
20121
|
+
case 65:
|
|
20122
|
+
case 66:
|
|
20123
|
+
case 67:
|
|
20124
|
+
case 68:
|
|
20125
|
+
case 69:
|
|
20126
|
+
case 70:
|
|
19989
20127
|
case 42:
|
|
19990
20128
|
case 44:
|
|
19991
20129
|
case 43:
|
|
20130
|
+
case 62:
|
|
20131
|
+
case 63:
|
|
19992
20132
|
case 18:
|
|
19993
20133
|
case 46:
|
|
19994
20134
|
case 24:
|
|
19995
20135
|
case 37:
|
|
20136
|
+
case 55:
|
|
20137
|
+
case 56:
|
|
20138
|
+
case 57:
|
|
20139
|
+
case 58:
|
|
19996
20140
|
case 38:
|
|
20141
|
+
case 59:
|
|
19997
20142
|
case 39:
|
|
19998
20143
|
case 52:
|
|
19999
20144
|
case 49:
|
|
20145
|
+
case 60:
|
|
20000
20146
|
case 50:
|
|
20147
|
+
case 61:
|
|
20001
20148
|
return { pop: 0, push: 1 };
|
|
20149
|
+
case 72:
|
|
20150
|
+
return { pop: 1, push: 1 };
|
|
20002
20151
|
case 15:
|
|
20003
20152
|
return { pop: bytecode.arg + 1, push: 1 };
|
|
20004
20153
|
case 36:
|
|
@@ -20014,15 +20163,27 @@ function getOpEffects(bytecode) {
|
|
|
20014
20163
|
case 14:
|
|
20015
20164
|
return 2;
|
|
20016
20165
|
case 17:
|
|
20166
|
+
case 73:
|
|
20017
20167
|
return 4;
|
|
20018
20168
|
case 21:
|
|
20019
20169
|
return 2 | 4;
|
|
20020
20170
|
case 15:
|
|
20171
|
+
case 72:
|
|
20021
20172
|
return 8 | 2 | 4;
|
|
20173
|
+
case 13:
|
|
20174
|
+
case 67:
|
|
20175
|
+
case 69:
|
|
20176
|
+
case 70:
|
|
20177
|
+
case 71:
|
|
20178
|
+
case 16:
|
|
20179
|
+
return 0;
|
|
20180
|
+
case 18:
|
|
20181
|
+
return 0;
|
|
20022
20182
|
case 0:
|
|
20023
20183
|
case 23:
|
|
20024
20184
|
case 1:
|
|
20025
20185
|
case 53:
|
|
20186
|
+
case 74:
|
|
20026
20187
|
case 25:
|
|
20027
20188
|
case 35:
|
|
20028
20189
|
case 2:
|
|
@@ -20048,9 +20209,9 @@ function getOpEffects(bytecode) {
|
|
|
20048
20209
|
case 31:
|
|
20049
20210
|
case 34:
|
|
20050
20211
|
case 33:
|
|
20051
|
-
case
|
|
20052
|
-
case 16:
|
|
20212
|
+
case 68:
|
|
20053
20213
|
case 32:
|
|
20214
|
+
case 75:
|
|
20054
20215
|
case 45:
|
|
20055
20216
|
case 48:
|
|
20056
20217
|
case 20:
|
|
@@ -20058,16 +20219,27 @@ function getOpEffects(bytecode) {
|
|
|
20058
20219
|
case 47:
|
|
20059
20220
|
case 42:
|
|
20060
20221
|
case 44:
|
|
20222
|
+
case 64:
|
|
20223
|
+
case 65:
|
|
20224
|
+
case 66:
|
|
20061
20225
|
case 43:
|
|
20062
|
-
case
|
|
20226
|
+
case 62:
|
|
20227
|
+
case 63:
|
|
20063
20228
|
case 46:
|
|
20064
20229
|
case 24:
|
|
20065
20230
|
case 37:
|
|
20231
|
+
case 55:
|
|
20232
|
+
case 56:
|
|
20233
|
+
case 57:
|
|
20234
|
+
case 58:
|
|
20066
20235
|
case 38:
|
|
20236
|
+
case 59:
|
|
20067
20237
|
case 39:
|
|
20068
20238
|
case 52:
|
|
20069
20239
|
case 49:
|
|
20240
|
+
case 60:
|
|
20070
20241
|
case 50:
|
|
20242
|
+
case 61:
|
|
20071
20243
|
return 0;
|
|
20072
20244
|
case 36:
|
|
20073
20245
|
throw new Error(`Unknown opcode ${bytecode.op}`);
|
|
@@ -20075,6 +20247,93 @@ function getOpEffects(bytecode) {
|
|
|
20075
20247
|
unhandledType(bytecode);
|
|
20076
20248
|
}
|
|
20077
20249
|
}
|
|
20250
|
+
function opReadsLocal(bytecode) {
|
|
20251
|
+
switch (bytecode.op) {
|
|
20252
|
+
case 67:
|
|
20253
|
+
case 68:
|
|
20254
|
+
case 42:
|
|
20255
|
+
return 0;
|
|
20256
|
+
case 70:
|
|
20257
|
+
return bytecode.arg.local;
|
|
20258
|
+
case 18:
|
|
20259
|
+
return bytecode.arg;
|
|
20260
|
+
case 19:
|
|
20261
|
+
case 14:
|
|
20262
|
+
case 17:
|
|
20263
|
+
case 73:
|
|
20264
|
+
case 21:
|
|
20265
|
+
case 15:
|
|
20266
|
+
case 72:
|
|
20267
|
+
case 13:
|
|
20268
|
+
case 69:
|
|
20269
|
+
case 71:
|
|
20270
|
+
case 16:
|
|
20271
|
+
case 0:
|
|
20272
|
+
case 23:
|
|
20273
|
+
case 1:
|
|
20274
|
+
case 53:
|
|
20275
|
+
case 74:
|
|
20276
|
+
case 25:
|
|
20277
|
+
case 35:
|
|
20278
|
+
case 2:
|
|
20279
|
+
case 22:
|
|
20280
|
+
case 51:
|
|
20281
|
+
case 40:
|
|
20282
|
+
case 41:
|
|
20283
|
+
case 3:
|
|
20284
|
+
case 4:
|
|
20285
|
+
case 5:
|
|
20286
|
+
case 6:
|
|
20287
|
+
case 7:
|
|
20288
|
+
case 8:
|
|
20289
|
+
case 9:
|
|
20290
|
+
case 10:
|
|
20291
|
+
case 11:
|
|
20292
|
+
case 12:
|
|
20293
|
+
case 26:
|
|
20294
|
+
case 27:
|
|
20295
|
+
case 28:
|
|
20296
|
+
case 29:
|
|
20297
|
+
case 30:
|
|
20298
|
+
case 31:
|
|
20299
|
+
case 34:
|
|
20300
|
+
case 33:
|
|
20301
|
+
case 32:
|
|
20302
|
+
case 75:
|
|
20303
|
+
case 45:
|
|
20304
|
+
case 48:
|
|
20305
|
+
case 20:
|
|
20306
|
+
case 54:
|
|
20307
|
+
case 47:
|
|
20308
|
+
case 44:
|
|
20309
|
+
case 64:
|
|
20310
|
+
case 65:
|
|
20311
|
+
case 66:
|
|
20312
|
+
case 43:
|
|
20313
|
+
case 62:
|
|
20314
|
+
case 63:
|
|
20315
|
+
case 46:
|
|
20316
|
+
case 24:
|
|
20317
|
+
case 37:
|
|
20318
|
+
case 55:
|
|
20319
|
+
case 56:
|
|
20320
|
+
case 57:
|
|
20321
|
+
case 58:
|
|
20322
|
+
case 38:
|
|
20323
|
+
case 59:
|
|
20324
|
+
case 39:
|
|
20325
|
+
case 52:
|
|
20326
|
+
case 49:
|
|
20327
|
+
case 60:
|
|
20328
|
+
case 50:
|
|
20329
|
+
case 61:
|
|
20330
|
+
return null;
|
|
20331
|
+
case 36:
|
|
20332
|
+
throw new Error(`Unknown opcode ${bytecode.op}`);
|
|
20333
|
+
default:
|
|
20334
|
+
unhandledType(bytecode);
|
|
20335
|
+
}
|
|
20336
|
+
}
|
|
20078
20337
|
function isBoolOp(op) {
|
|
20079
20338
|
switch (op) {
|
|
20080
20339
|
case 32:
|
|
@@ -20159,6 +20418,27 @@ var init_opcodes = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
20159
20418
|
Opcodes2[Opcodes2["cpush"] = 52] = "cpush";
|
|
20160
20419
|
Opcodes2[Opcodes2["argc"] = 53] = "argc";
|
|
20161
20420
|
Opcodes2[Opcodes2["newba"] = 54] = "newba";
|
|
20421
|
+
Opcodes2[Opcodes2["ipushz"] = 55] = "ipushz";
|
|
20422
|
+
Opcodes2[Opcodes2["ipush1"] = 56] = "ipush1";
|
|
20423
|
+
Opcodes2[Opcodes2["ipush2"] = 57] = "ipush2";
|
|
20424
|
+
Opcodes2[Opcodes2["ipush3"] = 58] = "ipush3";
|
|
20425
|
+
Opcodes2[Opcodes2["fpushz"] = 59] = "fpushz";
|
|
20426
|
+
Opcodes2[Opcodes2["lpushz"] = 60] = "lpushz";
|
|
20427
|
+
Opcodes2[Opcodes2["dpushz"] = 61] = "dpushz";
|
|
20428
|
+
Opcodes2[Opcodes2["btpush"] = 62] = "btpush";
|
|
20429
|
+
Opcodes2[Opcodes2["bfpush"] = 63] = "bfpush";
|
|
20430
|
+
Opcodes2[Opcodes2["apush"] = 64] = "apush";
|
|
20431
|
+
Opcodes2[Opcodes2["bapush"] = 65] = "bapush";
|
|
20432
|
+
Opcodes2[Opcodes2["hpush"] = 66] = "hpush";
|
|
20433
|
+
Opcodes2[Opcodes2["getselfv"] = 67] = "getselfv";
|
|
20434
|
+
Opcodes2[Opcodes2["getself"] = 68] = "getself";
|
|
20435
|
+
Opcodes2[Opcodes2["getmv"] = 69] = "getmv";
|
|
20436
|
+
Opcodes2[Opcodes2["getlocalv"] = 70] = "getlocalv";
|
|
20437
|
+
Opcodes2[Opcodes2["getsv"] = 71] = "getsv";
|
|
20438
|
+
Opcodes2[Opcodes2["invokemz"] = 72] = "invokemz";
|
|
20439
|
+
Opcodes2[Opcodes2["aputvdup"] = 73] = "aputvdup";
|
|
20440
|
+
Opcodes2[Opcodes2["argcincsp"] = 74] = "argcincsp";
|
|
20441
|
+
Opcodes2[Opcodes2["isnotnull"] = 75] = "isnotnull";
|
|
20162
20442
|
return Opcodes2;
|
|
20163
20443
|
})(Opcodes || {});
|
|
20164
20444
|
}
|
|
@@ -20330,7 +20610,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
|
|
|
20330
20610
|
i = -1;
|
|
20331
20611
|
continue;
|
|
20332
20612
|
}
|
|
20333
|
-
if (top.exsucc && (bc.op === 15 || bc.op === 51)) {
|
|
20613
|
+
if (top.exsucc && (bc.op === 15 || bc.op === 72 || bc.op === 51)) {
|
|
20334
20614
|
doMerge(top.exsucc, true);
|
|
20335
20615
|
}
|
|
20336
20616
|
}
|
|
@@ -20616,8 +20896,11 @@ function interpBytecode(bc, localState, context) {
|
|
|
20616
20896
|
localState.stack.splice(-2, 2, { type });
|
|
20617
20897
|
};
|
|
20618
20898
|
switch (bc.op) {
|
|
20899
|
+
case 68:
|
|
20619
20900
|
case 18: {
|
|
20620
|
-
|
|
20901
|
+
const localNum = opReadsLocal(bc);
|
|
20902
|
+
(0, import_node_assert7.default)(localNum != null);
|
|
20903
|
+
let local = localState.locals[localNum];
|
|
20621
20904
|
if (local) {
|
|
20622
20905
|
local = { ...local };
|
|
20623
20906
|
delete local.equivs;
|
|
@@ -20628,7 +20911,7 @@ function interpBytecode(bc, localState, context) {
|
|
|
20628
20911
|
} };
|
|
20629
20912
|
}
|
|
20630
20913
|
localState.stack.push(local);
|
|
20631
|
-
addEquiv2(localState, -localState.stack.length,
|
|
20914
|
+
addEquiv2(localState, -localState.stack.length, localNum);
|
|
20632
20915
|
break;
|
|
20633
20916
|
}
|
|
20634
20917
|
case 46: {
|
|
@@ -20676,18 +20959,33 @@ function interpBytecode(bc, localState, context) {
|
|
|
20676
20959
|
localState.locals[bc.arg].type = value2.type;
|
|
20677
20960
|
break;
|
|
20678
20961
|
}
|
|
20962
|
+
case 55:
|
|
20963
|
+
xpush(8, 0);
|
|
20964
|
+
break;
|
|
20679
20965
|
case 37:
|
|
20966
|
+
case 56:
|
|
20967
|
+
case 57:
|
|
20968
|
+
case 58:
|
|
20680
20969
|
xpush(8, bc.arg);
|
|
20681
20970
|
break;
|
|
20682
20971
|
case 49:
|
|
20683
20972
|
xpush(16, bc.arg);
|
|
20684
20973
|
break;
|
|
20974
|
+
case 60:
|
|
20975
|
+
xpush(16, 0n);
|
|
20976
|
+
break;
|
|
20685
20977
|
case 38:
|
|
20686
20978
|
xpush(32, roundToFloat(bc.arg));
|
|
20687
20979
|
break;
|
|
20980
|
+
case 59:
|
|
20981
|
+
xpush(32, 0);
|
|
20982
|
+
break;
|
|
20688
20983
|
case 50:
|
|
20689
20984
|
xpush(64, bc.arg);
|
|
20690
20985
|
break;
|
|
20986
|
+
case 61:
|
|
20987
|
+
xpush(64, 0);
|
|
20988
|
+
break;
|
|
20691
20989
|
case 52:
|
|
20692
20990
|
xpush(128, String.fromCharCode(bc.arg));
|
|
20693
20991
|
break;
|
|
@@ -20697,6 +20995,18 @@ function interpBytecode(bc, localState, context) {
|
|
|
20697
20995
|
/* False */
|
|
20698
20996
|
);
|
|
20699
20997
|
break;
|
|
20998
|
+
case 62:
|
|
20999
|
+
xpush(
|
|
21000
|
+
4
|
|
21001
|
+
/* True */
|
|
21002
|
+
);
|
|
21003
|
+
break;
|
|
21004
|
+
case 63:
|
|
21005
|
+
xpush(
|
|
21006
|
+
2
|
|
21007
|
+
/* False */
|
|
21008
|
+
);
|
|
21009
|
+
break;
|
|
20700
21010
|
case 44:
|
|
20701
21011
|
xpush(
|
|
20702
21012
|
1
|
|
@@ -21626,23 +21936,42 @@ function localDCE(func, context) {
|
|
|
21626
21936
|
}
|
|
21627
21937
|
break;
|
|
21628
21938
|
}
|
|
21939
|
+
case 70:
|
|
21940
|
+
case 68:
|
|
21941
|
+
case 67:
|
|
21629
21942
|
case 18:
|
|
21943
|
+
case 62:
|
|
21944
|
+
case 63:
|
|
21945
|
+
case 42:
|
|
21946
|
+
case 64:
|
|
21947
|
+
case 65:
|
|
21948
|
+
case 66:
|
|
21630
21949
|
case 44:
|
|
21631
21950
|
case 43:
|
|
21632
21951
|
case 24:
|
|
21633
21952
|
case 37:
|
|
21953
|
+
case 55:
|
|
21954
|
+
case 56:
|
|
21955
|
+
case 57:
|
|
21956
|
+
case 58:
|
|
21634
21957
|
case 38:
|
|
21958
|
+
case 59:
|
|
21635
21959
|
case 39:
|
|
21636
21960
|
case 52:
|
|
21637
21961
|
case 49:
|
|
21638
|
-
case
|
|
21962
|
+
case 60:
|
|
21963
|
+
case 50:
|
|
21964
|
+
case 61: {
|
|
21639
21965
|
const item = dceInfo.stack.pop();
|
|
21640
21966
|
if (item?.dead) {
|
|
21641
21967
|
item.deps.push(i);
|
|
21642
21968
|
reportNop(item);
|
|
21643
21969
|
item.deps.forEach((index) => makeNop(block.bytecodes[index]));
|
|
21644
|
-
} else
|
|
21645
|
-
|
|
21970
|
+
} else {
|
|
21971
|
+
const local = opReadsLocal(bytecode);
|
|
21972
|
+
if (local != null) {
|
|
21973
|
+
dceInfo.locals.add(local);
|
|
21974
|
+
}
|
|
21646
21975
|
}
|
|
21647
21976
|
break;
|
|
21648
21977
|
}
|
|
@@ -21680,6 +22009,7 @@ function localDCE(func, context) {
|
|
|
21680
22009
|
}
|
|
21681
22010
|
case 21:
|
|
21682
22011
|
case 32:
|
|
22012
|
+
case 75:
|
|
21683
22013
|
case 45:
|
|
21684
22014
|
case 48:
|
|
21685
22015
|
case 20:
|
|
@@ -21698,10 +22028,26 @@ function localDCE(func, context) {
|
|
|
21698
22028
|
}
|
|
21699
22029
|
case 51:
|
|
21700
22030
|
case 15:
|
|
22031
|
+
case 72:
|
|
21701
22032
|
if (block.exsucc) {
|
|
21702
22033
|
liveInLocals.get(block.exsucc)?.forEach((local) => dceInfo.locals.add(local));
|
|
21703
22034
|
}
|
|
21704
|
-
|
|
22035
|
+
case 17:
|
|
22036
|
+
case 73:
|
|
22037
|
+
case 53:
|
|
22038
|
+
case 1:
|
|
22039
|
+
case 74:
|
|
22040
|
+
case 41:
|
|
22041
|
+
case 40:
|
|
22042
|
+
case 69:
|
|
22043
|
+
case 71:
|
|
22044
|
+
case 25:
|
|
22045
|
+
case 35:
|
|
22046
|
+
case 0:
|
|
22047
|
+
case 14:
|
|
22048
|
+
case 23:
|
|
22049
|
+
case 22:
|
|
22050
|
+
case 36: {
|
|
21705
22051
|
let { push, pop } = getOpInfo(bytecode);
|
|
21706
22052
|
while (push-- > 0) {
|
|
21707
22053
|
dceInfo.stack.pop();
|
|
@@ -21709,7 +22055,10 @@ function localDCE(func, context) {
|
|
|
21709
22055
|
while (pop-- > 0) {
|
|
21710
22056
|
dceInfo.stack.push({ dead: false });
|
|
21711
22057
|
}
|
|
22058
|
+
break;
|
|
21712
22059
|
}
|
|
22060
|
+
default:
|
|
22061
|
+
unhandledType(bytecode);
|
|
21713
22062
|
}
|
|
21714
22063
|
}
|
|
21715
22064
|
if (changes) {
|
|
@@ -21732,18 +22081,22 @@ function computeLiveLocals(func) {
|
|
|
21732
22081
|
(block) => new Set(liveOutLocals.get(block.offset)),
|
|
21733
22082
|
(block, bc, locals) => {
|
|
21734
22083
|
switch (bc.op) {
|
|
21735
|
-
case 18:
|
|
21736
|
-
locals.add(bc.arg);
|
|
21737
|
-
break;
|
|
21738
22084
|
case 19:
|
|
21739
22085
|
locals.delete(bc.arg);
|
|
21740
22086
|
break;
|
|
21741
22087
|
case 51:
|
|
21742
22088
|
case 15:
|
|
22089
|
+
case 72:
|
|
21743
22090
|
if (block.exsucc) {
|
|
21744
22091
|
liveInLocals.get(block.exsucc)?.forEach((local) => locals.add(local));
|
|
21745
22092
|
}
|
|
21746
22093
|
break;
|
|
22094
|
+
default: {
|
|
22095
|
+
const local = opReadsLocal(bc);
|
|
22096
|
+
if (local != null) {
|
|
22097
|
+
locals.add(local);
|
|
22098
|
+
}
|
|
22099
|
+
}
|
|
21747
22100
|
}
|
|
21748
22101
|
},
|
|
21749
22102
|
(block, locals) => {
|
|
@@ -21767,6 +22120,7 @@ function computeLiveLocals(func) {
|
|
|
21767
22120
|
var init_dce = (0, import_chunk_ABYVSU2C.__esm)({
|
|
21768
22121
|
"src/readprg/dce.ts"() {
|
|
21769
22122
|
"use strict";
|
|
22123
|
+
init_data_flow();
|
|
21770
22124
|
(0, import_chunk_SG7ODKRM.init_util)();
|
|
21771
22125
|
init_bytecode();
|
|
21772
22126
|
init_cflow();
|
|
@@ -21796,6 +22150,13 @@ function mergeInto2(from, to) {
|
|
|
21796
22150
|
});
|
|
21797
22151
|
return changed;
|
|
21798
22152
|
}
|
|
22153
|
+
function getLocalNum(key) {
|
|
22154
|
+
if (key.op === 19)
|
|
22155
|
+
return key.arg;
|
|
22156
|
+
const local = opReadsLocal(key);
|
|
22157
|
+
(0, import_node_assert9.default)(local !== null);
|
|
22158
|
+
return local;
|
|
22159
|
+
}
|
|
21799
22160
|
function minimizeLocals2(func, equivSets, context) {
|
|
21800
22161
|
const splitRanges = computeSplitRanges(func, equivSets);
|
|
21801
22162
|
const locals = mergeSplitRanges(splitRanges);
|
|
@@ -21805,21 +22166,22 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21805
22166
|
const colors = /* @__PURE__ */ new Map();
|
|
21806
22167
|
const merge = [];
|
|
21807
22168
|
locals.forEach((local, key) => {
|
|
21808
|
-
|
|
21809
|
-
|
|
21810
|
-
|
|
21811
|
-
|
|
22169
|
+
const localNum = getLocalNum(key);
|
|
22170
|
+
if (key.op !== 19 || localNum === 0) {
|
|
22171
|
+
colors.set(key, localNum);
|
|
22172
|
+
const merged = merge[localNum];
|
|
22173
|
+
if (argc == null || localNum < argc) {
|
|
21812
22174
|
if (merged) {
|
|
21813
|
-
(0, import_node_assert9.default)(!
|
|
22175
|
+
(0, import_node_assert9.default)(!localNum);
|
|
21814
22176
|
merged.push(key);
|
|
21815
22177
|
} else {
|
|
21816
|
-
merge[
|
|
22178
|
+
merge[localNum] = [key];
|
|
21817
22179
|
}
|
|
21818
22180
|
}
|
|
21819
22181
|
}
|
|
21820
22182
|
});
|
|
21821
22183
|
locals.forEach((local, key) => {
|
|
21822
|
-
if (key.op
|
|
22184
|
+
if (key.op !== 19)
|
|
21823
22185
|
return;
|
|
21824
22186
|
let inUse = 0n;
|
|
21825
22187
|
local.conflicts.forEach((conflict) => {
|
|
@@ -21846,10 +22208,13 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21846
22208
|
if (argc != null && i <= argc)
|
|
21847
22209
|
break;
|
|
21848
22210
|
const merged = merge[i];
|
|
21849
|
-
if (merged
|
|
21850
|
-
|
|
22211
|
+
if (!merged)
|
|
22212
|
+
continue;
|
|
22213
|
+
const firstLocal = getLocalNum(merged[0]);
|
|
22214
|
+
if (firstLocal < i && (argc == null || firstLocal >= argc) && merged.every((elem) => getLocalNum(elem) === firstLocal)) {
|
|
22215
|
+
const j = firstLocal;
|
|
21851
22216
|
const other = merge[j];
|
|
21852
|
-
if (other.every((elem) => elem
|
|
22217
|
+
if (other.every((elem) => getLocalNum(elem) !== j)) {
|
|
21853
22218
|
merge[i] = other;
|
|
21854
22219
|
merge[j] = merged;
|
|
21855
22220
|
merged.forEach((elem) => colors.set(elem, j));
|
|
@@ -21904,6 +22269,20 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21904
22269
|
let filter = false;
|
|
21905
22270
|
block.bytecodes.forEach((bc) => {
|
|
21906
22271
|
switch (bc.op) {
|
|
22272
|
+
case 74: {
|
|
22273
|
+
argc = bc.arg.argc;
|
|
22274
|
+
const newinc = merge.length - argc;
|
|
22275
|
+
if (newinc > 0) {
|
|
22276
|
+
bc.arg.incsp = newinc;
|
|
22277
|
+
} else {
|
|
22278
|
+
const argCount = bc;
|
|
22279
|
+
argCount.op = 53;
|
|
22280
|
+
argCount.arg = argc;
|
|
22281
|
+
argCount.size = 2;
|
|
22282
|
+
filter = true;
|
|
22283
|
+
}
|
|
22284
|
+
break;
|
|
22285
|
+
}
|
|
21907
22286
|
case 53:
|
|
21908
22287
|
argc = bc.arg;
|
|
21909
22288
|
break;
|
|
@@ -21925,11 +22304,16 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21925
22304
|
}
|
|
21926
22305
|
break;
|
|
21927
22306
|
}
|
|
22307
|
+
case 70:
|
|
21928
22308
|
case 18:
|
|
21929
22309
|
case 19: {
|
|
21930
22310
|
const info = fixupMap.get(bc);
|
|
21931
22311
|
(0, import_node_assert9.default)(info != null);
|
|
21932
|
-
bc.
|
|
22312
|
+
if (bc.op === 70) {
|
|
22313
|
+
bc.arg.local = info.color;
|
|
22314
|
+
} else {
|
|
22315
|
+
bc.arg = info.color;
|
|
22316
|
+
}
|
|
21933
22317
|
if (info.range) {
|
|
21934
22318
|
bc.range = info.range;
|
|
21935
22319
|
} else {
|
|
@@ -21937,6 +22321,17 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21937
22321
|
}
|
|
21938
22322
|
break;
|
|
21939
22323
|
}
|
|
22324
|
+
case 42:
|
|
22325
|
+
case 68:
|
|
22326
|
+
case 67: {
|
|
22327
|
+
const info = fixupMap.get(bc);
|
|
22328
|
+
if (info) {
|
|
22329
|
+
(0, import_node_assert9.default)(!info.color);
|
|
22330
|
+
}
|
|
22331
|
+
break;
|
|
22332
|
+
}
|
|
22333
|
+
default:
|
|
22334
|
+
(0, import_node_assert9.default)(!fixupMap.get(bc));
|
|
21940
22335
|
}
|
|
21941
22336
|
});
|
|
21942
22337
|
if (filter) {
|
|
@@ -21952,43 +22347,34 @@ function computeSplitRanges(func, equivSets) {
|
|
|
21952
22347
|
const liveOutLocals = /* @__PURE__ */ new Map();
|
|
21953
22348
|
const liveInLocals = /* @__PURE__ */ new Map();
|
|
21954
22349
|
const splitRanges = /* @__PURE__ */ new Map();
|
|
21955
|
-
const
|
|
21956
|
-
const
|
|
22350
|
+
const recordLocalRead = (locals, bc) => {
|
|
22351
|
+
const localid = opReadsLocal(bc);
|
|
22352
|
+
(0, import_node_assert9.default)(localid != null);
|
|
22353
|
+
const bcs = locals.get(localid);
|
|
21957
22354
|
if (!bcs) {
|
|
21958
|
-
locals.set(
|
|
22355
|
+
locals.set(localid, /* @__PURE__ */ new Set([bc]));
|
|
21959
22356
|
} else {
|
|
21960
22357
|
bcs.add(bc);
|
|
21961
22358
|
}
|
|
21962
22359
|
};
|
|
21963
|
-
const fakeLgetvs = /* @__PURE__ */ new Map();
|
|
21964
22360
|
postOrderPropagate(
|
|
21965
22361
|
func,
|
|
21966
22362
|
(block) => cloneLive(liveOutLocals.get(block.offset)),
|
|
21967
22363
|
(block, bc, locals) => {
|
|
21968
22364
|
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
|
-
}
|
|
22365
|
+
case 68:
|
|
22366
|
+
case 67:
|
|
22367
|
+
case 70:
|
|
22368
|
+
case 42:
|
|
21983
22369
|
case 18:
|
|
21984
|
-
|
|
22370
|
+
recordLocalRead(locals, bc);
|
|
21985
22371
|
break;
|
|
21986
22372
|
case 19: {
|
|
21987
22373
|
let bcs = locals.get(bc.arg);
|
|
21988
22374
|
if (!bcs) {
|
|
21989
22375
|
bcs = /* @__PURE__ */ new Set();
|
|
21990
22376
|
}
|
|
21991
|
-
|
|
22377
|
+
const ranges = splitRanges.get(bc.arg);
|
|
21992
22378
|
const equiv = equivSets.get(bc);
|
|
21993
22379
|
const conflicts = /* @__PURE__ */ new Set();
|
|
21994
22380
|
locals.forEach((liveBcs, local) => {
|
|
@@ -21999,10 +22385,7 @@ function computeSplitRanges(func, equivSets) {
|
|
|
21999
22385
|
liveBcs.forEach((lbc) => conflicts.add(lbc));
|
|
22000
22386
|
});
|
|
22001
22387
|
if (!ranges) {
|
|
22002
|
-
splitRanges.set(
|
|
22003
|
-
bc.arg,
|
|
22004
|
-
ranges = /* @__PURE__ */ new Map([[bc, { live: bcs, conflicts }]])
|
|
22005
|
-
);
|
|
22388
|
+
splitRanges.set(bc.arg, /* @__PURE__ */ new Map([[bc, { live: bcs, conflicts }]]));
|
|
22006
22389
|
} else {
|
|
22007
22390
|
ranges.set(bc, { live: bcs, conflicts });
|
|
22008
22391
|
}
|
|
@@ -22011,6 +22394,7 @@ function computeSplitRanges(func, equivSets) {
|
|
|
22011
22394
|
}
|
|
22012
22395
|
case 51:
|
|
22013
22396
|
case 15:
|
|
22397
|
+
case 72:
|
|
22014
22398
|
if (block.exsucc) {
|
|
22015
22399
|
const from = liveInLocals.get(block.exsucc);
|
|
22016
22400
|
if (from) {
|
|
@@ -22018,6 +22402,8 @@ function computeSplitRanges(func, equivSets) {
|
|
|
22018
22402
|
}
|
|
22019
22403
|
}
|
|
22020
22404
|
break;
|
|
22405
|
+
default:
|
|
22406
|
+
(0, import_node_assert9.default)(opReadsLocal(bc) == null);
|
|
22021
22407
|
}
|
|
22022
22408
|
},
|
|
22023
22409
|
(block, locals) => {
|
|
@@ -22080,7 +22466,7 @@ function mergeSplitRanges(splitRanges) {
|
|
|
22080
22466
|
let lputv = null;
|
|
22081
22467
|
let singleRange = null;
|
|
22082
22468
|
pvSet.forEach((pv) => {
|
|
22083
|
-
if (!lputv || pv.op
|
|
22469
|
+
if (!lputv || pv.op !== 19)
|
|
22084
22470
|
lputv = pv;
|
|
22085
22471
|
});
|
|
22086
22472
|
pvSet.forEach((pv) => {
|
|
@@ -22109,6 +22495,7 @@ function mergeSplitRanges(splitRanges) {
|
|
|
22109
22495
|
v.conflicts = new Set(
|
|
22110
22496
|
Array.from(v.conflicts).flatMap((bc) => {
|
|
22111
22497
|
const r = bcToLiveRange.get(bc);
|
|
22498
|
+
(0, import_node_assert9.default)(r);
|
|
22112
22499
|
if (!r) {
|
|
22113
22500
|
(0, import_node_assert9.default)(bc.arg === 0);
|
|
22114
22501
|
return [];
|
|
@@ -22262,7 +22649,7 @@ function sizeBasedPRE2(func, context) {
|
|
|
22262
22649
|
const bcs = canonicalMap.get(key);
|
|
22263
22650
|
(0, import_node_assert10.default)(bcs);
|
|
22264
22651
|
let index = block.bytecodes.findIndex(
|
|
22265
|
-
(bc2) => bcs.has(bc2) || block.exsucc && (bc2.op === 15 || bc2.op === 51)
|
|
22652
|
+
(bc2) => bcs.has(bc2) || block.exsucc && (bc2.op === 15 || bc2.op === 72 || bc2.op === 51)
|
|
22266
22653
|
);
|
|
22267
22654
|
if (index < 0) {
|
|
22268
22655
|
if (block.next && !block.taken) {
|
|
@@ -23177,6 +23564,7 @@ function getLocalsInfo(func) {
|
|
|
23177
23564
|
break;
|
|
23178
23565
|
case 51:
|
|
23179
23566
|
case 15:
|
|
23567
|
+
case 72:
|
|
23180
23568
|
if (block.exsucc) {
|
|
23181
23569
|
const from = liveInLocals.get(block.exsucc);
|
|
23182
23570
|
if (from) {
|
|
@@ -23270,8 +23658,11 @@ var init_exceptions = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
23270
23658
|
});
|
|
23271
23659
|
function parseHeader(view) {
|
|
23272
23660
|
let offset = 0;
|
|
23273
|
-
const
|
|
23661
|
+
const word = view.getUint32((offset += 4) - 4);
|
|
23662
|
+
const ciqVersion = word & 16777215;
|
|
23663
|
+
const headerVersion = word >>> 24;
|
|
23274
23664
|
const header = {
|
|
23665
|
+
headerVersion,
|
|
23275
23666
|
ciqVersion,
|
|
23276
23667
|
backgroundOffsets: { data: 0, code: 0 },
|
|
23277
23668
|
appLock: false,
|
|
@@ -23296,10 +23687,13 @@ function parseHeader(view) {
|
|
|
23296
23687
|
return header;
|
|
23297
23688
|
}
|
|
23298
23689
|
function fixupHeader(context, updateInfo) {
|
|
23299
|
-
const view = context.sections[
|
|
23690
|
+
const view = (context.sections[
|
|
23300
23691
|
-805253120
|
|
23301
23692
|
/* HEADER */
|
|
23302
|
-
].
|
|
23693
|
+
] ?? context.sections[
|
|
23694
|
+
-805253107
|
|
23695
|
+
/* HEADER_VERSIONED */
|
|
23696
|
+
]).view;
|
|
23303
23697
|
if (context.header.backgroundOffsets.code !== 0) {
|
|
23304
23698
|
const offset = updateInfo.offsetMap.get(
|
|
23305
23699
|
context.header.backgroundOffsets.code
|
|
@@ -23716,6 +24110,16 @@ function lineInfoToString(lineInfo, context) {
|
|
|
23716
24110
|
}
|
|
23717
24111
|
function bytecodeToString(bytecode, symbolTable) {
|
|
23718
24112
|
let arg = null;
|
|
24113
|
+
const symbol = (arg2) => {
|
|
24114
|
+
const argSym = symbolTable?.symbolToLabelMap.get(arg2);
|
|
24115
|
+
if (argSym) {
|
|
24116
|
+
const symbol2 = symbolTable?.symbols.get(argSym);
|
|
24117
|
+
if (symbol2) {
|
|
24118
|
+
return `${symbol2.str} (${arg2})`;
|
|
24119
|
+
}
|
|
24120
|
+
}
|
|
24121
|
+
return arg2.toString();
|
|
24122
|
+
};
|
|
23719
24123
|
switch (bytecode.op) {
|
|
23720
24124
|
case 18:
|
|
23721
24125
|
case 19:
|
|
@@ -23723,30 +24127,31 @@ function bytecodeToString(bytecode, symbolTable) {
|
|
|
23723
24127
|
arg = `${bytecode.range.name} ${bytecode.arg}${bytecode.range.isParam ? " (param)" : ""}`;
|
|
23724
24128
|
}
|
|
23725
24129
|
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
|
-
}
|
|
24130
|
+
case 39:
|
|
24131
|
+
arg = symbol(bytecode.arg);
|
|
23734
24132
|
break;
|
|
23735
|
-
}
|
|
23736
24133
|
case 24: {
|
|
23737
|
-
const
|
|
23738
|
-
if (
|
|
23739
|
-
arg = `${JSON.stringify(
|
|
24134
|
+
const symbol2 = symbolTable?.symbols.get(bytecode.arg);
|
|
24135
|
+
if (symbol2) {
|
|
24136
|
+
arg = `${JSON.stringify(symbol2.str)} (${bytecode.arg})`;
|
|
23740
24137
|
}
|
|
23741
24138
|
break;
|
|
23742
24139
|
}
|
|
23743
24140
|
case 40:
|
|
23744
24141
|
case 41:
|
|
23745
24142
|
case 25:
|
|
23746
|
-
case 35:
|
|
24143
|
+
case 35:
|
|
23747
24144
|
arg = offsetToString(bytecode.arg);
|
|
23748
24145
|
break;
|
|
23749
|
-
|
|
24146
|
+
case 70:
|
|
24147
|
+
arg = `${bytecode.range ? `${bytecode.range.name} ${bytecode.arg}${bytecode.range.isParam ? " (param)" : ""}` : bytecode.arg.local} ${symbol(bytecode.arg.var)}`;
|
|
24148
|
+
break;
|
|
24149
|
+
case 69:
|
|
24150
|
+
arg = `${symbol(bytecode.arg.module)} ${symbol(bytecode.arg.var)}`;
|
|
24151
|
+
break;
|
|
24152
|
+
case 74:
|
|
24153
|
+
arg = `${bytecode.arg.argc} ${bytecode.arg.incsp}`;
|
|
24154
|
+
break;
|
|
23750
24155
|
}
|
|
23751
24156
|
if (arg == null && (0, import_chunk_MBTLUWXR.hasProperty)(bytecode, "arg")) {
|
|
23752
24157
|
arg = `${bytecode.arg}`;
|
|
@@ -23801,6 +24206,7 @@ function findFunctions({
|
|
|
23801
24206
|
next = void 0;
|
|
23802
24207
|
break;
|
|
23803
24208
|
case 15:
|
|
24209
|
+
case 72:
|
|
23804
24210
|
mayThrow2 = true;
|
|
23805
24211
|
break;
|
|
23806
24212
|
case 22:
|
|
@@ -23989,8 +24395,8 @@ function splitBlock(func, block, offset) {
|
|
|
23989
24395
|
const fixEx = (block2, isNew) => {
|
|
23990
24396
|
if (block2.exsucc) {
|
|
23991
24397
|
if (!block2.bytecodes.some(
|
|
23992
|
-
(bc) => bc.op === 51 || bc.op === 15
|
|
23993
|
-
/*
|
|
24398
|
+
(bc) => bc.op === 51 || bc.op === 15 || bc.op === 72
|
|
24399
|
+
/* invokemz */
|
|
23994
24400
|
)) {
|
|
23995
24401
|
if (!isNew) {
|
|
23996
24402
|
removePred(func, block2.exsucc, block2.offset);
|
|
@@ -24084,6 +24490,7 @@ var init_bytecode = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
24084
24490
|
init_optimize2();
|
|
24085
24491
|
SectionKinds = /* @__PURE__ */ ((SectionKinds2) => {
|
|
24086
24492
|
SectionKinds2[SectionKinds2["HEADER"] = -805253120] = "HEADER";
|
|
24493
|
+
SectionKinds2[SectionKinds2["HEADER_VERSIONED"] = -805253107] = "HEADER_VERSIONED";
|
|
24087
24494
|
SectionKinds2[SectionKinds2["TEXT"] = -1059145026] = "TEXT";
|
|
24088
24495
|
SectionKinds2[SectionKinds2["DATA"] = -629491010] = "DATA";
|
|
24089
24496
|
SectionKinds2[SectionKinds2["SYMBOLS"] = 1461170197] = "SYMBOLS";
|
|
@@ -28181,12 +28588,26 @@ async function generateOptimizedProject(options) {
|
|
|
28181
28588
|
);
|
|
28182
28589
|
await createLocalBarrels(targets, config);
|
|
28183
28590
|
const buildConfigs = {};
|
|
28184
|
-
|
|
28591
|
+
const pick_one = config.products ? config.products.indexOf("pick-one") : -1;
|
|
28592
|
+
if (pick_one >= 0) {
|
|
28593
|
+
let preferredProduct = 0;
|
|
28594
|
+
targets.every((t, i) => {
|
|
28595
|
+
const dev = devices[t.product];
|
|
28596
|
+
if (!dev)
|
|
28597
|
+
return true;
|
|
28598
|
+
if (dev.ciqVersions.every((ciq) => ciq.startsWith("5"))) {
|
|
28599
|
+
preferredProduct = i;
|
|
28600
|
+
return false;
|
|
28601
|
+
}
|
|
28602
|
+
if (dev.ciqVersions.some((ciq) => ciq.startsWith("5"))) {
|
|
28603
|
+
preferredProduct = i;
|
|
28604
|
+
}
|
|
28605
|
+
return true;
|
|
28606
|
+
});
|
|
28607
|
+
options.products = [...options.products];
|
|
28608
|
+
options.products[pick_one] = targets[preferredProduct].product;
|
|
28609
|
+
}
|
|
28185
28610
|
if (config.skipOptimization) {
|
|
28186
|
-
if (pick_one >= 0) {
|
|
28187
|
-
options.products = [...options.products];
|
|
28188
|
-
options.products[pick_one] = targets[0].product;
|
|
28189
|
-
}
|
|
28190
28611
|
return {
|
|
28191
28612
|
jungleFiles: config.jungleFiles,
|
|
28192
28613
|
xml,
|
|
@@ -28209,12 +28630,7 @@ async function generateOptimizedProject(options) {
|
|
|
28209
28630
|
}
|
|
28210
28631
|
buildConfigs[key] = null;
|
|
28211
28632
|
}
|
|
28212
|
-
if (
|
|
28213
|
-
if (pick_one >= 0) {
|
|
28214
|
-
options.products = [...options.products];
|
|
28215
|
-
options.products[pick_one] = p.product;
|
|
28216
|
-
pick_one = -1;
|
|
28217
|
-
}
|
|
28633
|
+
if (!options.products || options.products.includes(p.product) || p.shape && options.products.includes(p.shape)) {
|
|
28218
28634
|
if (!buildConfigs[key]) {
|
|
28219
28635
|
buildConfigs[key] = p.group.optimizerConfig;
|
|
28220
28636
|
configsToBuild++;
|
|
@@ -28565,7 +28981,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
28565
28981
|
const opt_time = await (0, import_chunk_SG7ODKRM.first_modified)(
|
|
28566
28982
|
Object.values(fnMap).map((v) => v.output)
|
|
28567
28983
|
);
|
|
28568
|
-
if (source_time < opt_time &&
|
|
28984
|
+
if (source_time < opt_time && 1712442631755 < opt_time) {
|
|
28569
28985
|
return {
|
|
28570
28986
|
hasTests,
|
|
28571
28987
|
diagnostics: prevDiagnostics,
|
|
@@ -28604,7 +29020,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
28604
29020
|
hasTests: hasTests2,
|
|
28605
29021
|
diagnostics,
|
|
28606
29022
|
sdkVersion,
|
|
28607
|
-
optimizerVersion: "1.1.
|
|
29023
|
+
optimizerVersion: "1.1.52",
|
|
28608
29024
|
...Object.fromEntries(
|
|
28609
29025
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
28610
29026
|
)
|
|
@@ -29063,10 +29479,15 @@ function optimizeProgramBuffer(filepath, view, debugXml, apiDebugXml, key, confi
|
|
|
29063
29479
|
if (apiDebugXml) {
|
|
29064
29480
|
symbolTable.parseXml(apiDebugXml);
|
|
29065
29481
|
}
|
|
29066
|
-
const header = parseHeader(
|
|
29067
|
-
|
|
29068
|
-
|
|
29069
|
-
|
|
29482
|
+
const header = parseHeader(
|
|
29483
|
+
(sections[
|
|
29484
|
+
-805253120
|
|
29485
|
+
/* HEADER */
|
|
29486
|
+
] ?? sections[
|
|
29487
|
+
-805253107
|
|
29488
|
+
/* HEADER_VERSIONED */
|
|
29489
|
+
]).view
|
|
29490
|
+
);
|
|
29070
29491
|
parseData(sections[
|
|
29071
29492
|
-629491010
|
|
29072
29493
|
/* DATA */
|
|
@@ -29370,9 +29791,10 @@ async function getDeviceInfo() {
|
|
|
29370
29791
|
(part) => part.languages.map((lang) => [lang.code, true])
|
|
29371
29792
|
).flat(1)
|
|
29372
29793
|
);
|
|
29794
|
+
const ciqVersions = partNumbers.map((part) => part.connectIQVersion);
|
|
29373
29795
|
return [
|
|
29374
29796
|
deviceId,
|
|
29375
|
-
{ appTypes, deviceFamily, displayName, languages }
|
|
29797
|
+
{ appTypes, deviceFamily, displayName, languages, ciqVersions }
|
|
29376
29798
|
];
|
|
29377
29799
|
});
|
|
29378
29800
|
})
|