@markw65/monkeyc-optimizer 1.1.50 → 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 +9 -0
- package/build/api.cjs +34 -34
- package/build/{chunk-6KP65YOB.cjs → chunk-J5XJWBYV.cjs} +542 -111
- 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_6KP65YOB_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) {
|
|
@@ -5864,6 +5882,15 @@ function shouldInline(state, func, call, context) {
|
|
|
5864
5882
|
return true;
|
|
5865
5883
|
}
|
|
5866
5884
|
}
|
|
5885
|
+
if (requested && func.node.params.length !== args.length) {
|
|
5886
|
+
inlineDiagnostic(
|
|
5887
|
+
state,
|
|
5888
|
+
func,
|
|
5889
|
+
call,
|
|
5890
|
+
"This function cannot be inlined due to incorrect arguments"
|
|
5891
|
+
);
|
|
5892
|
+
return false;
|
|
5893
|
+
}
|
|
5867
5894
|
if (!context && requested) {
|
|
5868
5895
|
inlineDiagnostic(
|
|
5869
5896
|
state,
|
|
@@ -9071,6 +9098,8 @@ function checkCallArgs(istate, node, callees, args) {
|
|
|
9071
9098
|
if (cur.info === false) {
|
|
9072
9099
|
argEffects = false;
|
|
9073
9100
|
}
|
|
9101
|
+
if (effects)
|
|
9102
|
+
result.embeddedEffects = true;
|
|
9074
9103
|
const needsCheck = checker && (cur === callees || !isOverride(cur, callees));
|
|
9075
9104
|
const expectedArgs = (argTypes || cur.node.params).length;
|
|
9076
9105
|
if (args.length !== expectedArgs) {
|
|
@@ -9177,8 +9206,6 @@ function checkCallArgs(istate, node, callees, args) {
|
|
|
9177
9206
|
result.value.type = 524287;
|
|
9178
9207
|
delete result.value.value;
|
|
9179
9208
|
}
|
|
9180
|
-
if (effects)
|
|
9181
|
-
result.embeddedEffects = true;
|
|
9182
9209
|
return result;
|
|
9183
9210
|
},
|
|
9184
9211
|
{
|
|
@@ -19749,6 +19776,16 @@ function parseCode(view, lineTable) {
|
|
|
19749
19776
|
case 47:
|
|
19750
19777
|
case 10:
|
|
19751
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:
|
|
19752
19789
|
return { op, offset, size: 1 };
|
|
19753
19790
|
case 1:
|
|
19754
19791
|
case 15:
|
|
@@ -19757,6 +19794,7 @@ function parseCode(view, lineTable) {
|
|
|
19757
19794
|
case 43:
|
|
19758
19795
|
case 46:
|
|
19759
19796
|
case 53:
|
|
19797
|
+
case 56:
|
|
19760
19798
|
return { op, arg: view.getUint8(current++), offset, size: 2 };
|
|
19761
19799
|
case 25:
|
|
19762
19800
|
case 35:
|
|
@@ -19768,11 +19806,60 @@ function parseCode(view, lineTable) {
|
|
|
19768
19806
|
offset,
|
|
19769
19807
|
size: 3
|
|
19770
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
|
+
};
|
|
19771
19823
|
case 24:
|
|
19824
|
+
case 64:
|
|
19825
|
+
case 65:
|
|
19826
|
+
case 66:
|
|
19772
19827
|
case 37:
|
|
19773
19828
|
case 39:
|
|
19774
19829
|
case 52:
|
|
19830
|
+
case 71:
|
|
19831
|
+
case 67:
|
|
19775
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
|
+
};
|
|
19776
19863
|
case 49:
|
|
19777
19864
|
return {
|
|
19778
19865
|
op,
|
|
@@ -19848,6 +19935,16 @@ function opcodeSize(op) {
|
|
|
19848
19935
|
case 20:
|
|
19849
19936
|
case 54:
|
|
19850
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:
|
|
19851
19948
|
return 1;
|
|
19852
19949
|
case 1:
|
|
19853
19950
|
case 15:
|
|
@@ -19858,20 +19955,33 @@ function opcodeSize(op) {
|
|
|
19858
19955
|
case 53:
|
|
19859
19956
|
case 10:
|
|
19860
19957
|
case 11:
|
|
19958
|
+
case 56:
|
|
19861
19959
|
return 2;
|
|
19862
19960
|
case 25:
|
|
19863
19961
|
case 35:
|
|
19864
19962
|
case 40:
|
|
19865
19963
|
case 41:
|
|
19964
|
+
case 57:
|
|
19965
|
+
case 74:
|
|
19866
19966
|
return 3;
|
|
19967
|
+
case 58:
|
|
19968
|
+
return 4;
|
|
19969
|
+
case 64:
|
|
19970
|
+
case 65:
|
|
19971
|
+
case 66:
|
|
19867
19972
|
case 24:
|
|
19868
19973
|
case 37:
|
|
19869
19974
|
case 39:
|
|
19870
19975
|
case 52:
|
|
19871
19976
|
case 38:
|
|
19977
|
+
case 71:
|
|
19978
|
+
case 67:
|
|
19872
19979
|
return 5;
|
|
19980
|
+
case 70:
|
|
19981
|
+
return 6;
|
|
19873
19982
|
case 49:
|
|
19874
19983
|
case 50:
|
|
19984
|
+
case 69:
|
|
19875
19985
|
return 9;
|
|
19876
19986
|
case 36:
|
|
19877
19987
|
throw new Error(`Unknown opcode ${op}`);
|
|
@@ -19899,6 +20009,7 @@ function emitBytecode(bytecode, view, offset, linktable, shift_hack) {
|
|
|
19899
20009
|
case 43:
|
|
19900
20010
|
case 46:
|
|
19901
20011
|
case 53:
|
|
20012
|
+
case 56:
|
|
19902
20013
|
view.setUint8(offset++, bytecode.arg);
|
|
19903
20014
|
break;
|
|
19904
20015
|
case 25:
|
|
@@ -19908,12 +20019,36 @@ function emitBytecode(bytecode, view, offset, linktable, shift_hack) {
|
|
|
19908
20019
|
linktable.set(offset, bytecode.arg);
|
|
19909
20020
|
view.setInt16((offset += 2) - 2, 0);
|
|
19910
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:
|
|
19911
20033
|
case 24:
|
|
19912
20034
|
case 37:
|
|
19913
20035
|
case 39:
|
|
19914
|
-
case 52:
|
|
20036
|
+
case 52: {
|
|
19915
20037
|
view.setInt32((offset += 4) - 4, bytecode.arg);
|
|
19916
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;
|
|
19917
20052
|
case 49:
|
|
19918
20053
|
view.setBigInt64((offset += 8) - 8, bytecode.arg);
|
|
19919
20054
|
break;
|
|
@@ -19934,6 +20069,7 @@ function getOpInfo(bytecode) {
|
|
|
19934
20069
|
case 23:
|
|
19935
20070
|
case 1:
|
|
19936
20071
|
case 53:
|
|
20072
|
+
case 74:
|
|
19937
20073
|
case 25:
|
|
19938
20074
|
case 35:
|
|
19939
20075
|
return { pop: 0, push: 0 };
|
|
@@ -19969,27 +20105,49 @@ function getOpInfo(bytecode) {
|
|
|
19969
20105
|
case 14:
|
|
19970
20106
|
case 17:
|
|
19971
20107
|
return { pop: 3, push: 0 };
|
|
20108
|
+
case 73:
|
|
20109
|
+
return { pop: 3, push: 1 };
|
|
19972
20110
|
case 21:
|
|
19973
20111
|
case 32:
|
|
20112
|
+
case 75:
|
|
19974
20113
|
case 45:
|
|
19975
20114
|
case 48:
|
|
19976
20115
|
case 20:
|
|
19977
20116
|
case 54:
|
|
19978
20117
|
case 47:
|
|
20118
|
+
case 71:
|
|
19979
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:
|
|
19980
20127
|
case 42:
|
|
19981
20128
|
case 44:
|
|
19982
20129
|
case 43:
|
|
20130
|
+
case 62:
|
|
20131
|
+
case 63:
|
|
19983
20132
|
case 18:
|
|
19984
20133
|
case 46:
|
|
19985
20134
|
case 24:
|
|
19986
20135
|
case 37:
|
|
20136
|
+
case 55:
|
|
20137
|
+
case 56:
|
|
20138
|
+
case 57:
|
|
20139
|
+
case 58:
|
|
19987
20140
|
case 38:
|
|
20141
|
+
case 59:
|
|
19988
20142
|
case 39:
|
|
19989
20143
|
case 52:
|
|
19990
20144
|
case 49:
|
|
20145
|
+
case 60:
|
|
19991
20146
|
case 50:
|
|
20147
|
+
case 61:
|
|
19992
20148
|
return { pop: 0, push: 1 };
|
|
20149
|
+
case 72:
|
|
20150
|
+
return { pop: 1, push: 1 };
|
|
19993
20151
|
case 15:
|
|
19994
20152
|
return { pop: bytecode.arg + 1, push: 1 };
|
|
19995
20153
|
case 36:
|
|
@@ -20005,15 +20163,27 @@ function getOpEffects(bytecode) {
|
|
|
20005
20163
|
case 14:
|
|
20006
20164
|
return 2;
|
|
20007
20165
|
case 17:
|
|
20166
|
+
case 73:
|
|
20008
20167
|
return 4;
|
|
20009
20168
|
case 21:
|
|
20010
20169
|
return 2 | 4;
|
|
20011
20170
|
case 15:
|
|
20171
|
+
case 72:
|
|
20012
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;
|
|
20013
20182
|
case 0:
|
|
20014
20183
|
case 23:
|
|
20015
20184
|
case 1:
|
|
20016
20185
|
case 53:
|
|
20186
|
+
case 74:
|
|
20017
20187
|
case 25:
|
|
20018
20188
|
case 35:
|
|
20019
20189
|
case 2:
|
|
@@ -20039,9 +20209,9 @@ function getOpEffects(bytecode) {
|
|
|
20039
20209
|
case 31:
|
|
20040
20210
|
case 34:
|
|
20041
20211
|
case 33:
|
|
20042
|
-
case
|
|
20043
|
-
case 16:
|
|
20212
|
+
case 68:
|
|
20044
20213
|
case 32:
|
|
20214
|
+
case 75:
|
|
20045
20215
|
case 45:
|
|
20046
20216
|
case 48:
|
|
20047
20217
|
case 20:
|
|
@@ -20049,16 +20219,27 @@ function getOpEffects(bytecode) {
|
|
|
20049
20219
|
case 47:
|
|
20050
20220
|
case 42:
|
|
20051
20221
|
case 44:
|
|
20222
|
+
case 64:
|
|
20223
|
+
case 65:
|
|
20224
|
+
case 66:
|
|
20052
20225
|
case 43:
|
|
20053
|
-
case
|
|
20226
|
+
case 62:
|
|
20227
|
+
case 63:
|
|
20054
20228
|
case 46:
|
|
20055
20229
|
case 24:
|
|
20056
20230
|
case 37:
|
|
20231
|
+
case 55:
|
|
20232
|
+
case 56:
|
|
20233
|
+
case 57:
|
|
20234
|
+
case 58:
|
|
20057
20235
|
case 38:
|
|
20236
|
+
case 59:
|
|
20058
20237
|
case 39:
|
|
20059
20238
|
case 52:
|
|
20060
20239
|
case 49:
|
|
20240
|
+
case 60:
|
|
20061
20241
|
case 50:
|
|
20242
|
+
case 61:
|
|
20062
20243
|
return 0;
|
|
20063
20244
|
case 36:
|
|
20064
20245
|
throw new Error(`Unknown opcode ${bytecode.op}`);
|
|
@@ -20066,6 +20247,93 @@ function getOpEffects(bytecode) {
|
|
|
20066
20247
|
unhandledType(bytecode);
|
|
20067
20248
|
}
|
|
20068
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
|
+
}
|
|
20069
20337
|
function isBoolOp(op) {
|
|
20070
20338
|
switch (op) {
|
|
20071
20339
|
case 32:
|
|
@@ -20150,6 +20418,27 @@ var init_opcodes = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
20150
20418
|
Opcodes2[Opcodes2["cpush"] = 52] = "cpush";
|
|
20151
20419
|
Opcodes2[Opcodes2["argc"] = 53] = "argc";
|
|
20152
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";
|
|
20153
20442
|
return Opcodes2;
|
|
20154
20443
|
})(Opcodes || {});
|
|
20155
20444
|
}
|
|
@@ -20321,7 +20610,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
|
|
|
20321
20610
|
i = -1;
|
|
20322
20611
|
continue;
|
|
20323
20612
|
}
|
|
20324
|
-
if (top.exsucc && (bc.op === 15 || bc.op === 51)) {
|
|
20613
|
+
if (top.exsucc && (bc.op === 15 || bc.op === 72 || bc.op === 51)) {
|
|
20325
20614
|
doMerge(top.exsucc, true);
|
|
20326
20615
|
}
|
|
20327
20616
|
}
|
|
@@ -20607,8 +20896,11 @@ function interpBytecode(bc, localState, context) {
|
|
|
20607
20896
|
localState.stack.splice(-2, 2, { type });
|
|
20608
20897
|
};
|
|
20609
20898
|
switch (bc.op) {
|
|
20899
|
+
case 68:
|
|
20610
20900
|
case 18: {
|
|
20611
|
-
|
|
20901
|
+
const localNum = opReadsLocal(bc);
|
|
20902
|
+
(0, import_node_assert7.default)(localNum != null);
|
|
20903
|
+
let local = localState.locals[localNum];
|
|
20612
20904
|
if (local) {
|
|
20613
20905
|
local = { ...local };
|
|
20614
20906
|
delete local.equivs;
|
|
@@ -20619,7 +20911,7 @@ function interpBytecode(bc, localState, context) {
|
|
|
20619
20911
|
} };
|
|
20620
20912
|
}
|
|
20621
20913
|
localState.stack.push(local);
|
|
20622
|
-
addEquiv2(localState, -localState.stack.length,
|
|
20914
|
+
addEquiv2(localState, -localState.stack.length, localNum);
|
|
20623
20915
|
break;
|
|
20624
20916
|
}
|
|
20625
20917
|
case 46: {
|
|
@@ -20667,18 +20959,33 @@ function interpBytecode(bc, localState, context) {
|
|
|
20667
20959
|
localState.locals[bc.arg].type = value2.type;
|
|
20668
20960
|
break;
|
|
20669
20961
|
}
|
|
20962
|
+
case 55:
|
|
20963
|
+
xpush(8, 0);
|
|
20964
|
+
break;
|
|
20670
20965
|
case 37:
|
|
20966
|
+
case 56:
|
|
20967
|
+
case 57:
|
|
20968
|
+
case 58:
|
|
20671
20969
|
xpush(8, bc.arg);
|
|
20672
20970
|
break;
|
|
20673
20971
|
case 49:
|
|
20674
20972
|
xpush(16, bc.arg);
|
|
20675
20973
|
break;
|
|
20974
|
+
case 60:
|
|
20975
|
+
xpush(16, 0n);
|
|
20976
|
+
break;
|
|
20676
20977
|
case 38:
|
|
20677
20978
|
xpush(32, roundToFloat(bc.arg));
|
|
20678
20979
|
break;
|
|
20980
|
+
case 59:
|
|
20981
|
+
xpush(32, 0);
|
|
20982
|
+
break;
|
|
20679
20983
|
case 50:
|
|
20680
20984
|
xpush(64, bc.arg);
|
|
20681
20985
|
break;
|
|
20986
|
+
case 61:
|
|
20987
|
+
xpush(64, 0);
|
|
20988
|
+
break;
|
|
20682
20989
|
case 52:
|
|
20683
20990
|
xpush(128, String.fromCharCode(bc.arg));
|
|
20684
20991
|
break;
|
|
@@ -20688,6 +20995,18 @@ function interpBytecode(bc, localState, context) {
|
|
|
20688
20995
|
/* False */
|
|
20689
20996
|
);
|
|
20690
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;
|
|
20691
21010
|
case 44:
|
|
20692
21011
|
xpush(
|
|
20693
21012
|
1
|
|
@@ -21617,23 +21936,42 @@ function localDCE(func, context) {
|
|
|
21617
21936
|
}
|
|
21618
21937
|
break;
|
|
21619
21938
|
}
|
|
21939
|
+
case 70:
|
|
21940
|
+
case 68:
|
|
21941
|
+
case 67:
|
|
21620
21942
|
case 18:
|
|
21943
|
+
case 62:
|
|
21944
|
+
case 63:
|
|
21945
|
+
case 42:
|
|
21946
|
+
case 64:
|
|
21947
|
+
case 65:
|
|
21948
|
+
case 66:
|
|
21621
21949
|
case 44:
|
|
21622
21950
|
case 43:
|
|
21623
21951
|
case 24:
|
|
21624
21952
|
case 37:
|
|
21953
|
+
case 55:
|
|
21954
|
+
case 56:
|
|
21955
|
+
case 57:
|
|
21956
|
+
case 58:
|
|
21625
21957
|
case 38:
|
|
21958
|
+
case 59:
|
|
21626
21959
|
case 39:
|
|
21627
21960
|
case 52:
|
|
21628
21961
|
case 49:
|
|
21629
|
-
case
|
|
21962
|
+
case 60:
|
|
21963
|
+
case 50:
|
|
21964
|
+
case 61: {
|
|
21630
21965
|
const item = dceInfo.stack.pop();
|
|
21631
21966
|
if (item?.dead) {
|
|
21632
21967
|
item.deps.push(i);
|
|
21633
21968
|
reportNop(item);
|
|
21634
21969
|
item.deps.forEach((index) => makeNop(block.bytecodes[index]));
|
|
21635
|
-
} else
|
|
21636
|
-
|
|
21970
|
+
} else {
|
|
21971
|
+
const local = opReadsLocal(bytecode);
|
|
21972
|
+
if (local != null) {
|
|
21973
|
+
dceInfo.locals.add(local);
|
|
21974
|
+
}
|
|
21637
21975
|
}
|
|
21638
21976
|
break;
|
|
21639
21977
|
}
|
|
@@ -21671,6 +22009,7 @@ function localDCE(func, context) {
|
|
|
21671
22009
|
}
|
|
21672
22010
|
case 21:
|
|
21673
22011
|
case 32:
|
|
22012
|
+
case 75:
|
|
21674
22013
|
case 45:
|
|
21675
22014
|
case 48:
|
|
21676
22015
|
case 20:
|
|
@@ -21689,10 +22028,26 @@ function localDCE(func, context) {
|
|
|
21689
22028
|
}
|
|
21690
22029
|
case 51:
|
|
21691
22030
|
case 15:
|
|
22031
|
+
case 72:
|
|
21692
22032
|
if (block.exsucc) {
|
|
21693
22033
|
liveInLocals.get(block.exsucc)?.forEach((local) => dceInfo.locals.add(local));
|
|
21694
22034
|
}
|
|
21695
|
-
|
|
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: {
|
|
21696
22051
|
let { push, pop } = getOpInfo(bytecode);
|
|
21697
22052
|
while (push-- > 0) {
|
|
21698
22053
|
dceInfo.stack.pop();
|
|
@@ -21700,7 +22055,10 @@ function localDCE(func, context) {
|
|
|
21700
22055
|
while (pop-- > 0) {
|
|
21701
22056
|
dceInfo.stack.push({ dead: false });
|
|
21702
22057
|
}
|
|
22058
|
+
break;
|
|
21703
22059
|
}
|
|
22060
|
+
default:
|
|
22061
|
+
unhandledType(bytecode);
|
|
21704
22062
|
}
|
|
21705
22063
|
}
|
|
21706
22064
|
if (changes) {
|
|
@@ -21723,18 +22081,22 @@ function computeLiveLocals(func) {
|
|
|
21723
22081
|
(block) => new Set(liveOutLocals.get(block.offset)),
|
|
21724
22082
|
(block, bc, locals) => {
|
|
21725
22083
|
switch (bc.op) {
|
|
21726
|
-
case 18:
|
|
21727
|
-
locals.add(bc.arg);
|
|
21728
|
-
break;
|
|
21729
22084
|
case 19:
|
|
21730
22085
|
locals.delete(bc.arg);
|
|
21731
22086
|
break;
|
|
21732
22087
|
case 51:
|
|
21733
22088
|
case 15:
|
|
22089
|
+
case 72:
|
|
21734
22090
|
if (block.exsucc) {
|
|
21735
22091
|
liveInLocals.get(block.exsucc)?.forEach((local) => locals.add(local));
|
|
21736
22092
|
}
|
|
21737
22093
|
break;
|
|
22094
|
+
default: {
|
|
22095
|
+
const local = opReadsLocal(bc);
|
|
22096
|
+
if (local != null) {
|
|
22097
|
+
locals.add(local);
|
|
22098
|
+
}
|
|
22099
|
+
}
|
|
21738
22100
|
}
|
|
21739
22101
|
},
|
|
21740
22102
|
(block, locals) => {
|
|
@@ -21758,6 +22120,7 @@ function computeLiveLocals(func) {
|
|
|
21758
22120
|
var init_dce = (0, import_chunk_ABYVSU2C.__esm)({
|
|
21759
22121
|
"src/readprg/dce.ts"() {
|
|
21760
22122
|
"use strict";
|
|
22123
|
+
init_data_flow();
|
|
21761
22124
|
(0, import_chunk_SG7ODKRM.init_util)();
|
|
21762
22125
|
init_bytecode();
|
|
21763
22126
|
init_cflow();
|
|
@@ -21787,6 +22150,13 @@ function mergeInto2(from, to) {
|
|
|
21787
22150
|
});
|
|
21788
22151
|
return changed;
|
|
21789
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
|
+
}
|
|
21790
22160
|
function minimizeLocals2(func, equivSets, context) {
|
|
21791
22161
|
const splitRanges = computeSplitRanges(func, equivSets);
|
|
21792
22162
|
const locals = mergeSplitRanges(splitRanges);
|
|
@@ -21796,21 +22166,22 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21796
22166
|
const colors = /* @__PURE__ */ new Map();
|
|
21797
22167
|
const merge = [];
|
|
21798
22168
|
locals.forEach((local, key) => {
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
|
|
21802
|
-
|
|
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) {
|
|
21803
22174
|
if (merged) {
|
|
21804
|
-
(0, import_node_assert9.default)(!
|
|
22175
|
+
(0, import_node_assert9.default)(!localNum);
|
|
21805
22176
|
merged.push(key);
|
|
21806
22177
|
} else {
|
|
21807
|
-
merge[
|
|
22178
|
+
merge[localNum] = [key];
|
|
21808
22179
|
}
|
|
21809
22180
|
}
|
|
21810
22181
|
}
|
|
21811
22182
|
});
|
|
21812
22183
|
locals.forEach((local, key) => {
|
|
21813
|
-
if (key.op
|
|
22184
|
+
if (key.op !== 19)
|
|
21814
22185
|
return;
|
|
21815
22186
|
let inUse = 0n;
|
|
21816
22187
|
local.conflicts.forEach((conflict) => {
|
|
@@ -21837,10 +22208,13 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21837
22208
|
if (argc != null && i <= argc)
|
|
21838
22209
|
break;
|
|
21839
22210
|
const merged = merge[i];
|
|
21840
|
-
if (merged
|
|
21841
|
-
|
|
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;
|
|
21842
22216
|
const other = merge[j];
|
|
21843
|
-
if (other.every((elem) => elem
|
|
22217
|
+
if (other.every((elem) => getLocalNum(elem) !== j)) {
|
|
21844
22218
|
merge[i] = other;
|
|
21845
22219
|
merge[j] = merged;
|
|
21846
22220
|
merged.forEach((elem) => colors.set(elem, j));
|
|
@@ -21895,6 +22269,20 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21895
22269
|
let filter = false;
|
|
21896
22270
|
block.bytecodes.forEach((bc) => {
|
|
21897
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
|
+
}
|
|
21898
22286
|
case 53:
|
|
21899
22287
|
argc = bc.arg;
|
|
21900
22288
|
break;
|
|
@@ -21916,11 +22304,16 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21916
22304
|
}
|
|
21917
22305
|
break;
|
|
21918
22306
|
}
|
|
22307
|
+
case 70:
|
|
21919
22308
|
case 18:
|
|
21920
22309
|
case 19: {
|
|
21921
22310
|
const info = fixupMap.get(bc);
|
|
21922
22311
|
(0, import_node_assert9.default)(info != null);
|
|
21923
|
-
bc.
|
|
22312
|
+
if (bc.op === 70) {
|
|
22313
|
+
bc.arg.local = info.color;
|
|
22314
|
+
} else {
|
|
22315
|
+
bc.arg = info.color;
|
|
22316
|
+
}
|
|
21924
22317
|
if (info.range) {
|
|
21925
22318
|
bc.range = info.range;
|
|
21926
22319
|
} else {
|
|
@@ -21928,6 +22321,17 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
21928
22321
|
}
|
|
21929
22322
|
break;
|
|
21930
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));
|
|
21931
22335
|
}
|
|
21932
22336
|
});
|
|
21933
22337
|
if (filter) {
|
|
@@ -21943,43 +22347,34 @@ function computeSplitRanges(func, equivSets) {
|
|
|
21943
22347
|
const liveOutLocals = /* @__PURE__ */ new Map();
|
|
21944
22348
|
const liveInLocals = /* @__PURE__ */ new Map();
|
|
21945
22349
|
const splitRanges = /* @__PURE__ */ new Map();
|
|
21946
|
-
const
|
|
21947
|
-
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);
|
|
21948
22354
|
if (!bcs) {
|
|
21949
|
-
locals.set(
|
|
22355
|
+
locals.set(localid, /* @__PURE__ */ new Set([bc]));
|
|
21950
22356
|
} else {
|
|
21951
22357
|
bcs.add(bc);
|
|
21952
22358
|
}
|
|
21953
22359
|
};
|
|
21954
|
-
const fakeLgetvs = /* @__PURE__ */ new Map();
|
|
21955
22360
|
postOrderPropagate(
|
|
21956
22361
|
func,
|
|
21957
22362
|
(block) => cloneLive(liveOutLocals.get(block.offset)),
|
|
21958
22363
|
(block, bc, locals) => {
|
|
21959
22364
|
switch (bc.op) {
|
|
21960
|
-
case
|
|
21961
|
-
|
|
21962
|
-
|
|
21963
|
-
|
|
21964
|
-
op: 18,
|
|
21965
|
-
arg: 0,
|
|
21966
|
-
size: 2,
|
|
21967
|
-
offset: bc.offset
|
|
21968
|
-
};
|
|
21969
|
-
fakeLgetvs.set(bc, fakeLgetv);
|
|
21970
|
-
}
|
|
21971
|
-
recordLgetv(locals, fakeLgetv);
|
|
21972
|
-
break;
|
|
21973
|
-
}
|
|
22365
|
+
case 68:
|
|
22366
|
+
case 67:
|
|
22367
|
+
case 70:
|
|
22368
|
+
case 42:
|
|
21974
22369
|
case 18:
|
|
21975
|
-
|
|
22370
|
+
recordLocalRead(locals, bc);
|
|
21976
22371
|
break;
|
|
21977
22372
|
case 19: {
|
|
21978
22373
|
let bcs = locals.get(bc.arg);
|
|
21979
22374
|
if (!bcs) {
|
|
21980
22375
|
bcs = /* @__PURE__ */ new Set();
|
|
21981
22376
|
}
|
|
21982
|
-
|
|
22377
|
+
const ranges = splitRanges.get(bc.arg);
|
|
21983
22378
|
const equiv = equivSets.get(bc);
|
|
21984
22379
|
const conflicts = /* @__PURE__ */ new Set();
|
|
21985
22380
|
locals.forEach((liveBcs, local) => {
|
|
@@ -21990,10 +22385,7 @@ function computeSplitRanges(func, equivSets) {
|
|
|
21990
22385
|
liveBcs.forEach((lbc) => conflicts.add(lbc));
|
|
21991
22386
|
});
|
|
21992
22387
|
if (!ranges) {
|
|
21993
|
-
splitRanges.set(
|
|
21994
|
-
bc.arg,
|
|
21995
|
-
ranges = /* @__PURE__ */ new Map([[bc, { live: bcs, conflicts }]])
|
|
21996
|
-
);
|
|
22388
|
+
splitRanges.set(bc.arg, /* @__PURE__ */ new Map([[bc, { live: bcs, conflicts }]]));
|
|
21997
22389
|
} else {
|
|
21998
22390
|
ranges.set(bc, { live: bcs, conflicts });
|
|
21999
22391
|
}
|
|
@@ -22002,6 +22394,7 @@ function computeSplitRanges(func, equivSets) {
|
|
|
22002
22394
|
}
|
|
22003
22395
|
case 51:
|
|
22004
22396
|
case 15:
|
|
22397
|
+
case 72:
|
|
22005
22398
|
if (block.exsucc) {
|
|
22006
22399
|
const from = liveInLocals.get(block.exsucc);
|
|
22007
22400
|
if (from) {
|
|
@@ -22009,6 +22402,8 @@ function computeSplitRanges(func, equivSets) {
|
|
|
22009
22402
|
}
|
|
22010
22403
|
}
|
|
22011
22404
|
break;
|
|
22405
|
+
default:
|
|
22406
|
+
(0, import_node_assert9.default)(opReadsLocal(bc) == null);
|
|
22012
22407
|
}
|
|
22013
22408
|
},
|
|
22014
22409
|
(block, locals) => {
|
|
@@ -22071,7 +22466,7 @@ function mergeSplitRanges(splitRanges) {
|
|
|
22071
22466
|
let lputv = null;
|
|
22072
22467
|
let singleRange = null;
|
|
22073
22468
|
pvSet.forEach((pv) => {
|
|
22074
|
-
if (!lputv || pv.op
|
|
22469
|
+
if (!lputv || pv.op !== 19)
|
|
22075
22470
|
lputv = pv;
|
|
22076
22471
|
});
|
|
22077
22472
|
pvSet.forEach((pv) => {
|
|
@@ -22100,6 +22495,7 @@ function mergeSplitRanges(splitRanges) {
|
|
|
22100
22495
|
v.conflicts = new Set(
|
|
22101
22496
|
Array.from(v.conflicts).flatMap((bc) => {
|
|
22102
22497
|
const r = bcToLiveRange.get(bc);
|
|
22498
|
+
(0, import_node_assert9.default)(r);
|
|
22103
22499
|
if (!r) {
|
|
22104
22500
|
(0, import_node_assert9.default)(bc.arg === 0);
|
|
22105
22501
|
return [];
|
|
@@ -22253,7 +22649,7 @@ function sizeBasedPRE2(func, context) {
|
|
|
22253
22649
|
const bcs = canonicalMap.get(key);
|
|
22254
22650
|
(0, import_node_assert10.default)(bcs);
|
|
22255
22651
|
let index = block.bytecodes.findIndex(
|
|
22256
|
-
(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)
|
|
22257
22653
|
);
|
|
22258
22654
|
if (index < 0) {
|
|
22259
22655
|
if (block.next && !block.taken) {
|
|
@@ -23168,6 +23564,7 @@ function getLocalsInfo(func) {
|
|
|
23168
23564
|
break;
|
|
23169
23565
|
case 51:
|
|
23170
23566
|
case 15:
|
|
23567
|
+
case 72:
|
|
23171
23568
|
if (block.exsucc) {
|
|
23172
23569
|
const from = liveInLocals.get(block.exsucc);
|
|
23173
23570
|
if (from) {
|
|
@@ -23261,8 +23658,11 @@ var init_exceptions = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
23261
23658
|
});
|
|
23262
23659
|
function parseHeader(view) {
|
|
23263
23660
|
let offset = 0;
|
|
23264
|
-
const
|
|
23661
|
+
const word = view.getUint32((offset += 4) - 4);
|
|
23662
|
+
const ciqVersion = word & 16777215;
|
|
23663
|
+
const headerVersion = word >>> 24;
|
|
23265
23664
|
const header = {
|
|
23665
|
+
headerVersion,
|
|
23266
23666
|
ciqVersion,
|
|
23267
23667
|
backgroundOffsets: { data: 0, code: 0 },
|
|
23268
23668
|
appLock: false,
|
|
@@ -23287,10 +23687,13 @@ function parseHeader(view) {
|
|
|
23287
23687
|
return header;
|
|
23288
23688
|
}
|
|
23289
23689
|
function fixupHeader(context, updateInfo) {
|
|
23290
|
-
const view = context.sections[
|
|
23690
|
+
const view = (context.sections[
|
|
23291
23691
|
-805253120
|
|
23292
23692
|
/* HEADER */
|
|
23293
|
-
].
|
|
23693
|
+
] ?? context.sections[
|
|
23694
|
+
-805253107
|
|
23695
|
+
/* HEADER_VERSIONED */
|
|
23696
|
+
]).view;
|
|
23294
23697
|
if (context.header.backgroundOffsets.code !== 0) {
|
|
23295
23698
|
const offset = updateInfo.offsetMap.get(
|
|
23296
23699
|
context.header.backgroundOffsets.code
|
|
@@ -23707,6 +24110,16 @@ function lineInfoToString(lineInfo, context) {
|
|
|
23707
24110
|
}
|
|
23708
24111
|
function bytecodeToString(bytecode, symbolTable) {
|
|
23709
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
|
+
};
|
|
23710
24123
|
switch (bytecode.op) {
|
|
23711
24124
|
case 18:
|
|
23712
24125
|
case 19:
|
|
@@ -23714,30 +24127,31 @@ function bytecodeToString(bytecode, symbolTable) {
|
|
|
23714
24127
|
arg = `${bytecode.range.name} ${bytecode.arg}${bytecode.range.isParam ? " (param)" : ""}`;
|
|
23715
24128
|
}
|
|
23716
24129
|
break;
|
|
23717
|
-
case 39:
|
|
23718
|
-
|
|
23719
|
-
if (argSym) {
|
|
23720
|
-
const symbol = symbolTable?.symbols.get(argSym);
|
|
23721
|
-
if (symbol) {
|
|
23722
|
-
arg = `${symbol.str} (${bytecode.arg})`;
|
|
23723
|
-
}
|
|
23724
|
-
}
|
|
24130
|
+
case 39:
|
|
24131
|
+
arg = symbol(bytecode.arg);
|
|
23725
24132
|
break;
|
|
23726
|
-
}
|
|
23727
24133
|
case 24: {
|
|
23728
|
-
const
|
|
23729
|
-
if (
|
|
23730
|
-
arg = `${JSON.stringify(
|
|
24134
|
+
const symbol2 = symbolTable?.symbols.get(bytecode.arg);
|
|
24135
|
+
if (symbol2) {
|
|
24136
|
+
arg = `${JSON.stringify(symbol2.str)} (${bytecode.arg})`;
|
|
23731
24137
|
}
|
|
23732
24138
|
break;
|
|
23733
24139
|
}
|
|
23734
24140
|
case 40:
|
|
23735
24141
|
case 41:
|
|
23736
24142
|
case 25:
|
|
23737
|
-
case 35:
|
|
24143
|
+
case 35:
|
|
23738
24144
|
arg = offsetToString(bytecode.arg);
|
|
23739
24145
|
break;
|
|
23740
|
-
|
|
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;
|
|
23741
24155
|
}
|
|
23742
24156
|
if (arg == null && (0, import_chunk_MBTLUWXR.hasProperty)(bytecode, "arg")) {
|
|
23743
24157
|
arg = `${bytecode.arg}`;
|
|
@@ -23792,6 +24206,7 @@ function findFunctions({
|
|
|
23792
24206
|
next = void 0;
|
|
23793
24207
|
break;
|
|
23794
24208
|
case 15:
|
|
24209
|
+
case 72:
|
|
23795
24210
|
mayThrow2 = true;
|
|
23796
24211
|
break;
|
|
23797
24212
|
case 22:
|
|
@@ -23980,8 +24395,8 @@ function splitBlock(func, block, offset) {
|
|
|
23980
24395
|
const fixEx = (block2, isNew) => {
|
|
23981
24396
|
if (block2.exsucc) {
|
|
23982
24397
|
if (!block2.bytecodes.some(
|
|
23983
|
-
(bc) => bc.op === 51 || bc.op === 15
|
|
23984
|
-
/*
|
|
24398
|
+
(bc) => bc.op === 51 || bc.op === 15 || bc.op === 72
|
|
24399
|
+
/* invokemz */
|
|
23985
24400
|
)) {
|
|
23986
24401
|
if (!isNew) {
|
|
23987
24402
|
removePred(func, block2.exsucc, block2.offset);
|
|
@@ -24075,6 +24490,7 @@ var init_bytecode = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
24075
24490
|
init_optimize2();
|
|
24076
24491
|
SectionKinds = /* @__PURE__ */ ((SectionKinds2) => {
|
|
24077
24492
|
SectionKinds2[SectionKinds2["HEADER"] = -805253120] = "HEADER";
|
|
24493
|
+
SectionKinds2[SectionKinds2["HEADER_VERSIONED"] = -805253107] = "HEADER_VERSIONED";
|
|
24078
24494
|
SectionKinds2[SectionKinds2["TEXT"] = -1059145026] = "TEXT";
|
|
24079
24495
|
SectionKinds2[SectionKinds2["DATA"] = -629491010] = "DATA";
|
|
24080
24496
|
SectionKinds2[SectionKinds2["SYMBOLS"] = 1461170197] = "SYMBOLS";
|
|
@@ -28172,12 +28588,26 @@ async function generateOptimizedProject(options) {
|
|
|
28172
28588
|
);
|
|
28173
28589
|
await createLocalBarrels(targets, config);
|
|
28174
28590
|
const buildConfigs = {};
|
|
28175
|
-
|
|
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
|
+
}
|
|
28176
28610
|
if (config.skipOptimization) {
|
|
28177
|
-
if (pick_one >= 0) {
|
|
28178
|
-
options.products = [...options.products];
|
|
28179
|
-
options.products[pick_one] = targets[0].product;
|
|
28180
|
-
}
|
|
28181
28611
|
return {
|
|
28182
28612
|
jungleFiles: config.jungleFiles,
|
|
28183
28613
|
xml,
|
|
@@ -28200,12 +28630,7 @@ async function generateOptimizedProject(options) {
|
|
|
28200
28630
|
}
|
|
28201
28631
|
buildConfigs[key] = null;
|
|
28202
28632
|
}
|
|
28203
|
-
if (
|
|
28204
|
-
if (pick_one >= 0) {
|
|
28205
|
-
options.products = [...options.products];
|
|
28206
|
-
options.products[pick_one] = p.product;
|
|
28207
|
-
pick_one = -1;
|
|
28208
|
-
}
|
|
28633
|
+
if (!options.products || options.products.includes(p.product) || p.shape && options.products.includes(p.shape)) {
|
|
28209
28634
|
if (!buildConfigs[key]) {
|
|
28210
28635
|
buildConfigs[key] = p.group.optimizerConfig;
|
|
28211
28636
|
configsToBuild++;
|
|
@@ -28556,7 +28981,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
28556
28981
|
const opt_time = await (0, import_chunk_SG7ODKRM.first_modified)(
|
|
28557
28982
|
Object.values(fnMap).map((v) => v.output)
|
|
28558
28983
|
);
|
|
28559
|
-
if (source_time < opt_time &&
|
|
28984
|
+
if (source_time < opt_time && 1712442631755 < opt_time) {
|
|
28560
28985
|
return {
|
|
28561
28986
|
hasTests,
|
|
28562
28987
|
diagnostics: prevDiagnostics,
|
|
@@ -28595,7 +29020,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
28595
29020
|
hasTests: hasTests2,
|
|
28596
29021
|
diagnostics,
|
|
28597
29022
|
sdkVersion,
|
|
28598
|
-
optimizerVersion: "1.1.
|
|
29023
|
+
optimizerVersion: "1.1.52",
|
|
28599
29024
|
...Object.fromEntries(
|
|
28600
29025
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
28601
29026
|
)
|
|
@@ -29054,10 +29479,15 @@ function optimizeProgramBuffer(filepath, view, debugXml, apiDebugXml, key, confi
|
|
|
29054
29479
|
if (apiDebugXml) {
|
|
29055
29480
|
symbolTable.parseXml(apiDebugXml);
|
|
29056
29481
|
}
|
|
29057
|
-
const header = parseHeader(
|
|
29058
|
-
|
|
29059
|
-
|
|
29060
|
-
|
|
29482
|
+
const header = parseHeader(
|
|
29483
|
+
(sections[
|
|
29484
|
+
-805253120
|
|
29485
|
+
/* HEADER */
|
|
29486
|
+
] ?? sections[
|
|
29487
|
+
-805253107
|
|
29488
|
+
/* HEADER_VERSIONED */
|
|
29489
|
+
]).view
|
|
29490
|
+
);
|
|
29061
29491
|
parseData(sections[
|
|
29062
29492
|
-629491010
|
|
29063
29493
|
/* DATA */
|
|
@@ -29361,9 +29791,10 @@ async function getDeviceInfo() {
|
|
|
29361
29791
|
(part) => part.languages.map((lang) => [lang.code, true])
|
|
29362
29792
|
).flat(1)
|
|
29363
29793
|
);
|
|
29794
|
+
const ciqVersions = partNumbers.map((part) => part.connectIQVersion);
|
|
29364
29795
|
return [
|
|
29365
29796
|
deviceId,
|
|
29366
|
-
{ appTypes, deviceFamily, displayName, languages }
|
|
29797
|
+
{ appTypes, deviceFamily, displayName, languages, ciqVersions }
|
|
29367
29798
|
];
|
|
29368
29799
|
});
|
|
29369
29800
|
})
|