@markw65/monkeyc-optimizer 1.1.64 → 1.1.66
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 +15 -0
- package/build/api.cjs +35 -35
- package/build/{chunk-SG7ODKRM.cjs → chunk-67LU4GPQ.cjs} +54 -49
- package/build/{chunk-VZBYW6QS.cjs → chunk-UDJNFXSX.cjs} +435 -368
- package/build/optimizer.cjs +19 -19
- package/build/sdk-util.cjs +15 -15
- package/build/src/ast.d.ts +1 -13
- package/build/src/build-config.d.ts +1 -0
- package/build/util.cjs +26 -26
- package/build/worker-thread.cjs +4 -4
- 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_UDJNFXSX_exports = {};
|
|
30
|
+
__export(chunk_UDJNFXSX_exports, {
|
|
31
31
|
EnumTagsConst: () => EnumTagsConst,
|
|
32
32
|
LastTypeTag: () => LastTypeTag,
|
|
33
33
|
ObjectLikeTagsConst: () => ObjectLikeTagsConst,
|
|
@@ -134,8 +134,8 @@ __export(chunk_VZBYW6QS_exports, {
|
|
|
134
134
|
visitorNode: () => visitorNode,
|
|
135
135
|
xml_util_exports: () => xml_util_exports
|
|
136
136
|
});
|
|
137
|
-
module.exports = __toCommonJS(
|
|
138
|
-
var
|
|
137
|
+
module.exports = __toCommonJS(chunk_UDJNFXSX_exports);
|
|
138
|
+
var import_chunk_67LU4GPQ = require("./chunk-67LU4GPQ.cjs");
|
|
139
139
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
140
140
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
141
141
|
var import_node_assert = __toESM(require("node:assert"));
|
|
@@ -5643,49 +5643,56 @@ var init_build_config = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
5643
5643
|
scope: "resource"
|
|
5644
5644
|
},
|
|
5645
5645
|
trustDeclaredTypes: {
|
|
5646
|
-
order:
|
|
5646
|
+
order: 100,
|
|
5647
5647
|
type: "boolean",
|
|
5648
5648
|
markdownDescription: "[Whether to rely on type declarations when optimizing](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#trust-declared-types)",
|
|
5649
5649
|
default: true,
|
|
5650
5650
|
scope: "resource"
|
|
5651
5651
|
},
|
|
5652
5652
|
propagateTypes: {
|
|
5653
|
-
order:
|
|
5653
|
+
order: 110,
|
|
5654
5654
|
type: "boolean",
|
|
5655
5655
|
markdownDescription: "[Whether to propagate type information, or process it locally](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#propagate-types)",
|
|
5656
5656
|
default: true,
|
|
5657
5657
|
scope: "resource"
|
|
5658
5658
|
},
|
|
5659
5659
|
sizeBasedPRE: {
|
|
5660
|
-
order:
|
|
5660
|
+
order: 111,
|
|
5661
5661
|
type: "boolean",
|
|
5662
5662
|
markdownDescription: "[Whether to enable the size based partial redundancy pass](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#size-based-pre)",
|
|
5663
5663
|
default: true,
|
|
5664
5664
|
scope: "resource"
|
|
5665
5665
|
},
|
|
5666
|
+
preSkipLiterals: {
|
|
5667
|
+
order: 112,
|
|
5668
|
+
type: "boolean",
|
|
5669
|
+
markdownDescription: "[Whether to skip the size based partial redundancy pass for literal values](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#size-based-pre-skip-literals)",
|
|
5670
|
+
default: false,
|
|
5671
|
+
scope: "resource"
|
|
5672
|
+
},
|
|
5666
5673
|
minimizeLocals: {
|
|
5667
|
-
order:
|
|
5674
|
+
order: 120,
|
|
5668
5675
|
type: "boolean",
|
|
5669
5676
|
markdownDescription: "[Whether to enable the minimize locals pass](https://github.com/markw65/monkeyc-optimizer/wiki/Local-variable-elimination#minimize-locals)",
|
|
5670
5677
|
default: true,
|
|
5671
5678
|
scope: "resource"
|
|
5672
5679
|
},
|
|
5673
5680
|
singleUseCopyProp: {
|
|
5674
|
-
order:
|
|
5681
|
+
order: 120,
|
|
5675
5682
|
type: "boolean",
|
|
5676
5683
|
markdownDescription: "[Whether to enable the single use copy propagation pass](https://github.com/markw65/monkeyc-optimizer/wiki/Local-variable-elimination#single-use-copy-propagation)",
|
|
5677
5684
|
default: true,
|
|
5678
5685
|
scope: "resource"
|
|
5679
5686
|
},
|
|
5680
5687
|
minimizeModules: {
|
|
5681
|
-
order:
|
|
5688
|
+
order: 120,
|
|
5682
5689
|
type: "boolean",
|
|
5683
5690
|
markdownDescription: "[Whether to enable the minimize modules pass](https://github.com/markw65/monkeyc-optimizer/wiki/Optimizing-module-imports#minimize-modules)",
|
|
5684
5691
|
default: true,
|
|
5685
5692
|
scope: "resource"
|
|
5686
5693
|
},
|
|
5687
5694
|
iterateOptimizer: {
|
|
5688
|
-
order:
|
|
5695
|
+
order: 120,
|
|
5689
5696
|
type: "boolean",
|
|
5690
5697
|
description: "Whether to keep running the optimizer pass until it makes no further changes (may be slow)",
|
|
5691
5698
|
default: false,
|
|
@@ -7319,9 +7326,9 @@ function buildReducedGraph(state, func, refsForUpdate, notice) {
|
|
|
7319
7326
|
);
|
|
7320
7327
|
}
|
|
7321
7328
|
} else {
|
|
7322
|
-
(0,
|
|
7329
|
+
(0, import_chunk_67LU4GPQ.forEach)(events, (e) => e.mayThrow = false);
|
|
7323
7330
|
}
|
|
7324
|
-
(0,
|
|
7331
|
+
(0, import_chunk_67LU4GPQ.forEach)(events, (event) => {
|
|
7325
7332
|
if (event.mayThrow) {
|
|
7326
7333
|
for (let i = localState.stack.length; i--; ) {
|
|
7327
7334
|
const target = localState.stack[i].throw;
|
|
@@ -7466,7 +7473,7 @@ var init_control_flow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
7466
7473
|
"src/control-flow.ts"() {
|
|
7467
7474
|
"use strict";
|
|
7468
7475
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
7469
|
-
(0,
|
|
7476
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
7470
7477
|
Terminals = {
|
|
7471
7478
|
BreakStatement: "break",
|
|
7472
7479
|
ContinueStatement: "continue",
|
|
@@ -7496,12 +7503,12 @@ var init_control_flow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
7496
7503
|
if (!from.succs) {
|
|
7497
7504
|
from.succs = [to];
|
|
7498
7505
|
} else {
|
|
7499
|
-
(0,
|
|
7506
|
+
(0, import_chunk_67LU4GPQ.pushUnique)(from.succs, to);
|
|
7500
7507
|
}
|
|
7501
7508
|
if (!to.preds) {
|
|
7502
7509
|
to.preds = [from];
|
|
7503
7510
|
} else {
|
|
7504
|
-
(0,
|
|
7511
|
+
(0, import_chunk_67LU4GPQ.pushUnique)(to.preds, from);
|
|
7505
7512
|
}
|
|
7506
7513
|
}
|
|
7507
7514
|
newBlock(block) {
|
|
@@ -7855,8 +7862,8 @@ function mergeObjectValues(to, from) {
|
|
|
7855
7862
|
function mergeStateDecls(to, from) {
|
|
7856
7863
|
let changed = false;
|
|
7857
7864
|
let result = to;
|
|
7858
|
-
(0,
|
|
7859
|
-
if ((0,
|
|
7865
|
+
(0, import_chunk_67LU4GPQ.forEach)(from, (v) => {
|
|
7866
|
+
if ((0, import_chunk_67LU4GPQ.some)(to, (t) => t === v)) {
|
|
7860
7867
|
return;
|
|
7861
7868
|
}
|
|
7862
7869
|
if (Array.isArray(result)) {
|
|
@@ -8023,7 +8030,7 @@ var init_union_type = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
8023
8030
|
"use strict";
|
|
8024
8031
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
8025
8032
|
init_data_flow();
|
|
8026
|
-
(0,
|
|
8033
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
8027
8034
|
init_could_be();
|
|
8028
8035
|
init_intersection_type();
|
|
8029
8036
|
init_sub_type();
|
|
@@ -8038,7 +8045,7 @@ function expandTypedef(t) {
|
|
|
8038
8045
|
);
|
|
8039
8046
|
const tExpanded = cloneType(t);
|
|
8040
8047
|
clearValuesUnder(tExpanded, 262144, true);
|
|
8041
|
-
(0,
|
|
8048
|
+
(0, import_chunk_67LU4GPQ.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
|
|
8042
8049
|
return tExpanded;
|
|
8043
8050
|
}
|
|
8044
8051
|
function intersectEnum(t, e) {
|
|
@@ -8232,9 +8239,9 @@ function intersectionValue(pair) {
|
|
|
8232
8239
|
case 4096:
|
|
8233
8240
|
case 8192: {
|
|
8234
8241
|
const common = [];
|
|
8235
|
-
(0,
|
|
8242
|
+
(0, import_chunk_67LU4GPQ.forEach)(
|
|
8236
8243
|
pair.avalue,
|
|
8237
|
-
(sna) => (0,
|
|
8244
|
+
(sna) => (0, import_chunk_67LU4GPQ.some)(pair.bvalue, (snb) => sna === snb) && common.push(sna)
|
|
8238
8245
|
);
|
|
8239
8246
|
if (!common.length)
|
|
8240
8247
|
return null;
|
|
@@ -8242,9 +8249,9 @@ function intersectionValue(pair) {
|
|
|
8242
8249
|
}
|
|
8243
8250
|
case 16384: {
|
|
8244
8251
|
const common = [];
|
|
8245
|
-
(0,
|
|
8252
|
+
(0, import_chunk_67LU4GPQ.forEach)(pair.avalue, (sna) => {
|
|
8246
8253
|
const superA = getSuperClasses(sna);
|
|
8247
|
-
(0,
|
|
8254
|
+
(0, import_chunk_67LU4GPQ.forEach)(pair.bvalue, (snb) => {
|
|
8248
8255
|
if (sna === snb || superA && superA.has(snb)) {
|
|
8249
8256
|
common.push(sna);
|
|
8250
8257
|
}
|
|
@@ -8490,7 +8497,7 @@ function restrictExactTypesByEquality(a, b) {
|
|
|
8490
8497
|
}
|
|
8491
8498
|
case 262144:
|
|
8492
8499
|
return restrictByEquality(
|
|
8493
|
-
(0,
|
|
8500
|
+
(0, import_chunk_67LU4GPQ.reduce)(
|
|
8494
8501
|
a.value,
|
|
8495
8502
|
(cur, decl) => {
|
|
8496
8503
|
unionInto(cur, decl.resolvedType);
|
|
@@ -8557,7 +8564,7 @@ var init_intersection_type = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
8557
8564
|
"use strict";
|
|
8558
8565
|
init_api();
|
|
8559
8566
|
init_data_flow();
|
|
8560
|
-
(0,
|
|
8567
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
8561
8568
|
init_could_be();
|
|
8562
8569
|
init_interp();
|
|
8563
8570
|
init_types();
|
|
@@ -8671,14 +8678,14 @@ function subtypeOfValue(pair) {
|
|
|
8671
8678
|
case 8192: {
|
|
8672
8679
|
const asd = pair.avalue;
|
|
8673
8680
|
const bsd = pair.bvalue;
|
|
8674
|
-
return (0,
|
|
8681
|
+
return (0, import_chunk_67LU4GPQ.some)(asd, (sna) => (0, import_chunk_67LU4GPQ.some)(bsd, (snb) => sna === snb));
|
|
8675
8682
|
}
|
|
8676
8683
|
case 16384: {
|
|
8677
8684
|
const asd = pair.avalue;
|
|
8678
8685
|
const bsd = pair.bvalue;
|
|
8679
|
-
return (0,
|
|
8686
|
+
return (0, import_chunk_67LU4GPQ.every)(asd, (sna) => {
|
|
8680
8687
|
const superA = getSuperClasses(sna);
|
|
8681
|
-
return (0,
|
|
8688
|
+
return (0, import_chunk_67LU4GPQ.some)(bsd, (snb) => {
|
|
8682
8689
|
if (sna === snb || superA && superA.has(snb)) {
|
|
8683
8690
|
return true;
|
|
8684
8691
|
}
|
|
@@ -8714,7 +8721,7 @@ var init_sub_type = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
8714
8721
|
"use strict";
|
|
8715
8722
|
init_api();
|
|
8716
8723
|
init_data_flow();
|
|
8717
|
-
(0,
|
|
8724
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
8718
8725
|
init_could_be();
|
|
8719
8726
|
init_intersection_type();
|
|
8720
8727
|
init_types();
|
|
@@ -9135,13 +9142,13 @@ function isTypeStateKey(decl) {
|
|
|
9135
9142
|
return Array.isArray(decl) || decl.type !== "MemberDecl" && decl.type !== "Unknown";
|
|
9136
9143
|
}
|
|
9137
9144
|
function declIsLocal(decl) {
|
|
9138
|
-
return (0,
|
|
9145
|
+
return (0, import_chunk_67LU4GPQ.some)(
|
|
9139
9146
|
decl,
|
|
9140
9147
|
(d) => d.type === "BinaryExpression" || d.type === "Identifier" || d.type === "VariableDeclarator" && isLocal(d)
|
|
9141
9148
|
);
|
|
9142
9149
|
}
|
|
9143
9150
|
function declIsNonLocal(decl) {
|
|
9144
|
-
return (0,
|
|
9151
|
+
return (0, import_chunk_67LU4GPQ.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d));
|
|
9145
9152
|
}
|
|
9146
9153
|
function localDeclName(decl) {
|
|
9147
9154
|
if (Array.isArray(decl))
|
|
@@ -9154,12 +9161,12 @@ function localDeclName(decl) {
|
|
|
9154
9161
|
case "VariableDeclarator":
|
|
9155
9162
|
return variableDeclarationName(decl.node.id);
|
|
9156
9163
|
}
|
|
9157
|
-
throw new
|
|
9164
|
+
throw new import_chunk_67LU4GPQ.AwaitedError(
|
|
9158
9165
|
declFullName(decl).then((declStr) => `Invalid local decl: ${declStr}`)
|
|
9159
9166
|
);
|
|
9160
9167
|
}
|
|
9161
9168
|
function tsKey(key) {
|
|
9162
|
-
return `${(0,
|
|
9169
|
+
return `${(0, import_chunk_67LU4GPQ.map)(key, (k) => {
|
|
9163
9170
|
if (k.type === "Literal") {
|
|
9164
9171
|
return k.raw;
|
|
9165
9172
|
} else if (isStateNode(k)) {
|
|
@@ -9178,7 +9185,7 @@ function sourceLocation(loc) {
|
|
|
9178
9185
|
return loc ? `${loc.source || "??"}:${loc.start.line}:${loc.start.column}` : "??";
|
|
9179
9186
|
}
|
|
9180
9187
|
function printBlockHeader(block) {
|
|
9181
|
-
(0,
|
|
9188
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
9182
9189
|
block.order,
|
|
9183
9190
|
`(${block.node?.loc?.source || "??"}:${block.node?.loc?.start.line || "??"})`,
|
|
9184
9191
|
`Preds: ${(block.preds || []).map((block2) => block2.order).join(", ")}`
|
|
@@ -9192,10 +9199,10 @@ function describeEvent(event) {
|
|
|
9192
9199
|
).then((desc) => `${event.type}: ${desc}`);
|
|
9193
9200
|
}
|
|
9194
9201
|
function printBlockEvents(block, extra) {
|
|
9195
|
-
(0,
|
|
9196
|
-
(0,
|
|
9202
|
+
(0, import_chunk_67LU4GPQ.log)("Events:");
|
|
9203
|
+
(0, import_chunk_67LU4GPQ.forEach)(
|
|
9197
9204
|
block.events,
|
|
9198
|
-
(event) => (0,
|
|
9205
|
+
(event) => (0, import_chunk_67LU4GPQ.log)(
|
|
9199
9206
|
describeEvent(event).then(
|
|
9200
9207
|
(eventStr) => ` ${eventStr} ${extra ? extra(event) : ""}`
|
|
9201
9208
|
)
|
|
@@ -9203,7 +9210,7 @@ function printBlockEvents(block, extra) {
|
|
|
9203
9210
|
);
|
|
9204
9211
|
}
|
|
9205
9212
|
function printBlockTrailer(block) {
|
|
9206
|
-
(0,
|
|
9213
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
9207
9214
|
`Succs: ${(block.succs || []).map((block2) => block2.order).join(", ")} ExSucc: ${block.exsucc ? block.exsucc.order : ""}`
|
|
9208
9215
|
);
|
|
9209
9216
|
}
|
|
@@ -9335,7 +9342,7 @@ var init_type_flow_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
9335
9342
|
"use strict";
|
|
9336
9343
|
init_api();
|
|
9337
9344
|
init_data_flow();
|
|
9338
|
-
(0,
|
|
9345
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
9339
9346
|
init_intersection_type();
|
|
9340
9347
|
init_sub_type();
|
|
9341
9348
|
init_types();
|
|
@@ -9389,7 +9396,7 @@ function calleeObjectType(istate, callee) {
|
|
|
9389
9396
|
}
|
|
9390
9397
|
function checkCallArgs(istate, node, callees, args) {
|
|
9391
9398
|
const allDiags = [];
|
|
9392
|
-
const resultType = (0,
|
|
9399
|
+
const resultType = (0, import_chunk_67LU4GPQ.reduce)(
|
|
9393
9400
|
callees,
|
|
9394
9401
|
(result, cur) => {
|
|
9395
9402
|
const curDiags = [];
|
|
@@ -9548,7 +9555,7 @@ function isOverride(cur, funcs) {
|
|
|
9548
9555
|
const cls = cur.stack?.[cur.stack.length - 1]?.sn;
|
|
9549
9556
|
if (cls?.type === "ClassDeclaration" && cls.superClasses) {
|
|
9550
9557
|
const supers = getSuperClasses(cls);
|
|
9551
|
-
if (supers && (0,
|
|
9558
|
+
if (supers && (0, import_chunk_67LU4GPQ.some)(funcs, (func) => {
|
|
9552
9559
|
if (func === cur)
|
|
9553
9560
|
return false;
|
|
9554
9561
|
const fcls = func.stack?.[func.stack.length - 1].sn;
|
|
@@ -9606,8 +9613,16 @@ function getSystemCallTable(state) {
|
|
|
9606
9613
|
512
|
|
9607
9614
|
/* Array */
|
|
9608
9615
|
);
|
|
9609
|
-
if (argSubtypes
|
|
9610
|
-
|
|
9616
|
+
if (argSubtypes) {
|
|
9617
|
+
if (Array.isArray(argSubtypes)) {
|
|
9618
|
+
const newAData2 = [...adata, ...argSubtypes];
|
|
9619
|
+
ret.returnType.value = newAData2;
|
|
9620
|
+
ret.argTypes = [arg];
|
|
9621
|
+
ret.calleeObj = ret.returnType;
|
|
9622
|
+
return ret;
|
|
9623
|
+
}
|
|
9624
|
+
const newAData = reducedType(adata);
|
|
9625
|
+
unionInto(newAData, argSubtypes);
|
|
9611
9626
|
ret.returnType.value = newAData;
|
|
9612
9627
|
ret.argTypes = [arg];
|
|
9613
9628
|
ret.calleeObj = ret.returnType;
|
|
@@ -10034,7 +10049,7 @@ var init_interp_call = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
10034
10049
|
"use strict";
|
|
10035
10050
|
init_optimizer_types();
|
|
10036
10051
|
init_api();
|
|
10037
|
-
(0,
|
|
10052
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
10038
10053
|
init_interp();
|
|
10039
10054
|
init_sub_type();
|
|
10040
10055
|
init_types();
|
|
@@ -11159,7 +11174,7 @@ function mustBeIdentical(a, b) {
|
|
|
11159
11174
|
return false;
|
|
11160
11175
|
}
|
|
11161
11176
|
function isByteArrayData(objectData) {
|
|
11162
|
-
return objectData.klass.value && (0,
|
|
11177
|
+
return objectData.klass.value && (0, import_chunk_67LU4GPQ.every)(
|
|
11163
11178
|
objectData.klass.value,
|
|
11164
11179
|
(klass) => klass.fullName === "$.Toybox.Lang.ByteArray"
|
|
11165
11180
|
);
|
|
@@ -11171,7 +11186,7 @@ var init_interp = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
11171
11186
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
11172
11187
|
init_data_flow();
|
|
11173
11188
|
init_optimizer_types();
|
|
11174
|
-
(0,
|
|
11189
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
11175
11190
|
init_could_be();
|
|
11176
11191
|
init_interp_binary();
|
|
11177
11192
|
init_interp_call();
|
|
@@ -11402,7 +11417,7 @@ function typeFromTypeStateNode(state, sn, classVsObj) {
|
|
|
11402
11417
|
);
|
|
11403
11418
|
if (value2) {
|
|
11404
11419
|
const a = [];
|
|
11405
|
-
(0,
|
|
11420
|
+
(0, import_chunk_67LU4GPQ.forEach)(value2, (v) => {
|
|
11406
11421
|
if (v !== sn)
|
|
11407
11422
|
a.push(v);
|
|
11408
11423
|
});
|
|
@@ -11569,7 +11584,7 @@ function typeFromSingleTypeSpec(state, type, stack) {
|
|
|
11569
11584
|
return {
|
|
11570
11585
|
type: 512,
|
|
11571
11586
|
value: type.elements.map(
|
|
11572
|
-
(cur) => typeFromTypespec(state, cur)
|
|
11587
|
+
(cur) => typeFromTypespec(state, cur, stack)
|
|
11573
11588
|
)
|
|
11574
11589
|
};
|
|
11575
11590
|
}
|
|
@@ -11579,7 +11594,7 @@ function typeFromSingleTypeSpec(state, type, stack) {
|
|
|
11579
11594
|
const prop = property;
|
|
11580
11595
|
fields.set(
|
|
11581
11596
|
objectLiteralKeyFromKeyExpr(prop.left),
|
|
11582
|
-
typeFromTypespec(state, prop.right)
|
|
11597
|
+
typeFromTypespec(state, prop.right, stack)
|
|
11583
11598
|
);
|
|
11584
11599
|
});
|
|
11585
11600
|
return { type: 1024, value: fields };
|
|
@@ -11894,7 +11909,7 @@ function mustBeFalse(arg) {
|
|
|
11894
11909
|
return arg.type === 1 || arg.type === 2 || (arg.type === 8 || arg.type === 16) && arg.value != null && Number(arg.value) === 0;
|
|
11895
11910
|
}
|
|
11896
11911
|
function display(type) {
|
|
11897
|
-
const names = (v, fn) => (0,
|
|
11912
|
+
const names = (v, fn) => (0, import_chunk_67LU4GPQ.map)(v, fn).sort().filter((s, i, arr) => !i || s !== arr[i - 1]).join(" or ");
|
|
11898
11913
|
const parts = [];
|
|
11899
11914
|
const displayOne = (tv) => {
|
|
11900
11915
|
switch (tv.type) {
|
|
@@ -12095,7 +12110,7 @@ var init_types = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
12095
12110
|
init_data_flow();
|
|
12096
12111
|
init_api();
|
|
12097
12112
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
12098
|
-
(0,
|
|
12113
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
12099
12114
|
init_interp();
|
|
12100
12115
|
init_union_type();
|
|
12101
12116
|
init_intersection_type();
|
|
@@ -12155,7 +12170,7 @@ function couldBeHelper(a, b, shallow) {
|
|
|
12155
12170
|
262144
|
|
12156
12171
|
/* Typedef */
|
|
12157
12172
|
);
|
|
12158
|
-
return typedef && (0,
|
|
12173
|
+
return typedef && (0, import_chunk_67LU4GPQ.some)(typedef, (td) => {
|
|
12159
12174
|
if (!td.resolvedType) {
|
|
12160
12175
|
throw new Error(`No resolved type for ${td.fullName} in 'couldBe'`);
|
|
12161
12176
|
}
|
|
@@ -12227,15 +12242,15 @@ function couldBeValue(pair, shallow) {
|
|
|
12227
12242
|
}
|
|
12228
12243
|
case 4096:
|
|
12229
12244
|
case 8192: {
|
|
12230
|
-
return (0,
|
|
12245
|
+
return (0, import_chunk_67LU4GPQ.some)(
|
|
12231
12246
|
pair.avalue,
|
|
12232
|
-
(sna) => (0,
|
|
12247
|
+
(sna) => (0, import_chunk_67LU4GPQ.some)(pair.bvalue, (snb) => sna === snb)
|
|
12233
12248
|
);
|
|
12234
12249
|
}
|
|
12235
12250
|
case 16384: {
|
|
12236
|
-
return (0,
|
|
12251
|
+
return (0, import_chunk_67LU4GPQ.some)(pair.avalue, (sna) => {
|
|
12237
12252
|
const superA = getSuperClasses(sna);
|
|
12238
|
-
return (0,
|
|
12253
|
+
return (0, import_chunk_67LU4GPQ.some)(pair.bvalue, (snb) => {
|
|
12239
12254
|
if (sna === snb || superA && superA.has(snb)) {
|
|
12240
12255
|
return true;
|
|
12241
12256
|
}
|
|
@@ -12268,7 +12283,7 @@ var init_could_be = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
12268
12283
|
"use strict";
|
|
12269
12284
|
init_api();
|
|
12270
12285
|
init_data_flow();
|
|
12271
|
-
(0,
|
|
12286
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
12272
12287
|
init_types();
|
|
12273
12288
|
}
|
|
12274
12289
|
});
|
|
@@ -12375,7 +12390,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12375
12390
|
}
|
|
12376
12391
|
addAnt(curState.partiallyAnticipated, key, node);
|
|
12377
12392
|
if (logThisRun) {
|
|
12378
|
-
(0,
|
|
12393
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
12379
12394
|
` antrefs: ${curState.partiallyAnticipated.get(key) !== false} ${curState.anticipated.get(key) !== false}`
|
|
12380
12395
|
);
|
|
12381
12396
|
}
|
|
@@ -12398,7 +12413,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12398
12413
|
const curState = cloneState(blockStates[top.order]);
|
|
12399
12414
|
if (logThisRun) {
|
|
12400
12415
|
printBlockHeader(top);
|
|
12401
|
-
curState.dead.forEach((decl) => (0,
|
|
12416
|
+
curState.dead.forEach((decl) => (0, import_chunk_67LU4GPQ.log)(` - anticipated: ${tsKey(decl)}`));
|
|
12402
12417
|
}
|
|
12403
12418
|
if (top.events) {
|
|
12404
12419
|
for (let i = top.events.length; i--; ) {
|
|
@@ -12410,12 +12425,12 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12410
12425
|
case "ref":
|
|
12411
12426
|
if (isTypeStateKey(event.decl)) {
|
|
12412
12427
|
if (logThisRun) {
|
|
12413
|
-
(0,
|
|
12428
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
12414
12429
|
describeEvent(event).then(
|
|
12415
12430
|
(eventStr) => `${eventStr} (${sourceLocation(event.node.loc)})`
|
|
12416
12431
|
)
|
|
12417
12432
|
);
|
|
12418
|
-
(0,
|
|
12433
|
+
(0, import_chunk_67LU4GPQ.log)(` kill => ${tsKey(event.decl)}`);
|
|
12419
12434
|
}
|
|
12420
12435
|
copyPropRef(curState, event.decl, event.node);
|
|
12421
12436
|
curState.dead.delete(event.decl);
|
|
@@ -12424,7 +12439,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12424
12439
|
case "def":
|
|
12425
12440
|
if (isTypeStateKey(event.decl) && (event.node.type !== "VariableDeclarator" || event.node.init)) {
|
|
12426
12441
|
if (logThisRun) {
|
|
12427
|
-
(0,
|
|
12442
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
12428
12443
|
describeEvent(event).then(
|
|
12429
12444
|
(eventStr) => `${eventStr} (${sourceLocation(event.node.loc)})`
|
|
12430
12445
|
)
|
|
@@ -12440,7 +12455,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12440
12455
|
const pant = curState.partiallyAnticipated.get(event.decl);
|
|
12441
12456
|
if (pant) {
|
|
12442
12457
|
if (logThisRun) {
|
|
12443
|
-
(0,
|
|
12458
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
12444
12459
|
` is copy-prop-candidate ${curState.anticipated?.get(event.decl) === pant}`
|
|
12445
12460
|
);
|
|
12446
12461
|
}
|
|
@@ -12472,7 +12487,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12472
12487
|
if (assignNode) {
|
|
12473
12488
|
curState.dead.add(event.decl);
|
|
12474
12489
|
if (logThisRun) {
|
|
12475
|
-
(0,
|
|
12490
|
+
(0, import_chunk_67LU4GPQ.log)(` anticipated => ${tsKey(event.decl)}`);
|
|
12476
12491
|
}
|
|
12477
12492
|
} else if (event.node.type === "UpdateExpression") {
|
|
12478
12493
|
copyPropRef(curState, event.decl, event.node.argument);
|
|
@@ -12483,7 +12498,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12483
12498
|
if (isTypeStateKey(event.decl)) {
|
|
12484
12499
|
curState.dead.add(event.decl);
|
|
12485
12500
|
if (logThisRun) {
|
|
12486
|
-
(0,
|
|
12501
|
+
(0, import_chunk_67LU4GPQ.log)(` anticipated => ${tsKey(event.decl)}`);
|
|
12487
12502
|
}
|
|
12488
12503
|
}
|
|
12489
12504
|
break;
|
|
@@ -12546,9 +12561,9 @@ function eliminateDeadStores(state, func, graph, logThisRun) {
|
|
|
12546
12561
|
if (!deadStores.size)
|
|
12547
12562
|
return { changes: false, copyPropStores };
|
|
12548
12563
|
if (logThisRun) {
|
|
12549
|
-
(0,
|
|
12564
|
+
(0, import_chunk_67LU4GPQ.log)("====== Dead Stores =====");
|
|
12550
12565
|
deadStores.forEach(
|
|
12551
|
-
(dead) => (dead.type === "AssignmentExpression" || dead.type === "UpdateExpression" || dead.type === "VariableDeclarator") && (0,
|
|
12566
|
+
(dead) => (dead.type === "AssignmentExpression" || dead.type === "UpdateExpression" || dead.type === "VariableDeclarator") && (0, import_chunk_67LU4GPQ.log)(
|
|
12552
12567
|
formatAst(dead).then(
|
|
12553
12568
|
(deadStr) => `${deadStr} (${sourceLocation(dead.loc)})`
|
|
12554
12569
|
)
|
|
@@ -12603,7 +12618,7 @@ var init_dead_store = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
12603
12618
|
init_control_flow();
|
|
12604
12619
|
init_data_flow();
|
|
12605
12620
|
init_inliner();
|
|
12606
|
-
(0,
|
|
12621
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
12607
12622
|
init_minimize_locals();
|
|
12608
12623
|
init_type_flow_util();
|
|
12609
12624
|
}
|
|
@@ -12968,13 +12983,13 @@ function typeStateEntry(value2, key) {
|
|
|
12968
12983
|
return `${tsKey(key)} = ${display(value2.curType)}`;
|
|
12969
12984
|
}
|
|
12970
12985
|
function printBlockState(block, state, indent = "") {
|
|
12971
|
-
(0,
|
|
12986
|
+
(0, import_chunk_67LU4GPQ.log)(indent + "State:");
|
|
12972
12987
|
if (!state) {
|
|
12973
|
-
(0,
|
|
12988
|
+
(0, import_chunk_67LU4GPQ.log)(indent + "Not visited!");
|
|
12974
12989
|
return;
|
|
12975
12990
|
}
|
|
12976
12991
|
state.map.forEach((value2, key) => {
|
|
12977
|
-
(0,
|
|
12992
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
12978
12993
|
`${indent} - ${typeStateEntry(value2, key)}${value2.equivSet ? ` [(${Array.from(value2.equivSet).map(tsKey).join(", ")})]` : ""}`
|
|
12979
12994
|
);
|
|
12980
12995
|
});
|
|
@@ -13181,7 +13196,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13181
13196
|
type: 0
|
|
13182
13197
|
/* Never */
|
|
13183
13198
|
};
|
|
13184
|
-
(0,
|
|
13199
|
+
(0, import_chunk_67LU4GPQ.forEach)(avalue, (v) => unionInto(n, v));
|
|
13185
13200
|
next = n;
|
|
13186
13201
|
}
|
|
13187
13202
|
} else {
|
|
@@ -13286,7 +13301,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13286
13301
|
}
|
|
13287
13302
|
if (!isStatic && selfClassDecl) {
|
|
13288
13303
|
const baseObj = getObjectValue(baseElem.type);
|
|
13289
|
-
if (baseObj && baseObj.klass.type === 16384 && (0,
|
|
13304
|
+
if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_67LU4GPQ.some)(
|
|
13290
13305
|
baseObj.klass.value,
|
|
13291
13306
|
(cls) => cls === selfClassDecl || getSuperClasses(cls)?.has(selfClassDecl) || getSuperClasses(selfClassDecl)?.has(cls) || false
|
|
13292
13307
|
)) {
|
|
@@ -13331,7 +13346,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13331
13346
|
return [cur, updateAny];
|
|
13332
13347
|
}
|
|
13333
13348
|
function typeConstraint(decls, blockState) {
|
|
13334
|
-
return (0,
|
|
13349
|
+
return (0, import_chunk_67LU4GPQ.reduce)(
|
|
13335
13350
|
decls,
|
|
13336
13351
|
(cur, decl) => {
|
|
13337
13352
|
if (decl.type === "Identifier" || decl.type === "BinaryExpression") {
|
|
@@ -13427,9 +13442,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13427
13442
|
stack: [],
|
|
13428
13443
|
func
|
|
13429
13444
|
};
|
|
13430
|
-
const modifiableDecl = (decls, callees) => (0,
|
|
13445
|
+
const modifiableDecl = (decls, callees) => (0, import_chunk_67LU4GPQ.some)(
|
|
13431
13446
|
decls,
|
|
13432
|
-
(decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0,
|
|
13447
|
+
(decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0, import_chunk_67LU4GPQ.some)(callees, (callee) => functionMayModify(state, callee, decl)))
|
|
13433
13448
|
);
|
|
13434
13449
|
const mergeSuccState = (top, curState) => {
|
|
13435
13450
|
top.succs?.forEach((succ) => {
|
|
@@ -13438,7 +13453,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13438
13453
|
}
|
|
13439
13454
|
if (mergeTypeState(blockStates, succ.order, curState, nodeCopyProp)) {
|
|
13440
13455
|
if (logThisRun) {
|
|
13441
|
-
(0,
|
|
13456
|
+
(0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${succ.order}`);
|
|
13442
13457
|
}
|
|
13443
13458
|
queue.enqueue(succ);
|
|
13444
13459
|
}
|
|
@@ -13448,7 +13463,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13448
13463
|
const calleeObj = getStateType(curState, calleeObjDecl);
|
|
13449
13464
|
let calleeResult = null;
|
|
13450
13465
|
let effectFree = true;
|
|
13451
|
-
(0,
|
|
13466
|
+
(0, import_chunk_67LU4GPQ.forEach)(callees, (callee) => {
|
|
13452
13467
|
const info = sysCallInfo(istate.state, callee);
|
|
13453
13468
|
if (!info) {
|
|
13454
13469
|
effectFree = false;
|
|
@@ -13725,7 +13740,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13725
13740
|
});
|
|
13726
13741
|
} else {
|
|
13727
13742
|
if (logThisRun) {
|
|
13728
|
-
(0,
|
|
13743
|
+
(0, import_chunk_67LU4GPQ.log)(` Flow (true): merge to ${trueSucc.order || -1}`);
|
|
13729
13744
|
printBlockState(top, sTrue || curState, " >true ");
|
|
13730
13745
|
}
|
|
13731
13746
|
if (mergeTypeState(
|
|
@@ -13735,7 +13750,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13735
13750
|
nodeCopyProp
|
|
13736
13751
|
)) {
|
|
13737
13752
|
if (logThisRun) {
|
|
13738
|
-
(0,
|
|
13753
|
+
(0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${trueSucc.order}`);
|
|
13739
13754
|
}
|
|
13740
13755
|
queue.enqueue(trueSucc);
|
|
13741
13756
|
}
|
|
@@ -13747,7 +13762,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13747
13762
|
});
|
|
13748
13763
|
} else {
|
|
13749
13764
|
if (logThisRun) {
|
|
13750
|
-
(0,
|
|
13765
|
+
(0, import_chunk_67LU4GPQ.log)(` Flow (false): merge to: ${falseSucc.order || -1}`);
|
|
13751
13766
|
printBlockState(top, sFalse || curState, " >false ");
|
|
13752
13767
|
}
|
|
13753
13768
|
if (mergeTypeState(
|
|
@@ -13757,7 +13772,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13757
13772
|
nodeCopyProp
|
|
13758
13773
|
)) {
|
|
13759
13774
|
if (logThisRun) {
|
|
13760
|
-
(0,
|
|
13775
|
+
(0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${falseSucc.order}`);
|
|
13761
13776
|
}
|
|
13762
13777
|
queue.enqueue(falseSucc);
|
|
13763
13778
|
}
|
|
@@ -13832,7 +13847,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13832
13847
|
}
|
|
13833
13848
|
}
|
|
13834
13849
|
if (logThisRun) {
|
|
13835
|
-
(0,
|
|
13850
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
13836
13851
|
describeEvent(event).then(
|
|
13837
13852
|
(eventStr) => ` ${eventStr} == ${display(curEntry.curType)}`
|
|
13838
13853
|
)
|
|
@@ -13842,7 +13857,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13842
13857
|
}
|
|
13843
13858
|
case "mod": {
|
|
13844
13859
|
if (logThisRun) {
|
|
13845
|
-
(0,
|
|
13860
|
+
(0, import_chunk_67LU4GPQ.log)(describeEvent(event).then((eventStr) => ` ${eventStr}`));
|
|
13846
13861
|
}
|
|
13847
13862
|
modInterference(curState, event, true, (callees, calleeObj) => {
|
|
13848
13863
|
clearRelatedCopyPropEvents(curState, null, nodeCopyProp);
|
|
@@ -13858,7 +13873,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13858
13873
|
);
|
|
13859
13874
|
}
|
|
13860
13875
|
}
|
|
13861
|
-
if (nodeCopyProp.size && event.node.type === "CallExpression" && (0,
|
|
13876
|
+
if (nodeCopyProp.size && event.node.type === "CallExpression" && (0, import_chunk_67LU4GPQ.some)(callees, (callee) => inlineRequested(state, callee))) {
|
|
13862
13877
|
event.node.arguments.forEach((arg) => {
|
|
13863
13878
|
const def = nodeCopyProp.get(arg);
|
|
13864
13879
|
if (def && nodeCopyProp.get(def) !== false) {
|
|
@@ -13870,7 +13885,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13870
13885
|
let calleeEffects;
|
|
13871
13886
|
curState.map.forEach((tsv, decl) => {
|
|
13872
13887
|
let type = tsv.curType;
|
|
13873
|
-
if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0,
|
|
13888
|
+
if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0, import_chunk_67LU4GPQ.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d))) {
|
|
13874
13889
|
return;
|
|
13875
13890
|
}
|
|
13876
13891
|
if (modifiableDecl(decl, callees)) {
|
|
@@ -13885,7 +13900,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13885
13900
|
curState.map.set(decl, {
|
|
13886
13901
|
curType: typeConstraint(decl, curState)
|
|
13887
13902
|
});
|
|
13888
|
-
} else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0,
|
|
13903
|
+
} else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0, import_chunk_67LU4GPQ.every)(callees, (callee) => callee.info === false) : calleeEffects)) {
|
|
13889
13904
|
if (type.value != null && type.type & 32768) {
|
|
13890
13905
|
const odata = getObjectValue(tsv.curType);
|
|
13891
13906
|
if (odata?.obj) {
|
|
@@ -13953,7 +13968,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13953
13968
|
2
|
|
13954
13969
|
/* Reassign */
|
|
13955
13970
|
);
|
|
13956
|
-
(0,
|
|
13971
|
+
(0, import_chunk_67LU4GPQ.some)(event.decl, (decl) => {
|
|
13957
13972
|
if (decl.type !== "VariableDeclarator" || decl.node.kind !== "var" || !isClassVariable(decl)) {
|
|
13958
13973
|
return false;
|
|
13959
13974
|
}
|
|
@@ -13961,7 +13976,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13961
13976
|
if (affected) {
|
|
13962
13977
|
const objType = typeFromTypeStateNodes(
|
|
13963
13978
|
istate.state,
|
|
13964
|
-
(0,
|
|
13979
|
+
(0, import_chunk_67LU4GPQ.map)(
|
|
13965
13980
|
event.decl,
|
|
13966
13981
|
(decl2) => decl2.type === "VariableDeclarator" && decl2.stack[decl2.stack.length - 1].sn
|
|
13967
13982
|
).filter(
|
|
@@ -13982,7 +13997,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13982
13997
|
});
|
|
13983
13998
|
if (wasComputedDecl) {
|
|
13984
13999
|
curState.map.forEach((value2, decls) => {
|
|
13985
|
-
if ((0,
|
|
14000
|
+
if ((0, import_chunk_67LU4GPQ.some)(
|
|
13986
14001
|
decls,
|
|
13987
14002
|
(decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl)
|
|
13988
14003
|
)) {
|
|
@@ -14028,14 +14043,14 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14028
14043
|
}
|
|
14029
14044
|
if (!copyPropCandidate.ant || // If the ref isn't anticipated, we can't propagate it
|
|
14030
14045
|
// in case it has side effects.
|
|
14031
|
-
(0,
|
|
14046
|
+
(0, import_chunk_67LU4GPQ.some)(
|
|
14032
14047
|
event2.calleeDecl,
|
|
14033
14048
|
(callee) => callee.type === "FunctionDeclaration" && inlineRequested(state, callee)
|
|
14034
14049
|
)) {
|
|
14035
14050
|
return false;
|
|
14036
14051
|
}
|
|
14037
14052
|
}
|
|
14038
|
-
if (!event2.decl || isTypeStateKey(event2.decl) && (0,
|
|
14053
|
+
if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_67LU4GPQ.some)(
|
|
14039
14054
|
event2.decl,
|
|
14040
14055
|
(decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" || decl.type === "BinaryExpression" || decl.type === "Identifier"
|
|
14041
14056
|
)) {
|
|
@@ -14074,13 +14089,13 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14074
14089
|
}
|
|
14075
14090
|
}
|
|
14076
14091
|
if (uninitClassDecls?.size) {
|
|
14077
|
-
(0,
|
|
14092
|
+
(0, import_chunk_67LU4GPQ.forEach)(
|
|
14078
14093
|
event.decl,
|
|
14079
14094
|
(decl) => uninitClassDecls.has(decl) && curState.inited?.add(decl)
|
|
14080
14095
|
);
|
|
14081
14096
|
}
|
|
14082
14097
|
if (logThisRun) {
|
|
14083
|
-
(0,
|
|
14098
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14084
14099
|
describeEvent(event).then(
|
|
14085
14100
|
(eventStr) => ` ${eventStr} := ${display(type)}`
|
|
14086
14101
|
)
|
|
@@ -14098,7 +14113,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14098
14113
|
);
|
|
14099
14114
|
}
|
|
14100
14115
|
if (logThisRun) {
|
|
14101
|
-
(0,
|
|
14116
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14102
14117
|
describeEvent(event).then(
|
|
14103
14118
|
(eventStr) => ` ${eventStr} : ${!Array.isArray(event.left) && event.left.type === "MemberDecl" ? `${display(
|
|
14104
14119
|
curState.map.get(event.left.base)?.curType || {
|
|
@@ -14156,8 +14171,8 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14156
14171
|
}
|
|
14157
14172
|
if (!successorsHandled) {
|
|
14158
14173
|
if (logThisRun) {
|
|
14159
|
-
(0,
|
|
14160
|
-
` merge to: ${(0,
|
|
14174
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14175
|
+
` merge to: ${(0, import_chunk_67LU4GPQ.map)(
|
|
14161
14176
|
top.succs,
|
|
14162
14177
|
(succ) => succ.order || -1
|
|
14163
14178
|
).join(", ")}`
|
|
@@ -14188,17 +14203,17 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14188
14203
|
);
|
|
14189
14204
|
printBlockTrailer(block);
|
|
14190
14205
|
});
|
|
14191
|
-
(0,
|
|
14206
|
+
(0, import_chunk_67LU4GPQ.log)("====== TypeMap =====");
|
|
14192
14207
|
typeMap.forEach((value2, key) => {
|
|
14193
|
-
(0,
|
|
14208
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14194
14209
|
formatAst(key).then(
|
|
14195
14210
|
(keyStr) => `${keyStr} = ${display(value2)} ${key.loc && key.loc.source ? ` (${sourceLocation(key.loc)})` : ""}`
|
|
14196
14211
|
)
|
|
14197
14212
|
);
|
|
14198
14213
|
});
|
|
14199
|
-
(0,
|
|
14214
|
+
(0, import_chunk_67LU4GPQ.log)("====== EquivMap =====");
|
|
14200
14215
|
nodeEquivs.forEach((value2, key) => {
|
|
14201
|
-
(0,
|
|
14216
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14202
14217
|
formatAst(key).then(
|
|
14203
14218
|
(keyStr) => `${keyStr} = [${value2.equiv.map(
|
|
14204
14219
|
(equiv) => tsKey(equiv)
|
|
@@ -14206,7 +14221,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14206
14221
|
)
|
|
14207
14222
|
);
|
|
14208
14223
|
});
|
|
14209
|
-
(0,
|
|
14224
|
+
(0, import_chunk_67LU4GPQ.log)("====== Copy Prop =====");
|
|
14210
14225
|
nodeCopyProp.forEach((value2, key) => {
|
|
14211
14226
|
(0, import_node_assert3.default)(value2 !== false);
|
|
14212
14227
|
if (key.type === "VariableDeclarator" || key.type === "AssignmentExpression") {
|
|
@@ -14216,7 +14231,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14216
14231
|
value2.type === "VariableDeclarator" && value2.init || value2.type === "AssignmentExpression"
|
|
14217
14232
|
);
|
|
14218
14233
|
const node = value2.type === "VariableDeclarator" ? value2.init : value2.right;
|
|
14219
|
-
(0,
|
|
14234
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14220
14235
|
formatAst(key).then(
|
|
14221
14236
|
(keyStr) => formatAstLongLines(node).then(
|
|
14222
14237
|
(nodeStr) => `${keyStr} = [${nodeStr}] ${key.loc && key.loc.source ? ` (${sourceLocation(key.loc)})` : ""}`
|
|
@@ -14226,10 +14241,10 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14226
14241
|
});
|
|
14227
14242
|
}
|
|
14228
14243
|
if (logThisRun) {
|
|
14229
|
-
(0,
|
|
14244
|
+
(0, import_chunk_67LU4GPQ.log)(formatAstLongLines(func.node));
|
|
14230
14245
|
if (copyPropStores) {
|
|
14231
14246
|
copyPropStores.forEach(({ ref, ant }, node) => {
|
|
14232
|
-
(0,
|
|
14247
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14233
14248
|
formatAstLongLines(node).then(
|
|
14234
14249
|
(nodeStr) => `copy-prop-store: ${nodeStr}${ant ? "!" : ""} => ${nodeCopyProp.get(node) !== ref ? "Failed" : "Success"}`
|
|
14235
14250
|
)
|
|
@@ -14243,9 +14258,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14243
14258
|
}
|
|
14244
14259
|
if (logThisRun) {
|
|
14245
14260
|
if (selfAssignments.size) {
|
|
14246
|
-
(0,
|
|
14261
|
+
(0, import_chunk_67LU4GPQ.log)("====== Self Assignments =====");
|
|
14247
14262
|
selfAssignments.forEach(
|
|
14248
|
-
(self) => (0,
|
|
14263
|
+
(self) => (0, import_chunk_67LU4GPQ.log)(
|
|
14249
14264
|
formatAst(self).then(
|
|
14250
14265
|
(selfStr) => `${selfStr} (${sourceLocation(self.loc)})`
|
|
14251
14266
|
)
|
|
@@ -14310,7 +14325,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14310
14325
|
if (copyNode) {
|
|
14311
14326
|
if (node.type === "AssignmentExpression") {
|
|
14312
14327
|
if (logThisRun) {
|
|
14313
|
-
(0,
|
|
14328
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14314
14329
|
formatAstLongLines(node).then(
|
|
14315
14330
|
(nodeStr) => `Killing copy-prop assignment ${nodeStr}`
|
|
14316
14331
|
)
|
|
@@ -14325,7 +14340,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14325
14340
|
if (node.type === "VariableDeclarator") {
|
|
14326
14341
|
(0, import_node_assert3.default)(node.init);
|
|
14327
14342
|
if (logThisRun) {
|
|
14328
|
-
(0,
|
|
14343
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14329
14344
|
formatAstLongLines(node).then(
|
|
14330
14345
|
(nodeStr) => `Killing copy-prop variable initialization ${nodeStr}`
|
|
14331
14346
|
)
|
|
@@ -14346,7 +14361,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14346
14361
|
right: copyNode.right
|
|
14347
14362
|
};
|
|
14348
14363
|
if (logThisRun) {
|
|
14349
|
-
(0,
|
|
14364
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14350
14365
|
formatAstLongLines(node).then(
|
|
14351
14366
|
(nodeStr) => formatAstLongLines(replacement2).then(
|
|
14352
14367
|
(repStr) => `copy-prop ${nodeStr} => ${repStr}`
|
|
@@ -14359,7 +14374,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14359
14374
|
const init = copyNode.init;
|
|
14360
14375
|
(0, import_node_assert3.default)(init);
|
|
14361
14376
|
if (logThisRun) {
|
|
14362
|
-
(0,
|
|
14377
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14363
14378
|
formatAstLongLines(node).then(
|
|
14364
14379
|
(nodeStr) => formatAstLongLines(init).then(
|
|
14365
14380
|
(initStr) => `copy-prop ${nodeStr} => ${initStr}`
|
|
@@ -14373,7 +14388,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14373
14388
|
}
|
|
14374
14389
|
if (selfAssignments.has(node)) {
|
|
14375
14390
|
if (logThisRun) {
|
|
14376
|
-
(0,
|
|
14391
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14377
14392
|
formatAst(node).then(
|
|
14378
14393
|
(nodeStr) => `Deleting self assignment: ${nodeStr} (${sourceLocation(
|
|
14379
14394
|
node.loc
|
|
@@ -14417,7 +14432,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14417
14432
|
}, curInfo);
|
|
14418
14433
|
if (rep === curInfo)
|
|
14419
14434
|
return null;
|
|
14420
|
-
const name = (0,
|
|
14435
|
+
const name = (0, import_chunk_67LU4GPQ.reduce)(
|
|
14421
14436
|
rep.decl,
|
|
14422
14437
|
(cur, decl) => decl.type === "VariableDeclarator" ? decl.name : cur,
|
|
14423
14438
|
null
|
|
@@ -14425,7 +14440,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14425
14440
|
if (!name)
|
|
14426
14441
|
return null;
|
|
14427
14442
|
if (logThisRun) {
|
|
14428
|
-
(0,
|
|
14443
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14429
14444
|
formatAst(node).then(
|
|
14430
14445
|
(nodeStr) => `Replacing ${nodeStr} with ${name} at ${sourceLocation(
|
|
14431
14446
|
node.loc
|
|
@@ -14556,7 +14571,7 @@ var init_type_flow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
14556
14571
|
init_type_flow_util();
|
|
14557
14572
|
init_types();
|
|
14558
14573
|
init_union_type();
|
|
14559
|
-
(0,
|
|
14574
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
14560
14575
|
logging = true;
|
|
14561
14576
|
missingNullWorkaround = true;
|
|
14562
14577
|
}
|
|
@@ -14608,9 +14623,9 @@ function minimizeLocals(state, func) {
|
|
|
14608
14623
|
if (!didMerge)
|
|
14609
14624
|
return;
|
|
14610
14625
|
if (logThisRun) {
|
|
14611
|
-
(0,
|
|
14626
|
+
(0, import_chunk_67LU4GPQ.log)(`>>> Merging locals in ${func.fullName}`);
|
|
14612
14627
|
merge.forEach(
|
|
14613
|
-
(merged) => merged.length > 1 && (0,
|
|
14628
|
+
(merged) => merged.length > 1 && (0, import_chunk_67LU4GPQ.log)(` - merging ${merged.map((k) => tsKey(k)).join(" | ")}`)
|
|
14614
14629
|
);
|
|
14615
14630
|
}
|
|
14616
14631
|
const remap = /* @__PURE__ */ new Map();
|
|
@@ -14880,7 +14895,7 @@ var init_minimize_locals = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
14880
14895
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
14881
14896
|
init_control_flow();
|
|
14882
14897
|
init_type_flow();
|
|
14883
|
-
(0,
|
|
14898
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
14884
14899
|
init_variable_renamer();
|
|
14885
14900
|
init_type_flow_util();
|
|
14886
14901
|
}
|
|
@@ -14891,12 +14906,12 @@ function logAntState(s, decl) {
|
|
|
14891
14906
|
defs2++;
|
|
14892
14907
|
return defs2;
|
|
14893
14908
|
}, 0);
|
|
14894
|
-
(0,
|
|
14909
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14895
14910
|
declFullName(decl).then(
|
|
14896
14911
|
(declStr) => ` - ${declStr}: ${candidateCost(s)} bytes, ${s.ant.size - defs} refs, ${defs} defs, ${s.live ? "" : "!"}live, ${s.isIsolated ? "" : "!"}isolated`
|
|
14897
14912
|
)
|
|
14898
14913
|
);
|
|
14899
|
-
(0,
|
|
14914
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
14900
14915
|
` - members: ${Array.from(s.members).map(([block, live]) => block.order + (live ? "t" : "f")).join(", ")}`
|
|
14901
14916
|
);
|
|
14902
14917
|
}
|
|
@@ -14913,7 +14928,7 @@ async function sizeBasedPRE(state, func) {
|
|
|
14913
14928
|
const candidates = computeAttributes(state, head);
|
|
14914
14929
|
if (candidates) {
|
|
14915
14930
|
if (logging2) {
|
|
14916
|
-
(0,
|
|
14931
|
+
(0, import_chunk_67LU4GPQ.log)(`Found ${candidates.size} candidates in ${func.fullName}`);
|
|
14917
14932
|
logAntDecls(candidates);
|
|
14918
14933
|
}
|
|
14919
14934
|
const nodeMap = /* @__PURE__ */ new Map();
|
|
@@ -14973,7 +14988,7 @@ function buildPREGraph(state, func) {
|
|
|
14973
14988
|
const result = buildDataFlowGraph(
|
|
14974
14989
|
state,
|
|
14975
14990
|
func,
|
|
14976
|
-
(literal) => refCost(literal) > LocalRefCost,
|
|
14991
|
+
(literal) => !state.config?.preSkipLiterals && refCost(literal) > LocalRefCost,
|
|
14977
14992
|
true,
|
|
14978
14993
|
false
|
|
14979
14994
|
);
|
|
@@ -15006,7 +15021,7 @@ function buildPREGraph(state, func) {
|
|
|
15006
15021
|
const event = block.events[i];
|
|
15007
15022
|
switch (event.type) {
|
|
15008
15023
|
case "ref":
|
|
15009
|
-
if ((0,
|
|
15024
|
+
if ((0, import_chunk_67LU4GPQ.some)(
|
|
15010
15025
|
event.decl,
|
|
15011
15026
|
(decl) => decl.type === "Literal" || decl.type === "VariableDeclarator" && decl.node.kind === "const"
|
|
15012
15027
|
)) {
|
|
@@ -15024,7 +15039,7 @@ function buildPREGraph(state, func) {
|
|
|
15024
15039
|
defs.add(event.decl);
|
|
15025
15040
|
break;
|
|
15026
15041
|
case "mod":
|
|
15027
|
-
if (event.callees && (0,
|
|
15042
|
+
if (event.callees && (0, import_chunk_67LU4GPQ.every)(event.callees, (callee) => callee.info === false)) {
|
|
15028
15043
|
block.events.splice(i, 1);
|
|
15029
15044
|
break;
|
|
15030
15045
|
}
|
|
@@ -15183,21 +15198,21 @@ function computeAttributes(state, head) {
|
|
|
15183
15198
|
});
|
|
15184
15199
|
if (logging2) {
|
|
15185
15200
|
order.forEach((block) => {
|
|
15186
|
-
(0,
|
|
15201
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
15187
15202
|
block.order,
|
|
15188
15203
|
`(${block.node ? block.node.loc?.start.line : "??"})`,
|
|
15189
15204
|
`Preds: ${(block.preds || []).map((block2) => block2.order).join(", ")}`
|
|
15190
15205
|
);
|
|
15191
15206
|
if (block.events) {
|
|
15192
15207
|
block.events.forEach(
|
|
15193
|
-
(event) => event.type !== "exn" && (0,
|
|
15208
|
+
(event) => event.type !== "exn" && (0, import_chunk_67LU4GPQ.log)(
|
|
15194
15209
|
Promise.resolve(
|
|
15195
15210
|
event.decl ? declFullName(event.decl) : event.node ? formatAst(event.node) : "??"
|
|
15196
15211
|
).then((eventDetails) => ` ${event.type}: ${eventDetails}`)
|
|
15197
15212
|
)
|
|
15198
15213
|
);
|
|
15199
15214
|
}
|
|
15200
|
-
(0,
|
|
15215
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
15201
15216
|
`Succs: ${(block.succs || []).map((block2) => block2.order).join(", ")} ExSucc: ${block.exsucc ? block.exsucc.order : ""}`
|
|
15202
15217
|
);
|
|
15203
15218
|
});
|
|
@@ -15265,7 +15280,7 @@ function computeAttributes(state, head) {
|
|
|
15265
15280
|
}
|
|
15266
15281
|
case "mod": {
|
|
15267
15282
|
curState.forEach((candidates, decls) => {
|
|
15268
|
-
if ((0,
|
|
15283
|
+
if ((0, import_chunk_67LU4GPQ.some)(
|
|
15269
15284
|
decls,
|
|
15270
15285
|
(decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && candidates.live && (!event.callees || event.callees.some(
|
|
15271
15286
|
(callee) => functionMayModify(state, callee, decl)
|
|
@@ -15307,7 +15322,7 @@ function computeAttributes(state, head) {
|
|
|
15307
15322
|
}
|
|
15308
15323
|
blockStates[top.order] = curState;
|
|
15309
15324
|
if (logging2) {
|
|
15310
|
-
(0,
|
|
15325
|
+
(0, import_chunk_67LU4GPQ.log)(`Updated block ${top.order}`);
|
|
15311
15326
|
logAntDecls(curState);
|
|
15312
15327
|
}
|
|
15313
15328
|
if (top.preds) {
|
|
@@ -15409,7 +15424,7 @@ function applyReplacements(func, nodeMap, declMap) {
|
|
|
15409
15424
|
}
|
|
15410
15425
|
const name = declMap.get(event.decl);
|
|
15411
15426
|
if (!name) {
|
|
15412
|
-
throw new
|
|
15427
|
+
throw new import_chunk_67LU4GPQ.AwaitedError(
|
|
15413
15428
|
formatAst(node).then(
|
|
15414
15429
|
(targetStr) => `No replacement found for "${targetStr}"`
|
|
15415
15430
|
)
|
|
@@ -15431,7 +15446,7 @@ function applyReplacements(func, nodeMap, declMap) {
|
|
|
15431
15446
|
const target = node.type === "AssignmentExpression" ? node.left : node.argument;
|
|
15432
15447
|
const name = declMap.get(event.decl);
|
|
15433
15448
|
if (!name) {
|
|
15434
|
-
throw new
|
|
15449
|
+
throw new import_chunk_67LU4GPQ.AwaitedError(
|
|
15435
15450
|
formatAst(target).then(
|
|
15436
15451
|
(targetStr) => `No replacement found for "${targetStr}"`
|
|
15437
15452
|
)
|
|
@@ -15494,14 +15509,14 @@ function applyReplacements(func, nodeMap, declMap) {
|
|
|
15494
15509
|
const decl = event.decl;
|
|
15495
15510
|
const name = declMap.get(decl);
|
|
15496
15511
|
if (!name) {
|
|
15497
|
-
throw new
|
|
15512
|
+
throw new import_chunk_67LU4GPQ.AwaitedError(
|
|
15498
15513
|
declFullName(decl).then(
|
|
15499
15514
|
(declStr) => `No replacement found for "${declStr}"`
|
|
15500
15515
|
)
|
|
15501
15516
|
);
|
|
15502
15517
|
}
|
|
15503
15518
|
if (!event.id) {
|
|
15504
|
-
throw new
|
|
15519
|
+
throw new import_chunk_67LU4GPQ.AwaitedError(
|
|
15505
15520
|
declFullName(decl).then(
|
|
15506
15521
|
(declStr) => `Missing id for mod event for "${declStr}"`
|
|
15507
15522
|
)
|
|
@@ -15566,7 +15581,7 @@ var init_pre = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
15566
15581
|
init_data_flow();
|
|
15567
15582
|
init_function_info();
|
|
15568
15583
|
init_minimize_locals();
|
|
15569
|
-
(0,
|
|
15584
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
15570
15585
|
logging2 = false;
|
|
15571
15586
|
LocalRefCost = 2;
|
|
15572
15587
|
}
|
|
@@ -15937,7 +15952,7 @@ function beforeEvaluate(istate, node) {
|
|
|
15937
15952
|
break;
|
|
15938
15953
|
}
|
|
15939
15954
|
const id = node.right.argument;
|
|
15940
|
-
if ((0,
|
|
15955
|
+
if ((0, import_chunk_67LU4GPQ.every)(left.value.value, (m) => {
|
|
15941
15956
|
if ((0, import_chunk_MBTLUWXR.hasProperty)(m.decls, id.name))
|
|
15942
15957
|
return false;
|
|
15943
15958
|
return istate.state.lookup({
|
|
@@ -16383,7 +16398,7 @@ var init_optimize = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
16383
16398
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
16384
16399
|
init_inliner();
|
|
16385
16400
|
init_type_flow();
|
|
16386
|
-
(0,
|
|
16401
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
16387
16402
|
init_interp();
|
|
16388
16403
|
init_interp_binary();
|
|
16389
16404
|
init_types();
|
|
@@ -16920,13 +16935,13 @@ function markFunctionCalled(state, func) {
|
|
|
16920
16935
|
state.calledFunctions[func.id.name] = [func];
|
|
16921
16936
|
return;
|
|
16922
16937
|
}
|
|
16923
|
-
(0,
|
|
16938
|
+
(0, import_chunk_67LU4GPQ.pushUnique)(state.calledFunctions[func.id.name], func);
|
|
16924
16939
|
}
|
|
16925
16940
|
async function optimizeMonkeyC(fnMap, resourcesMap, manifestXML, config) {
|
|
16926
16941
|
try {
|
|
16927
16942
|
return optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config);
|
|
16928
16943
|
} catch (ex) {
|
|
16929
|
-
if (ex instanceof
|
|
16944
|
+
if (ex instanceof import_chunk_67LU4GPQ.AwaitedError) {
|
|
16930
16945
|
await ex.resolve();
|
|
16931
16946
|
}
|
|
16932
16947
|
throw ex;
|
|
@@ -17362,26 +17377,49 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17362
17377
|
Object.values(fnMap).forEach((f) => {
|
|
17363
17378
|
collectNamespaces(f.ast, state);
|
|
17364
17379
|
});
|
|
17380
|
+
let Changes;
|
|
17381
|
+
((Changes2) => {
|
|
17382
|
+
Changes2[Changes2["None"] = 0] = "None";
|
|
17383
|
+
Changes2[Changes2["Some"] = 1] = "Some";
|
|
17384
|
+
Changes2[Changes2["Force"] = 2] = "Force";
|
|
17385
|
+
})(Changes || (Changes = {}));
|
|
17365
17386
|
const cleanupAll = () => {
|
|
17366
17387
|
const usedDecls = findRezRefs(state);
|
|
17367
|
-
|
|
17368
|
-
|
|
17369
|
-
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
|
|
17373
|
-
|
|
17374
|
-
|
|
17375
|
-
|
|
17376
|
-
|
|
17377
|
-
|
|
17378
|
-
|
|
17379
|
-
|
|
17380
|
-
|
|
17381
|
-
|
|
17382
|
-
|
|
17388
|
+
const pre = state.pre;
|
|
17389
|
+
const post = state.post;
|
|
17390
|
+
try {
|
|
17391
|
+
delete state.pre;
|
|
17392
|
+
return Object.values(fnMap).reduce(
|
|
17393
|
+
(changes, f) => {
|
|
17394
|
+
state.post = (node) => {
|
|
17395
|
+
if (usedDecls.has(node)) {
|
|
17396
|
+
return null;
|
|
17397
|
+
}
|
|
17398
|
+
const ret = cleanup(state, node, f.ast, usedDecls);
|
|
17399
|
+
if (ret === false) {
|
|
17400
|
+
changes |= 1;
|
|
17401
|
+
state.removeNodeComments(node, f.ast);
|
|
17402
|
+
} else if (ret) {
|
|
17403
|
+
if (node.type === "EnumDeclaration" && ret.type === "TypedefDeclaration" && ret.ts.argument.ts.length > 1) {
|
|
17404
|
+
changes |= 2;
|
|
17405
|
+
} else {
|
|
17406
|
+
changes |= 1;
|
|
17407
|
+
}
|
|
17408
|
+
}
|
|
17409
|
+
return ret;
|
|
17410
|
+
};
|
|
17411
|
+
collectNamespaces(f.ast, state);
|
|
17412
|
+
return changes;
|
|
17413
|
+
},
|
|
17414
|
+
0
|
|
17415
|
+
/* None */
|
|
17416
|
+
);
|
|
17417
|
+
} finally {
|
|
17418
|
+
state.pre = pre;
|
|
17419
|
+
state.post = post;
|
|
17420
|
+
}
|
|
17383
17421
|
};
|
|
17384
|
-
|
|
17422
|
+
while (true) {
|
|
17385
17423
|
state.usedByName = {};
|
|
17386
17424
|
state.calledFunctions = {};
|
|
17387
17425
|
state.exposed = state.nextExposed;
|
|
@@ -17391,9 +17429,12 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17391
17429
|
});
|
|
17392
17430
|
state.exposed = state.nextExposed;
|
|
17393
17431
|
state.nextExposed = {};
|
|
17394
|
-
|
|
17395
|
-
|
|
17396
|
-
|
|
17432
|
+
const changes = cleanupAll();
|
|
17433
|
+
if (changes & 2 || changes & 1 && state.config?.iterateOptimizer) {
|
|
17434
|
+
continue;
|
|
17435
|
+
}
|
|
17436
|
+
break;
|
|
17437
|
+
}
|
|
17397
17438
|
delete state.pre;
|
|
17398
17439
|
delete state.post;
|
|
17399
17440
|
if (state.config?.minimizeModules ?? true) {
|
|
@@ -17514,56 +17555,64 @@ function cleanup(state, node, ast, usedNodes) {
|
|
|
17514
17555
|
case "ThisExpression":
|
|
17515
17556
|
node.text = "self";
|
|
17516
17557
|
break;
|
|
17517
|
-
case "
|
|
17518
|
-
if (node.members.every((m) => {
|
|
17558
|
+
case "EnumDeclaration": {
|
|
17559
|
+
if (!node.body.members.every((m) => {
|
|
17519
17560
|
if (usedNodes.has(m))
|
|
17520
17561
|
return false;
|
|
17521
17562
|
const name = "name" in m ? m.name : m.id.name;
|
|
17522
17563
|
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);
|
|
17523
17564
|
})) {
|
|
17524
|
-
|
|
17525
|
-
node.members.map((m) => {
|
|
17526
|
-
if (!("init" in m))
|
|
17527
|
-
return "Number";
|
|
17528
|
-
const [node2, type] = (0, import_chunk_MBTLUWXR.getNodeValue)(m.init);
|
|
17529
|
-
return node2 ? type : null;
|
|
17530
|
-
})
|
|
17531
|
-
);
|
|
17532
|
-
if (!enumType.has(null)) {
|
|
17533
|
-
node.enumType = [...enumType].map((t) => t === "Null" ? t : `Toybox.Lang.${t}`).join(" or ");
|
|
17534
|
-
node.members.splice(0);
|
|
17535
|
-
}
|
|
17565
|
+
break;
|
|
17536
17566
|
}
|
|
17537
|
-
|
|
17538
|
-
|
|
17539
|
-
|
|
17540
|
-
|
|
17541
|
-
|
|
17542
|
-
|
|
17543
|
-
|
|
17544
|
-
|
|
17545
|
-
|
|
17546
|
-
|
|
17547
|
-
|
|
17548
|
-
|
|
17549
|
-
|
|
17550
|
-
|
|
17551
|
-
|
|
17552
|
-
|
|
17553
|
-
|
|
17554
|
-
|
|
17555
|
-
|
|
17556
|
-
|
|
17557
|
-
|
|
17558
|
-
|
|
17559
|
-
|
|
17560
|
-
|
|
17561
|
-
|
|
17562
|
-
|
|
17563
|
-
|
|
17567
|
+
const enumType = new Set(
|
|
17568
|
+
node.body.members.map((m) => {
|
|
17569
|
+
if (!("init" in m))
|
|
17570
|
+
return "Number";
|
|
17571
|
+
const [node2, type] = (0, import_chunk_MBTLUWXR.getNodeValue)(m.init);
|
|
17572
|
+
return node2 ? type : null;
|
|
17573
|
+
})
|
|
17574
|
+
);
|
|
17575
|
+
if (enumType.has(null))
|
|
17576
|
+
break;
|
|
17577
|
+
if (!node.id)
|
|
17578
|
+
return false;
|
|
17579
|
+
state.removeNodeComments(node, ast);
|
|
17580
|
+
const typedefDecl = (0, import_chunk_MBTLUWXR.withLocDeep)(
|
|
17581
|
+
{
|
|
17582
|
+
type: "TypedefDeclaration",
|
|
17583
|
+
id: node.id,
|
|
17584
|
+
ts: {
|
|
17585
|
+
type: "UnaryExpression",
|
|
17586
|
+
argument: {
|
|
17587
|
+
type: "TypeSpecList",
|
|
17588
|
+
ts: Array.from(enumType).map((t) => ({
|
|
17589
|
+
type: "TypeSpecPart",
|
|
17590
|
+
name: t === "Null" ? t : (0, import_chunk_MBTLUWXR.makeScopedName)(`Toybox.Lang.${t}`)
|
|
17591
|
+
}))
|
|
17592
|
+
},
|
|
17593
|
+
prefix: true,
|
|
17594
|
+
operator: " as"
|
|
17595
|
+
}
|
|
17596
|
+
},
|
|
17597
|
+
node,
|
|
17598
|
+
node
|
|
17599
|
+
);
|
|
17600
|
+
const decls = state.stack[state.stack.length - 1].sn?.type_decls?.[node.id.name];
|
|
17601
|
+
if (decls) {
|
|
17602
|
+
const i = decls.findIndex(
|
|
17603
|
+
(d) => d.type === "EnumDeclaration" && d.node === node
|
|
17564
17604
|
);
|
|
17605
|
+
if (i >= 0) {
|
|
17606
|
+
const old = decls[i];
|
|
17607
|
+
decls.splice(i, 1, {
|
|
17608
|
+
...old,
|
|
17609
|
+
type: "TypedefDeclaration",
|
|
17610
|
+
node: typedefDecl
|
|
17611
|
+
});
|
|
17612
|
+
}
|
|
17565
17613
|
}
|
|
17566
|
-
|
|
17614
|
+
return typedefDecl;
|
|
17615
|
+
}
|
|
17567
17616
|
case "VariableDeclarator": {
|
|
17568
17617
|
const name = variableDeclarationName(node.id);
|
|
17569
17618
|
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) ? null : false;
|
|
@@ -17663,7 +17712,7 @@ var init_mc_rewrite = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
17663
17712
|
init_sub_type();
|
|
17664
17713
|
init_types();
|
|
17665
17714
|
init_unused_exprs();
|
|
17666
|
-
(0,
|
|
17715
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
17667
17716
|
init_variable_renamer();
|
|
17668
17717
|
init_data_flow();
|
|
17669
17718
|
}
|
|
@@ -17892,7 +17941,9 @@ function add_resources_to_ast(state, ast, resources, manifestXML) {
|
|
|
17892
17941
|
const hiddenRez = makeModule("*Rez*");
|
|
17893
17942
|
rez.body.body.push(hiddenRez);
|
|
17894
17943
|
if (barrel === "" && manifestXML && manifestXML.body instanceof xml_util_exports.Nodes) {
|
|
17895
|
-
manifestXML.body.children("iq:application").elements.forEach(
|
|
17944
|
+
manifestXML.body.children("iq:application").elements.forEach(
|
|
17945
|
+
(e) => add_one_resource(state, manifestXML, rez, e, "")
|
|
17946
|
+
);
|
|
17896
17947
|
}
|
|
17897
17948
|
const rezModules = Object.fromEntries(
|
|
17898
17949
|
Object.entries(modules).map(([moduleName, isPublic]) => {
|
|
@@ -17910,7 +17961,7 @@ function add_resources_to_ast(state, ast, resources, manifestXML) {
|
|
|
17910
17961
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(rezModules, s))
|
|
17911
17962
|
return;
|
|
17912
17963
|
const module2 = rezModules[s];
|
|
17913
|
-
add_one_resource(state, rez2, module2, e);
|
|
17964
|
+
add_one_resource(state, rez2, module2, e, barrel);
|
|
17914
17965
|
});
|
|
17915
17966
|
});
|
|
17916
17967
|
});
|
|
@@ -17926,11 +17977,14 @@ function addPositions(base, pos) {
|
|
|
17926
17977
|
result.offset += pos.offset;
|
|
17927
17978
|
return result;
|
|
17928
17979
|
}
|
|
17929
|
-
function visit_resource_refs(state, doc, e) {
|
|
17980
|
+
function visit_resource_refs(state, doc, e, barrel) {
|
|
17930
17981
|
const result = [];
|
|
17931
17982
|
const parseArg = (name, loc, skip) => {
|
|
17932
17983
|
if (name.startsWith("@")) {
|
|
17933
17984
|
name = name.substring(1);
|
|
17985
|
+
if (barrel && name.startsWith(barrel) && name[barrel.length] === ".") {
|
|
17986
|
+
name = name.slice(barrel.length + 1);
|
|
17987
|
+
}
|
|
17934
17988
|
loc = (0, import_chunk_MBTLUWXR.adjustLoc)(loc, 1, 0);
|
|
17935
17989
|
}
|
|
17936
17990
|
if ((0, import_chunk_MBTLUWXR.hasProperty)(skip, name) || /^\d+(\.\d+)?%?$/.test(name)) {
|
|
@@ -17987,18 +18041,27 @@ function visit_resource_refs(state, doc, e) {
|
|
|
17987
18041
|
}
|
|
17988
18042
|
if (id === "personality") {
|
|
17989
18043
|
const elems = dotted.match(/\s+|\S+/g);
|
|
17990
|
-
elems?.reduce((
|
|
17991
|
-
|
|
17992
|
-
|
|
18044
|
+
elems?.reduce((loc, name) => {
|
|
18045
|
+
if (/\s/.test(name)) {
|
|
18046
|
+
const newLines = name.match(/\r\n|[\r\n]/g);
|
|
18047
|
+
if (newLines?.length) {
|
|
18048
|
+
loc.start.line += newLines.length;
|
|
18049
|
+
loc.start.column = 1;
|
|
18050
|
+
loc.start.offset += name.length;
|
|
18051
|
+
name = name.replace(/^.*(\r\n|[\r\n])(.*)$/, "$2");
|
|
18052
|
+
loc.start.offset -= name.length;
|
|
18053
|
+
}
|
|
18054
|
+
} else {
|
|
17993
18055
|
const base = (0, import_chunk_MBTLUWXR.makeScopedName)(`Rez.Styles`);
|
|
17994
|
-
const
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
18056
|
+
const idLoc = (0, import_chunk_MBTLUWXR.adjustLoc)(loc, 0, 0);
|
|
18057
|
+
idLoc.end = { ...idLoc.start };
|
|
18058
|
+
idLoc.end.column += name.length;
|
|
18059
|
+
idLoc.end.offset += name.length;
|
|
18060
|
+
const id2 = (0, import_chunk_MBTLUWXR.makeIdentifier)(name, idLoc);
|
|
17998
18061
|
result.push((0, import_chunk_MBTLUWXR.makeMemberExpression)((0, import_chunk_MBTLUWXR.withLoc)(base, id2, false), id2));
|
|
17999
18062
|
}
|
|
18000
|
-
return
|
|
18001
|
-
}, 0);
|
|
18063
|
+
return (0, import_chunk_MBTLUWXR.adjustLoc)(loc, name.length, 0);
|
|
18064
|
+
}, (0, import_chunk_MBTLUWXR.adjustLoc)(l, 0, 0));
|
|
18002
18065
|
return;
|
|
18003
18066
|
}
|
|
18004
18067
|
if (/^\s*(true|false|null|NaN|(0x|#)[0-9a-f]+|[-+]?\d+%?)\s*$/i.test(dotted)) {
|
|
@@ -18072,7 +18135,7 @@ function visit_resource_refs(state, doc, e) {
|
|
|
18072
18135
|
});
|
|
18073
18136
|
return result;
|
|
18074
18137
|
}
|
|
18075
|
-
function add_one_resource(state, doc, module2, e) {
|
|
18138
|
+
function add_one_resource(state, doc, module2, e, barrel) {
|
|
18076
18139
|
let id;
|
|
18077
18140
|
let func;
|
|
18078
18141
|
const makeVarDecl = (id2, outer) => {
|
|
@@ -18236,7 +18299,7 @@ function add_one_resource(state, doc, module2, e) {
|
|
|
18236
18299
|
}
|
|
18237
18300
|
if (!func)
|
|
18238
18301
|
return;
|
|
18239
|
-
const elements = visit_resource_refs(state, doc, e);
|
|
18302
|
+
const elements = visit_resource_refs(state, doc, e, barrel);
|
|
18240
18303
|
const startLoc = elements[0]?.loc;
|
|
18241
18304
|
const endLoc = elements[elements.length - 1]?.loc;
|
|
18242
18305
|
const init = elements.length ? (0, import_chunk_MBTLUWXR.wrap)(
|
|
@@ -18544,7 +18607,7 @@ async function getApiMapping(state, resourcesMap, manifestXML) {
|
|
|
18544
18607
|
throw `Negative constant ${fixup} was not a Literal`;
|
|
18545
18608
|
}
|
|
18546
18609
|
if (typeof init.value !== "number") {
|
|
18547
|
-
(0,
|
|
18610
|
+
(0, import_chunk_67LU4GPQ.log)(`Negative fixup ${fixup} was not a number!`);
|
|
18548
18611
|
} else if (init.value > 0) {
|
|
18549
18612
|
init.value = -init.value;
|
|
18550
18613
|
init.raw = "-" + init.raw;
|
|
@@ -18634,11 +18697,11 @@ function sameStateNodeDecl(a, b) {
|
|
|
18634
18697
|
function sameLookupDefinition(a, b) {
|
|
18635
18698
|
return (
|
|
18636
18699
|
// sameStateNodeDecl(a.parent, b.parent) &&
|
|
18637
|
-
(0,
|
|
18700
|
+
(0, import_chunk_67LU4GPQ.sameArrays)(a.results, b.results, (ar, br) => sameStateNodeDecl(ar, br))
|
|
18638
18701
|
);
|
|
18639
18702
|
}
|
|
18640
18703
|
function sameLookupResult(a, b) {
|
|
18641
|
-
return (0,
|
|
18704
|
+
return (0, import_chunk_67LU4GPQ.sameArrays)(a, b, sameLookupDefinition);
|
|
18642
18705
|
}
|
|
18643
18706
|
function declKey(decl) {
|
|
18644
18707
|
return isStateNode(decl) ? decl.type === "ModuleDeclaration" ? decl.fullName : decl.node : decl;
|
|
@@ -19176,7 +19239,7 @@ function stateFuncs() {
|
|
|
19176
19239
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(this.index, name)) {
|
|
19177
19240
|
this.index[name] = [];
|
|
19178
19241
|
}
|
|
19179
|
-
(0,
|
|
19242
|
+
(0, import_chunk_67LU4GPQ.pushUnique)(this.index[name], parent);
|
|
19180
19243
|
}
|
|
19181
19244
|
});
|
|
19182
19245
|
break;
|
|
@@ -19231,7 +19294,7 @@ function stateFuncs() {
|
|
|
19231
19294
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(values, name)) {
|
|
19232
19295
|
values[name] = [];
|
|
19233
19296
|
}
|
|
19234
|
-
if ((0,
|
|
19297
|
+
if ((0, import_chunk_67LU4GPQ.pushUnique)(values[name], m) && currentEnum) {
|
|
19235
19298
|
if (!this.enumMap)
|
|
19236
19299
|
this.enumMap = /* @__PURE__ */ new Map();
|
|
19237
19300
|
this.enumMap.set(m, currentEnum);
|
|
@@ -19239,7 +19302,7 @@ function stateFuncs() {
|
|
|
19239
19302
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(this.index, name)) {
|
|
19240
19303
|
this.index[name] = [];
|
|
19241
19304
|
}
|
|
19242
|
-
(0,
|
|
19305
|
+
(0, import_chunk_67LU4GPQ.pushUnique)(this.index[name], parent);
|
|
19243
19306
|
});
|
|
19244
19307
|
break;
|
|
19245
19308
|
}
|
|
@@ -19740,7 +19803,7 @@ var init_api = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
19740
19803
|
init_sdk_util();
|
|
19741
19804
|
init_type_flow_util();
|
|
19742
19805
|
init_types();
|
|
19743
|
-
(0,
|
|
19806
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
19744
19807
|
init_visitor();
|
|
19745
19808
|
}
|
|
19746
19809
|
});
|
|
@@ -19824,7 +19887,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
|
|
|
19824
19887
|
return decls;
|
|
19825
19888
|
}
|
|
19826
19889
|
if (canon.length !== decls.length || !canon.every((v, i) => v === decls[i])) {
|
|
19827
|
-
throw new
|
|
19890
|
+
throw new import_chunk_67LU4GPQ.AwaitedError(
|
|
19828
19891
|
declFullName(canon).then(
|
|
19829
19892
|
(canonStr) => `Canonical representation of ${canonStr} did not match`
|
|
19830
19893
|
)
|
|
@@ -19858,7 +19921,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
|
|
|
19858
19921
|
}
|
|
19859
19922
|
const decl = lookupDefToDecl(results);
|
|
19860
19923
|
if (decl && path7.length) {
|
|
19861
|
-
if (wantsAllRefs && (0,
|
|
19924
|
+
if (wantsAllRefs && (0, import_chunk_67LU4GPQ.every)(
|
|
19862
19925
|
decl,
|
|
19863
19926
|
(d) => d.type === "VariableDeclarator" || d.type === "BinaryExpression" || d.type === "Identifier"
|
|
19864
19927
|
)) {
|
|
@@ -19910,7 +19973,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
|
|
|
19910
19973
|
}
|
|
19911
19974
|
const v = liveDefs.get(def);
|
|
19912
19975
|
if (!v || !v.has(node)) {
|
|
19913
|
-
throw new
|
|
19976
|
+
throw new import_chunk_67LU4GPQ.AwaitedError(
|
|
19914
19977
|
Promise.resolve(def ? declFullName(def) : "null").then(
|
|
19915
19978
|
(defStr) => `No stmt in liveDef for ${defStr}`
|
|
19916
19979
|
)
|
|
@@ -19968,7 +20031,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
|
|
|
19968
20031
|
const decls = findDecl(node);
|
|
19969
20032
|
if (!decls)
|
|
19970
20033
|
break;
|
|
19971
|
-
if (trackInsertionPoints && (0,
|
|
20034
|
+
if (trackInsertionPoints && (0, import_chunk_67LU4GPQ.some)(decls, (decl) => {
|
|
19972
20035
|
if (decl.type === "VariableDeclarator") {
|
|
19973
20036
|
const defStmts = decl.node.kind === "var" && liveDefs.get(null) || liveDefs.get(decl);
|
|
19974
20037
|
if (defStmts) {
|
|
@@ -20219,8 +20282,8 @@ var init_data_flow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
20219
20282
|
init_control_flow();
|
|
20220
20283
|
init_function_info();
|
|
20221
20284
|
init_type_flow_util();
|
|
20222
|
-
(0,
|
|
20223
|
-
DataflowQueue = class extends
|
|
20285
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
20286
|
+
DataflowQueue = class extends import_chunk_67LU4GPQ.GenericQueue {
|
|
20224
20287
|
constructor() {
|
|
20225
20288
|
super((b, a) => (a.order || 0) - (b.order || 0));
|
|
20226
20289
|
}
|
|
@@ -21015,7 +21078,7 @@ function computeJsrMap(func) {
|
|
|
21015
21078
|
}
|
|
21016
21079
|
function postOrderPropagate(func, preBlock, processBc, postBlock, merge) {
|
|
21017
21080
|
const order = /* @__PURE__ */ new Map();
|
|
21018
|
-
const queue = new
|
|
21081
|
+
const queue = new import_chunk_67LU4GPQ.GenericQueue(
|
|
21019
21082
|
(b, a) => order.get(a) - order.get(b)
|
|
21020
21083
|
);
|
|
21021
21084
|
postOrderTraverse2(func, (block) => {
|
|
@@ -21074,7 +21137,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
|
|
|
21074
21137
|
});
|
|
21075
21138
|
blocks.reverse().forEach((block, i) => order.set(block, i));
|
|
21076
21139
|
}
|
|
21077
|
-
const queue = new
|
|
21140
|
+
const queue = new import_chunk_67LU4GPQ.GenericQueue(
|
|
21078
21141
|
(b, a) => order.get(a) - order.get(b)
|
|
21079
21142
|
);
|
|
21080
21143
|
queue.enqueue(func.blocks.get(func.offset));
|
|
@@ -21128,7 +21191,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
|
|
|
21128
21191
|
var init_cflow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
21129
21192
|
"src/readprg/cflow.ts"() {
|
|
21130
21193
|
"use strict";
|
|
21131
|
-
(0,
|
|
21194
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
21132
21195
|
init_opcodes();
|
|
21133
21196
|
}
|
|
21134
21197
|
});
|
|
@@ -21591,12 +21654,12 @@ function interpFunc(func, context) {
|
|
|
21591
21654
|
const selfStores = /* @__PURE__ */ new Set();
|
|
21592
21655
|
const liveInState = /* @__PURE__ */ new Map();
|
|
21593
21656
|
const replacements = /* @__PURE__ */ new Map();
|
|
21594
|
-
const interpLogging = (0,
|
|
21657
|
+
const interpLogging = (0, import_chunk_67LU4GPQ.wouldLog)("interp", 1);
|
|
21595
21658
|
if (interpLogging) {
|
|
21596
|
-
if ((0,
|
|
21597
|
-
(0,
|
|
21598
|
-
} else if ((0,
|
|
21599
|
-
(0,
|
|
21659
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 7)) {
|
|
21660
|
+
(0, import_chunk_67LU4GPQ.setBanner)(functionBanner(func, context, "interp"));
|
|
21661
|
+
} else if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 3)) {
|
|
21662
|
+
(0, import_chunk_67LU4GPQ.setBanner)(
|
|
21600
21663
|
() => `+++++++++++++ interp-prepare ${func.name} ++++++++++++++`
|
|
21601
21664
|
);
|
|
21602
21665
|
}
|
|
@@ -21630,20 +21693,20 @@ function interpFunc(func, context) {
|
|
|
21630
21693
|
func,
|
|
21631
21694
|
(block) => {
|
|
21632
21695
|
if (interpLogging) {
|
|
21633
|
-
(0,
|
|
21696
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
21634
21697
|
"interp",
|
|
21635
21698
|
3,
|
|
21636
21699
|
`${offsetToString(block.offset)}: ${block.bytecodes[0]?.lineNum ? lineInfoToString(block.bytecodes[0]?.lineNum, context) : ""}
|
|
21637
21700
|
${interpStateToString(liveInState.get(block.offset))}`
|
|
21638
21701
|
);
|
|
21639
|
-
(0,
|
|
21702
|
+
(0, import_chunk_67LU4GPQ.logger)("interp", 9, () => blockToString(block, context));
|
|
21640
21703
|
}
|
|
21641
21704
|
return cloneState2(liveInState.get(block.offset));
|
|
21642
21705
|
},
|
|
21643
21706
|
(block, bc, localState) => {
|
|
21644
21707
|
if (interpLogging) {
|
|
21645
|
-
if ((0,
|
|
21646
|
-
(0,
|
|
21708
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 8)) {
|
|
21709
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
21647
21710
|
`${interpStateToString(localState)}
|
|
21648
21711
|
${bytecodeToString(
|
|
21649
21712
|
bc,
|
|
@@ -21808,14 +21871,14 @@ function interpFunc(func, context) {
|
|
|
21808
21871
|
if (!mergeInto(localState, succState))
|
|
21809
21872
|
return false;
|
|
21810
21873
|
if (interpLogging) {
|
|
21811
|
-
(0,
|
|
21874
|
+
(0, import_chunk_67LU4GPQ.logger)("interp", 3, `Re-Merge to ${offsetToString(succBlock.offset)}`);
|
|
21812
21875
|
}
|
|
21813
21876
|
return true;
|
|
21814
21877
|
}
|
|
21815
21878
|
);
|
|
21816
21879
|
if (interpLogging) {
|
|
21817
|
-
if ((0,
|
|
21818
|
-
(0,
|
|
21880
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 5)) {
|
|
21881
|
+
(0, import_chunk_67LU4GPQ.setBanner)(
|
|
21819
21882
|
functionBanner(func, context, "interp", (block, footer) => {
|
|
21820
21883
|
if (footer)
|
|
21821
21884
|
return "";
|
|
@@ -21823,44 +21886,44 @@ function interpFunc(func, context) {
|
|
|
21823
21886
|
})
|
|
21824
21887
|
);
|
|
21825
21888
|
} else {
|
|
21826
|
-
(0,
|
|
21889
|
+
(0, import_chunk_67LU4GPQ.setBanner)(() => `=============== interp ${func.name} ==============`);
|
|
21827
21890
|
}
|
|
21828
21891
|
if (equivSets.size) {
|
|
21829
|
-
(0,
|
|
21892
|
+
(0, import_chunk_67LU4GPQ.log)(`====== equivSets =====`);
|
|
21830
21893
|
equivSets.forEach(
|
|
21831
|
-
(value2, key) => (0,
|
|
21894
|
+
(value2, key) => (0, import_chunk_67LU4GPQ.log)(
|
|
21832
21895
|
`L${key.arg} === ${Array.from(value2).sort().join(" ")} ${key.lineNum ? lineInfoToString(key.lineNum, context) : ""}`
|
|
21833
21896
|
)
|
|
21834
21897
|
);
|
|
21835
21898
|
}
|
|
21836
21899
|
if (selfStores.size) {
|
|
21837
|
-
(0,
|
|
21900
|
+
(0, import_chunk_67LU4GPQ.log)(`====== selfStores =====`);
|
|
21838
21901
|
selfStores.forEach(
|
|
21839
|
-
(value2) => (0,
|
|
21902
|
+
(value2) => (0, import_chunk_67LU4GPQ.log)(`${bytecodeToString(value2, symbolTable)}`)
|
|
21840
21903
|
);
|
|
21841
21904
|
}
|
|
21842
21905
|
if (replacements.size) {
|
|
21843
|
-
(0,
|
|
21906
|
+
(0, import_chunk_67LU4GPQ.log)(`====== replacements =====`);
|
|
21844
21907
|
replacements.forEach(
|
|
21845
21908
|
(blockRep) => blockRep.forEach(
|
|
21846
|
-
(rep, bc) => (0,
|
|
21909
|
+
(rep, bc) => (0, import_chunk_67LU4GPQ.log)(
|
|
21847
21910
|
`${bytecodeToString(bc, symbolTable)} => ${rep.invert ? "~" : ""}${bytecodeToString(rep, symbolTable)} ${bc.lineNum ? lineInfoToString(bc.lineNum, context) : ""}`
|
|
21848
21911
|
)
|
|
21849
21912
|
)
|
|
21850
21913
|
);
|
|
21851
21914
|
}
|
|
21852
21915
|
if (resolvedBranches.size) {
|
|
21853
|
-
(0,
|
|
21916
|
+
(0, import_chunk_67LU4GPQ.log)(`====== resolved branches =====`);
|
|
21854
21917
|
resolvedBranches.forEach(
|
|
21855
|
-
(isTaken, block) => (0,
|
|
21918
|
+
(isTaken, block) => (0, import_chunk_67LU4GPQ.log)(
|
|
21856
21919
|
`block ${offsetToString(block.offset)} is ${isTaken ? "always" : "never"} taken`
|
|
21857
21920
|
)
|
|
21858
21921
|
);
|
|
21859
21922
|
}
|
|
21860
21923
|
if (branchRedirects.size) {
|
|
21861
|
-
(0,
|
|
21924
|
+
(0, import_chunk_67LU4GPQ.log)(`====== redirected branches =====`);
|
|
21862
21925
|
branchRedirects.forEach(
|
|
21863
|
-
({ to, from }, block) => (0,
|
|
21926
|
+
({ to, from }, block) => (0, import_chunk_67LU4GPQ.log)(
|
|
21864
21927
|
`block ${offsetToString(
|
|
21865
21928
|
block.offset
|
|
21866
21929
|
)} redirects from ${offsetToString(from)} to ${offsetToString(to)}${safeBranchBlocks.get(from) ? ` popping ${safeBranchBlocks.get(from)}` : ""}`
|
|
@@ -21923,7 +21986,7 @@ function interpFunc(func, context) {
|
|
|
21923
21986
|
}
|
|
21924
21987
|
});
|
|
21925
21988
|
if (interpLogging)
|
|
21926
|
-
(0,
|
|
21989
|
+
(0, import_chunk_67LU4GPQ.setBanner)(null);
|
|
21927
21990
|
return {
|
|
21928
21991
|
liveInState,
|
|
21929
21992
|
equivSets,
|
|
@@ -21973,7 +22036,7 @@ var init_interp2 = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
21973
22036
|
"src/readprg/interp.ts"() {
|
|
21974
22037
|
"use strict";
|
|
21975
22038
|
init_interp_binary();
|
|
21976
|
-
(0,
|
|
22039
|
+
(0, import_chunk_67LU4GPQ.init_logger)();
|
|
21977
22040
|
init_interp();
|
|
21978
22041
|
init_types();
|
|
21979
22042
|
init_union_type();
|
|
@@ -22085,7 +22148,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
22085
22148
|
i = found;
|
|
22086
22149
|
}
|
|
22087
22150
|
if (initType && (block.bytecodes[index].op === 20 ? initType.type === 1 : initType.type === 8 && initType.value === 0)) {
|
|
22088
|
-
(0,
|
|
22151
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
22089
22152
|
"array-init",
|
|
22090
22153
|
1,
|
|
22091
22154
|
() => `${func.name}: Removing initialization of default initialized ${putvStarts.length} element array init at block ${offsetToString(
|
|
@@ -22122,7 +22185,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
22122
22185
|
convertAputv(offset - 1);
|
|
22123
22186
|
}
|
|
22124
22187
|
}
|
|
22125
|
-
(0,
|
|
22188
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
22126
22189
|
"array-init",
|
|
22127
22190
|
1,
|
|
22128
22191
|
() => `${func.name}: Optimizing unused ${putvStarts.length} element array init at block ${offsetToString(
|
|
@@ -22131,8 +22194,8 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
22131
22194
|
block.bytecodes[index].offset
|
|
22132
22195
|
)}`
|
|
22133
22196
|
);
|
|
22134
|
-
if ((0,
|
|
22135
|
-
(0,
|
|
22197
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("array-init", 5)) {
|
|
22198
|
+
(0, import_chunk_67LU4GPQ.log)(blockToString(block, context));
|
|
22136
22199
|
}
|
|
22137
22200
|
return true;
|
|
22138
22201
|
}
|
|
@@ -22172,7 +22235,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
22172
22235
|
if (putvStarts.length < 3)
|
|
22173
22236
|
return false;
|
|
22174
22237
|
tryLocal(3);
|
|
22175
|
-
(0,
|
|
22238
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
22176
22239
|
"array-init",
|
|
22177
22240
|
1,
|
|
22178
22241
|
() => `${func.name}: Optimizing ${putvStarts.length} element array init with constant initializer ${bytecodeToString(
|
|
@@ -22198,7 +22261,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
22198
22261
|
block.bytecodes[index + 1].arg = putvStarts.length;
|
|
22199
22262
|
}
|
|
22200
22263
|
}
|
|
22201
|
-
(0,
|
|
22264
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
22202
22265
|
"array-init",
|
|
22203
22266
|
5,
|
|
22204
22267
|
() => `index: ${index}, i: ${i}
|
|
@@ -22251,7 +22314,7 @@ ${blockToString(block, context)}`
|
|
|
22251
22314
|
for (let i2 = putvStarts.length; i2-- > 1; ) {
|
|
22252
22315
|
block.bytecodes.splice(putvStarts[i2], 2);
|
|
22253
22316
|
}
|
|
22254
|
-
(0,
|
|
22317
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
22255
22318
|
"array-init",
|
|
22256
22319
|
1,
|
|
22257
22320
|
() => `${func.name}: Optimizing ${putvStarts.length} element array init at block ${offsetToString(
|
|
@@ -22310,15 +22373,15 @@ var init_array_init = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
22310
22373
|
"src/readprg/array-init.ts"() {
|
|
22311
22374
|
"use strict";
|
|
22312
22375
|
init_types();
|
|
22313
|
-
(0,
|
|
22376
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
22314
22377
|
init_bytecode();
|
|
22315
22378
|
init_interp2();
|
|
22316
22379
|
init_opcodes();
|
|
22317
22380
|
}
|
|
22318
22381
|
});
|
|
22319
22382
|
function localDCE(func, context) {
|
|
22320
|
-
if ((0,
|
|
22321
|
-
(0,
|
|
22383
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("dce", 5)) {
|
|
22384
|
+
(0, import_chunk_67LU4GPQ.setBanner)(
|
|
22322
22385
|
functionBanner(
|
|
22323
22386
|
func,
|
|
22324
22387
|
context,
|
|
@@ -22351,7 +22414,7 @@ function localDCE(func, context) {
|
|
|
22351
22414
|
};
|
|
22352
22415
|
func.blocks.forEach((block) => {
|
|
22353
22416
|
const reportPopv = (i, item, kill) => {
|
|
22354
|
-
(0,
|
|
22417
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
22355
22418
|
"dce",
|
|
22356
22419
|
2,
|
|
22357
22420
|
() => `${func.name}: Convert ${i}:${bytecodeToString(
|
|
@@ -22366,7 +22429,7 @@ function localDCE(func, context) {
|
|
|
22366
22429
|
);
|
|
22367
22430
|
};
|
|
22368
22431
|
const reportNop = (item) => {
|
|
22369
|
-
(0,
|
|
22432
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
22370
22433
|
"dce",
|
|
22371
22434
|
2,
|
|
22372
22435
|
() => `${func.name}: Kill ${item.deps.map(
|
|
@@ -22385,7 +22448,7 @@ function localDCE(func, context) {
|
|
|
22385
22448
|
case 19: {
|
|
22386
22449
|
const liveLocal = dceInfo.locals.has(bytecode.arg);
|
|
22387
22450
|
if (!liveLocal && (bytecode.arg || context.config.allowForbiddenOpts)) {
|
|
22388
|
-
(0,
|
|
22451
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
22389
22452
|
"dce",
|
|
22390
22453
|
2,
|
|
22391
22454
|
() => `${func.name}: Killing store to unused local ${bytecode.arg} at ${offsetToString(block.offset)}:${i}`
|
|
@@ -22545,10 +22608,10 @@ function localDCE(func, context) {
|
|
|
22545
22608
|
(bc) => bc.op !== 0
|
|
22546
22609
|
/* nop */
|
|
22547
22610
|
);
|
|
22548
|
-
(0,
|
|
22611
|
+
(0, import_chunk_67LU4GPQ.logger)("dce", 3, functionBanner(func, context, "local-dce-end"));
|
|
22549
22612
|
}
|
|
22550
22613
|
});
|
|
22551
|
-
(0,
|
|
22614
|
+
(0, import_chunk_67LU4GPQ.setBanner)(null);
|
|
22552
22615
|
return anyChanges;
|
|
22553
22616
|
}
|
|
22554
22617
|
function computeLiveLocals(func) {
|
|
@@ -22599,7 +22662,7 @@ var init_dce = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
22599
22662
|
"src/readprg/dce.ts"() {
|
|
22600
22663
|
"use strict";
|
|
22601
22664
|
init_data_flow();
|
|
22602
|
-
(0,
|
|
22665
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
22603
22666
|
init_bytecode();
|
|
22604
22667
|
init_cflow();
|
|
22605
22668
|
init_opcodes();
|
|
@@ -22639,7 +22702,7 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
22639
22702
|
const splitRanges = computeSplitRanges(func, equivSets);
|
|
22640
22703
|
const locals = mergeSplitRanges(splitRanges);
|
|
22641
22704
|
const numLocals = Math.max(...Array.from(splitRanges.keys())) + 1;
|
|
22642
|
-
(0,
|
|
22705
|
+
(0, import_chunk_67LU4GPQ.logger)("locals", 10, functionBanner(func, context, "Minimize Locals"));
|
|
22643
22706
|
let argc = func.argc ?? null;
|
|
22644
22707
|
const colors = /* @__PURE__ */ new Map();
|
|
22645
22708
|
const merge = [];
|
|
@@ -22706,15 +22769,15 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
22706
22769
|
}
|
|
22707
22770
|
}
|
|
22708
22771
|
}
|
|
22709
|
-
if ((0,
|
|
22710
|
-
if (!(0,
|
|
22711
|
-
(0,
|
|
22772
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("locals", 1)) {
|
|
22773
|
+
if (!(0, import_chunk_67LU4GPQ.wouldLog)("locals", 10)) {
|
|
22774
|
+
(0, import_chunk_67LU4GPQ.logger)("locals", 5, functionBanner(func, context, "Minimize Locals"));
|
|
22712
22775
|
}
|
|
22713
|
-
(0,
|
|
22776
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
22714
22777
|
`>>> Merging locals in ${func.name} (in: ${numLocals} => out: ${merge.length})`
|
|
22715
22778
|
);
|
|
22716
22779
|
merge.slice().sort((a, b) => (colors.get(a[0]) ?? 0) - (colors.get(b[0]) ?? 0)).forEach(
|
|
22717
|
-
(merged) => (0,
|
|
22780
|
+
(merged) => (0, import_chunk_67LU4GPQ.log)(
|
|
22718
22781
|
` ${colors.get(merged[0])} - ${merged.map((k) => bytecodeToString(k, context.symbolTable)).join(" | ")}`
|
|
22719
22782
|
)
|
|
22720
22783
|
);
|
|
@@ -23013,7 +23076,7 @@ function mergeSplitRanges(splitRanges) {
|
|
|
23013
23076
|
var init_locals = (0, import_chunk_ABYVSU2C.__esm)({
|
|
23014
23077
|
"src/readprg/locals.ts"() {
|
|
23015
23078
|
"use strict";
|
|
23016
|
-
(0,
|
|
23079
|
+
(0, import_chunk_67LU4GPQ.init_logger)();
|
|
23017
23080
|
init_bytecode();
|
|
23018
23081
|
init_cflow();
|
|
23019
23082
|
init_opcodes();
|
|
@@ -23126,16 +23189,16 @@ function sizeBasedPRE2(func, context) {
|
|
|
23126
23189
|
delete bc.arg;
|
|
23127
23190
|
return bc;
|
|
23128
23191
|
};
|
|
23129
|
-
if ((0,
|
|
23130
|
-
if ((0,
|
|
23131
|
-
(0,
|
|
23192
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("pre", 1)) {
|
|
23193
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("pre", 5)) {
|
|
23194
|
+
(0, import_chunk_67LU4GPQ.log)(functionBanner(func, context, "PRE")());
|
|
23132
23195
|
} else {
|
|
23133
|
-
(0,
|
|
23196
|
+
(0, import_chunk_67LU4GPQ.log)(`================ PRE : ${func.name} ================
|
|
23134
23197
|
`);
|
|
23135
23198
|
}
|
|
23136
23199
|
insertionBlocks.forEach((o, key) => {
|
|
23137
23200
|
const bcs = canonicalMap.get(key);
|
|
23138
|
-
(0,
|
|
23201
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
23139
23202
|
`Replacing ${bcs.size} instances of ${bytecodeToString(
|
|
23140
23203
|
bcs.values().next().value,
|
|
23141
23204
|
context.symbolTable
|
|
@@ -23218,13 +23281,13 @@ function sizeBasedPRE2(func, context) {
|
|
|
23218
23281
|
bytecode(1, insertionBlocks.size)
|
|
23219
23282
|
);
|
|
23220
23283
|
}
|
|
23221
|
-
(0,
|
|
23284
|
+
(0, import_chunk_67LU4GPQ.logger)("pre", 5, functionBanner(func, context, "post-PRE"));
|
|
23222
23285
|
return true;
|
|
23223
23286
|
}
|
|
23224
23287
|
var init_pre2 = (0, import_chunk_ABYVSU2C.__esm)({
|
|
23225
23288
|
"src/readprg/pre.ts"() {
|
|
23226
23289
|
"use strict";
|
|
23227
|
-
(0,
|
|
23290
|
+
(0, import_chunk_67LU4GPQ.init_logger)();
|
|
23228
23291
|
init_bytecode();
|
|
23229
23292
|
init_cflow();
|
|
23230
23293
|
init_opcodes();
|
|
@@ -23257,9 +23320,9 @@ function blockSharing(func, context) {
|
|
|
23257
23320
|
if (!any)
|
|
23258
23321
|
return false;
|
|
23259
23322
|
any = false;
|
|
23260
|
-
const logging3 = (0,
|
|
23261
|
-
if (logging3 && (0,
|
|
23262
|
-
(0,
|
|
23323
|
+
const logging3 = (0, import_chunk_67LU4GPQ.wouldLog)("sharing", 1);
|
|
23324
|
+
if (logging3 && (0, import_chunk_67LU4GPQ.wouldLog)("sharing", 10)) {
|
|
23325
|
+
(0, import_chunk_67LU4GPQ.setBanner)(functionBanner(func, context, "sharing"));
|
|
23263
23326
|
}
|
|
23264
23327
|
candidates.forEach((blocks) => {
|
|
23265
23328
|
while (blocks.size > 1) {
|
|
@@ -23395,9 +23458,9 @@ function blockSharing(func, context) {
|
|
|
23395
23458
|
block2.offset
|
|
23396
23459
|
)})` : `block(${offsetToString(block2.offset)})`;
|
|
23397
23460
|
};
|
|
23398
|
-
(0,
|
|
23399
|
-
if ((0,
|
|
23400
|
-
(0,
|
|
23461
|
+
(0, import_chunk_67LU4GPQ.log)(`Sharing ${showBlock(block)} with ${showBlock(target)}`);
|
|
23462
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("sharing", 5)) {
|
|
23463
|
+
(0, import_chunk_67LU4GPQ.log)(blockToString(target, context));
|
|
23401
23464
|
}
|
|
23402
23465
|
}
|
|
23403
23466
|
if (target.bytecodes.length > length2) {
|
|
@@ -23424,13 +23487,13 @@ function blockSharing(func, context) {
|
|
|
23424
23487
|
});
|
|
23425
23488
|
}
|
|
23426
23489
|
});
|
|
23427
|
-
(0,
|
|
23490
|
+
(0, import_chunk_67LU4GPQ.setBanner)(null);
|
|
23428
23491
|
return any;
|
|
23429
23492
|
}
|
|
23430
23493
|
var init_sharing = (0, import_chunk_ABYVSU2C.__esm)({
|
|
23431
23494
|
"src/readprg/sharing.ts"() {
|
|
23432
23495
|
"use strict";
|
|
23433
|
-
(0,
|
|
23496
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
23434
23497
|
init_bytecode();
|
|
23435
23498
|
init_opcodes();
|
|
23436
23499
|
}
|
|
@@ -23494,7 +23557,7 @@ function doArrayInits(func, liveInState, context) {
|
|
|
23494
23557
|
}
|
|
23495
23558
|
function simpleOpts(func, context) {
|
|
23496
23559
|
const equalsSym = 8388787;
|
|
23497
|
-
const logging3 = (0,
|
|
23560
|
+
const logging3 = (0, import_chunk_67LU4GPQ.wouldLog)("optimize", 5);
|
|
23498
23561
|
return Array.from(func.blocks.values()).reduce((changes, block) => {
|
|
23499
23562
|
for (let i = block.bytecodes.length; i--; ) {
|
|
23500
23563
|
const cur = block.bytecodes[i];
|
|
@@ -23502,7 +23565,7 @@ function simpleOpts(func, context) {
|
|
|
23502
23565
|
block.bytecodes.splice(i, 1);
|
|
23503
23566
|
changes = true;
|
|
23504
23567
|
if (logging3) {
|
|
23505
|
-
(0,
|
|
23568
|
+
(0, import_chunk_67LU4GPQ.log)(`${func.name}: deleting ${bytecodeToString(cur, null)}`);
|
|
23506
23569
|
}
|
|
23507
23570
|
} else if (cur.op === 74 && context.config.removeArgc && context.config.allowForbiddenOpts) {
|
|
23508
23571
|
const arg = cur.arg.incsp;
|
|
@@ -23511,7 +23574,7 @@ function simpleOpts(func, context) {
|
|
|
23511
23574
|
incsp.arg = arg;
|
|
23512
23575
|
changes = true;
|
|
23513
23576
|
if (logging3) {
|
|
23514
|
-
(0,
|
|
23577
|
+
(0, import_chunk_67LU4GPQ.log)(`${func.name}: argcincsp => incsp`);
|
|
23515
23578
|
}
|
|
23516
23579
|
} else if (i && cur.op === 39 && cur.arg === equalsSym) {
|
|
23517
23580
|
changes = equalSymbolToEq(block, i) || changes;
|
|
@@ -23522,7 +23585,7 @@ function simpleOpts(func, context) {
|
|
|
23522
23585
|
if (!shift && prev.op === 37) {
|
|
23523
23586
|
block.bytecodes.splice(i - 1, 2);
|
|
23524
23587
|
changes = true;
|
|
23525
|
-
logging3 && (0,
|
|
23588
|
+
logging3 && (0, import_chunk_67LU4GPQ.log)(`${func.name}: deleting no-op shift (${shift})`);
|
|
23526
23589
|
continue;
|
|
23527
23590
|
}
|
|
23528
23591
|
if (shift === 1n && prev.op === 37) {
|
|
@@ -23532,7 +23595,7 @@ function simpleOpts(func, context) {
|
|
|
23532
23595
|
const add = cur;
|
|
23533
23596
|
add.op = 3;
|
|
23534
23597
|
delete add.arg;
|
|
23535
|
-
logging3 && (0,
|
|
23598
|
+
logging3 && (0, import_chunk_67LU4GPQ.log)(`${func.name}: converting "ipush 1; shlv" to "dup 0; addv"`);
|
|
23536
23599
|
continue;
|
|
23537
23600
|
}
|
|
23538
23601
|
if (shift < (prev.op === 49 ? 64n : 31n)) {
|
|
@@ -23542,7 +23605,7 @@ function simpleOpts(func, context) {
|
|
|
23542
23605
|
} else {
|
|
23543
23606
|
prev.arg = BigInt.asIntN(64, mul);
|
|
23544
23607
|
}
|
|
23545
|
-
logging3 && (0,
|
|
23608
|
+
logging3 && (0, import_chunk_67LU4GPQ.log)(
|
|
23546
23609
|
`${func.name}: converting shlv(${shift}) to mulv(${prev.arg})`
|
|
23547
23610
|
);
|
|
23548
23611
|
changes = true;
|
|
@@ -23556,14 +23619,14 @@ function simpleOpts(func, context) {
|
|
|
23556
23619
|
func.blocks.get(block.taken).preds.delete(block.offset);
|
|
23557
23620
|
delete block.taken;
|
|
23558
23621
|
changes = true;
|
|
23559
|
-
logging3 && (0,
|
|
23622
|
+
logging3 && (0, import_chunk_67LU4GPQ.log)(`${func.name}: deleting empty finally handler`);
|
|
23560
23623
|
} else if (isCondBranch(cur.op)) {
|
|
23561
23624
|
const next = func.blocks.get(block.next);
|
|
23562
23625
|
const taken = func.blocks.get(block.taken);
|
|
23563
23626
|
if (next.preds.size > 1 && taken.preds.size === 1) {
|
|
23564
23627
|
const newOp = cur.op === 40 ? 41 : 40;
|
|
23565
23628
|
if (logging3) {
|
|
23566
|
-
(0,
|
|
23629
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
23567
23630
|
`${func.name}: converting ${Opcodes[cur.op]} to ${Opcodes[newOp]}`
|
|
23568
23631
|
);
|
|
23569
23632
|
}
|
|
@@ -23576,7 +23639,7 @@ function simpleOpts(func, context) {
|
|
|
23576
23639
|
const isBool = i >= 2 && isBoolOp(block.bytecodes[i - 2].op);
|
|
23577
23640
|
if (next.next === block.taken && next.taken == null && taken.bytecodes.length === 1 && isCondBranch(taken.bytecodes[0].op) && next.bytecodes.length > 1 && next.bytecodes[next.bytecodes.length - 1].op === (cur.op === 41 ? 7 : 8) && (isBool || next.bytecodes.length > 2 && isBoolOp(next.bytecodes[next.bytecodes.length - 2].op)) && next.preds?.size === 1 && taken.preds?.size === 2) {
|
|
23578
23641
|
if (logging3) {
|
|
23579
|
-
(0,
|
|
23642
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
23580
23643
|
`${func.name}: simplifying ${next.bytecodes[next.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
|
|
23581
23644
|
next.offset
|
|
23582
23645
|
)}:${offsetToString(taken.offset)}:`
|
|
@@ -23593,7 +23656,7 @@ function simpleOpts(func, context) {
|
|
|
23593
23656
|
changes = true;
|
|
23594
23657
|
} else if (taken.next === block.next && taken.taken == null && next.bytecodes.length === 1 && isCondBranch(next.bytecodes[0].op) && taken.bytecodes.length > 1 && taken.bytecodes[taken.bytecodes.length - 1].op === (cur.op === 40 ? 7 : 8) && (isBool || taken.bytecodes.length > 2 && isBoolOp(taken.bytecodes[taken.bytecodes.length - 2].op)) && next.preds?.size === 2 && taken.preds?.size === 1) {
|
|
23595
23658
|
if (logging3) {
|
|
23596
|
-
(0,
|
|
23659
|
+
(0, import_chunk_67LU4GPQ.log)(
|
|
23597
23660
|
`${func.name}: simplifying ${taken.bytecodes[taken.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
|
|
23598
23661
|
taken.offset
|
|
23599
23662
|
)}:${offsetToString(next.offset)}:`
|
|
@@ -23641,7 +23704,7 @@ function equalSymbolToEq(block, equalsIndex) {
|
|
|
23641
23704
|
op: 26,
|
|
23642
23705
|
offset: invokem.offset
|
|
23643
23706
|
});
|
|
23644
|
-
(0,
|
|
23707
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
23645
23708
|
"optimize",
|
|
23646
23709
|
1,
|
|
23647
23710
|
`Replacing <thing>.equals(:symbol) with <thing> eq :symbol at ${offsetToString(
|
|
@@ -23701,7 +23764,7 @@ function removeUnreachableCatches(func, context) {
|
|
|
23701
23764
|
const next = func.blocks.get(block.next);
|
|
23702
23765
|
if (block.try === next.try) {
|
|
23703
23766
|
if (next.preds.size === 1) {
|
|
23704
|
-
(0,
|
|
23767
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
23705
23768
|
"cfg",
|
|
23706
23769
|
1,
|
|
23707
23770
|
() => `${func.name}: ${offsetToString(
|
|
@@ -23724,7 +23787,7 @@ function removeUnreachableCatches(func, context) {
|
|
|
23724
23787
|
delete next.preds;
|
|
23725
23788
|
removeBlock(func, next.offset);
|
|
23726
23789
|
} else if (next.next == null && next.bytecodes.length < 3 && next.bytecodes.reduce((size, bc) => size + opcodeSize(bc.op), 0) < 3 && countFallthroughPreds(func, next) > 1) {
|
|
23727
|
-
(0,
|
|
23790
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
23728
23791
|
"cfg",
|
|
23729
23792
|
1,
|
|
23730
23793
|
() => `${func.name}: ${offsetToString(
|
|
@@ -23749,7 +23812,7 @@ function removeUnreachableCatches(func, context) {
|
|
|
23749
23812
|
switch (last.op) {
|
|
23750
23813
|
case 41:
|
|
23751
23814
|
case 40:
|
|
23752
|
-
(0,
|
|
23815
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
23753
23816
|
"cfg",
|
|
23754
23817
|
1,
|
|
23755
23818
|
() => `${func.name}: killing no-op ${bytecodeToString(
|
|
@@ -23772,7 +23835,7 @@ function removeUnreachableCatches(func, context) {
|
|
|
23772
23835
|
for (let i = block.try.length; i--; ) {
|
|
23773
23836
|
const handler = block.try[i].handler;
|
|
23774
23837
|
if (!func.blocks.get(handler)?.preds?.size) {
|
|
23775
|
-
(0,
|
|
23838
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
23776
23839
|
"cfg",
|
|
23777
23840
|
1,
|
|
23778
23841
|
`${func.name}: killing unused try-catch at ${offsetToString(
|
|
@@ -23789,8 +23852,8 @@ function removeUnreachableCatches(func, context) {
|
|
|
23789
23852
|
});
|
|
23790
23853
|
}
|
|
23791
23854
|
function cleanCfg2(func, context) {
|
|
23792
|
-
if ((0,
|
|
23793
|
-
(0,
|
|
23855
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("cfg", 10)) {
|
|
23856
|
+
(0, import_chunk_67LU4GPQ.setBanner)(functionBanner(func, context, "sharing"));
|
|
23794
23857
|
}
|
|
23795
23858
|
removeNoOpBlocks(func);
|
|
23796
23859
|
removeUnreachableCatches(func, context);
|
|
@@ -23805,12 +23868,12 @@ function cleanCfg2(func, context) {
|
|
|
23805
23868
|
(0, import_node_assert12.default)(!block.preds?.size);
|
|
23806
23869
|
func.blocks.delete(block.offset);
|
|
23807
23870
|
});
|
|
23808
|
-
(0,
|
|
23871
|
+
(0, import_chunk_67LU4GPQ.setBanner)(null);
|
|
23809
23872
|
}
|
|
23810
23873
|
var init_optimize2 = (0, import_chunk_ABYVSU2C.__esm)({
|
|
23811
23874
|
"src/readprg/optimize.ts"() {
|
|
23812
23875
|
"use strict";
|
|
23813
|
-
(0,
|
|
23876
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
23814
23877
|
init_array_init();
|
|
23815
23878
|
init_bytecode();
|
|
23816
23879
|
init_cflow();
|
|
@@ -24425,21 +24488,21 @@ function optimizeBytecode(context) {
|
|
|
24425
24488
|
functions.forEach(callback);
|
|
24426
24489
|
return;
|
|
24427
24490
|
}
|
|
24428
|
-
(0,
|
|
24491
|
+
(0, import_chunk_67LU4GPQ.bumpLogging)(null, 10);
|
|
24429
24492
|
functions.forEach((func) => {
|
|
24430
24493
|
if (loggerFunc.test(func.name ?? "<null>")) {
|
|
24431
|
-
(0,
|
|
24494
|
+
(0, import_chunk_67LU4GPQ.bumpLogging)(null, -10);
|
|
24432
24495
|
callback(func);
|
|
24433
|
-
(0,
|
|
24496
|
+
(0, import_chunk_67LU4GPQ.bumpLogging)(null, 10);
|
|
24434
24497
|
return;
|
|
24435
24498
|
}
|
|
24436
24499
|
callback(func);
|
|
24437
24500
|
});
|
|
24438
|
-
(0,
|
|
24501
|
+
(0, import_chunk_67LU4GPQ.bumpLogging)(null, -10);
|
|
24439
24502
|
};
|
|
24440
|
-
if ((0,
|
|
24503
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("list-input", 1)) {
|
|
24441
24504
|
forEachFunction(
|
|
24442
|
-
(func) => (0,
|
|
24505
|
+
(func) => (0, import_chunk_67LU4GPQ.wouldLog)("list-input", 1) && printFunction(func, context)
|
|
24443
24506
|
);
|
|
24444
24507
|
}
|
|
24445
24508
|
forEachFunction((func) => optimizeFunc(func, context));
|
|
@@ -24457,7 +24520,7 @@ function optimizeBytecode(context) {
|
|
|
24457
24520
|
forEachFunction((func) => {
|
|
24458
24521
|
if (!func.name)
|
|
24459
24522
|
return;
|
|
24460
|
-
(0,
|
|
24523
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
24461
24524
|
"bytecode",
|
|
24462
24525
|
5,
|
|
24463
24526
|
`${func.name}: ${offset.toString(16)} ${offset - func.offset}`
|
|
@@ -24466,7 +24529,7 @@ function optimizeBytecode(context) {
|
|
|
24466
24529
|
});
|
|
24467
24530
|
const { offsetMap } = updateInfo;
|
|
24468
24531
|
offsetMap.set(code.byteLength, offset);
|
|
24469
|
-
(0,
|
|
24532
|
+
(0, import_chunk_67LU4GPQ.logger)(
|
|
24470
24533
|
"bytecode",
|
|
24471
24534
|
1,
|
|
24472
24535
|
`${context.filepath}: code size: ${context.sections[
|
|
@@ -24478,9 +24541,9 @@ function optimizeBytecode(context) {
|
|
|
24478
24541
|
].length - offset}`
|
|
24479
24542
|
);
|
|
24480
24543
|
fixSectionSize(-1059145026, context.sections, offset);
|
|
24481
|
-
if ((0,
|
|
24544
|
+
if ((0, import_chunk_67LU4GPQ.wouldLog)("list-output", 1)) {
|
|
24482
24545
|
forEachFunction(
|
|
24483
|
-
(func) => (0,
|
|
24546
|
+
(func) => (0, import_chunk_67LU4GPQ.wouldLog)("list-output", 1) && printFunction(func, context)
|
|
24484
24547
|
);
|
|
24485
24548
|
}
|
|
24486
24549
|
fixupHeader(context, updateInfo);
|
|
@@ -24570,7 +24633,7 @@ ${functionToString(
|
|
|
24570
24633
|
---------------- ${func.name} ----------------`;
|
|
24571
24634
|
}
|
|
24572
24635
|
function printFunction(func, context) {
|
|
24573
|
-
(0,
|
|
24636
|
+
(0, import_chunk_67LU4GPQ.log)(functionToString(func, context));
|
|
24574
24637
|
}
|
|
24575
24638
|
function functionToString(func, context, extra) {
|
|
24576
24639
|
const parts = [];
|
|
@@ -25001,7 +25064,7 @@ var init_bytecode = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
25001
25064
|
"use strict";
|
|
25002
25065
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
25003
25066
|
init_sdk_util();
|
|
25004
|
-
(0,
|
|
25067
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
25005
25068
|
init_data();
|
|
25006
25069
|
init_emit();
|
|
25007
25070
|
init_exceptions();
|
|
@@ -25287,10 +25350,10 @@ async function build_project(product, options, lineCallback) {
|
|
|
25287
25350
|
].flat();
|
|
25288
25351
|
if (!returnCommand) {
|
|
25289
25352
|
const handlers = [
|
|
25290
|
-
lineCallback || ((line) => (0,
|
|
25353
|
+
lineCallback || ((line) => (0, import_chunk_67LU4GPQ.log)(line)),
|
|
25291
25354
|
(line) => console.error(line)
|
|
25292
25355
|
];
|
|
25293
|
-
await (0,
|
|
25356
|
+
await (0, import_chunk_67LU4GPQ.spawnByLine)(exe, args, handlers, {
|
|
25294
25357
|
cwd: workspace
|
|
25295
25358
|
});
|
|
25296
25359
|
}
|
|
@@ -25300,7 +25363,7 @@ var init_build = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
25300
25363
|
"src/build.ts"() {
|
|
25301
25364
|
"use strict";
|
|
25302
25365
|
init_sdk_util();
|
|
25303
|
-
(0,
|
|
25366
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
25304
25367
|
}
|
|
25305
25368
|
});
|
|
25306
25369
|
var require_ms = (0, import_chunk_ABYVSU2C.__commonJS)({
|
|
@@ -28267,7 +28330,7 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
|
|
|
28267
28330
|
);
|
|
28268
28331
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(cache.resolvedPaths, resolved)) {
|
|
28269
28332
|
if (/[*?[\]{}]/.test(resolved)) {
|
|
28270
|
-
cache.resolvedPaths[resolved] = (0,
|
|
28333
|
+
cache.resolvedPaths[resolved] = (0, import_chunk_67LU4GPQ.globSome)(resolved, () => true);
|
|
28271
28334
|
} else {
|
|
28272
28335
|
cache.resolvedPaths[resolved] = fs5.stat(resolved).then(
|
|
28273
28336
|
() => true,
|
|
@@ -28345,12 +28408,12 @@ async function read_resource_files(targets, cache) {
|
|
|
28345
28408
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(resourceGroupPromises, key)) {
|
|
28346
28409
|
resourceGroupPromises[key] = Promise.all(
|
|
28347
28410
|
p.qualifier.resourcePath.map(
|
|
28348
|
-
(pattern) => (0,
|
|
28411
|
+
(pattern) => (0, import_chunk_67LU4GPQ.globa)(pattern, { mark: true })
|
|
28349
28412
|
)
|
|
28350
28413
|
).then(
|
|
28351
28414
|
(patterns) => Promise.all(
|
|
28352
28415
|
patterns.flat().map(
|
|
28353
|
-
(path7) => path7.endsWith("/") ? (0,
|
|
28416
|
+
(path7) => path7.endsWith("/") ? (0, import_chunk_67LU4GPQ.globa)(`${path7}**/*.xml`, { mark: true }) : path7
|
|
28354
28417
|
)
|
|
28355
28418
|
)
|
|
28356
28419
|
).then(
|
|
@@ -28410,7 +28473,7 @@ async function find_build_instructions_in_resource(file, rez, buildDependencies)
|
|
|
28410
28473
|
const sourceExcludes = excludes.map((e) => e.file?.value.value).filter((f) => f != null).map((f) => path2.resolve(dir, f).replace(/\\/g, "/"));
|
|
28411
28474
|
const filePatterns = excludes.map((e) => e.dir?.value.value).filter((f) => f != null).map((f) => path2.join(dir, f, "**", "*.mc").replace(/\\/g, "/"));
|
|
28412
28475
|
if (filePatterns.length) {
|
|
28413
|
-
const files = (await Promise.all(filePatterns.map((p) => (0,
|
|
28476
|
+
const files = (await Promise.all(filePatterns.map((p) => (0, import_chunk_67LU4GPQ.globa)(p)))).flat();
|
|
28414
28477
|
sourceExcludes.push(...files);
|
|
28415
28478
|
}
|
|
28416
28479
|
const excludeAnnotations = excludes.map((e) => e.annotation?.value.value).filter((f) => f != null);
|
|
@@ -28587,15 +28650,15 @@ function identify_optimizer_groups(targets, options) {
|
|
|
28587
28650
|
function find_barrels(barrelPath) {
|
|
28588
28651
|
if (Array.isArray(barrelPath)) {
|
|
28589
28652
|
return Promise.all(
|
|
28590
|
-
barrelPath.map((path7) => (0,
|
|
28653
|
+
barrelPath.map((path7) => (0, import_chunk_67LU4GPQ.globa)(path7, { mark: true }))
|
|
28591
28654
|
).then((paths) => [
|
|
28592
28655
|
paths.flat().filter((path7) => path7.endsWith(".jungle")).join(";")
|
|
28593
28656
|
]);
|
|
28594
28657
|
}
|
|
28595
|
-
return (0,
|
|
28658
|
+
return (0, import_chunk_67LU4GPQ.globa)(barrelPath, { mark: true }).then(
|
|
28596
28659
|
(paths) => Promise.all(
|
|
28597
28660
|
paths.map(
|
|
28598
|
-
(path7) => path7.endsWith("/") ? (0,
|
|
28661
|
+
(path7) => path7.endsWith("/") ? (0, import_chunk_67LU4GPQ.globa)(`${path7}**/*.barrel`) : path7
|
|
28599
28662
|
)
|
|
28600
28663
|
)
|
|
28601
28664
|
).then(
|
|
@@ -28606,7 +28669,7 @@ function resolve_barrel(barrel, barrelDir, products, options, cache, buildDepend
|
|
|
28606
28669
|
if ((0, import_chunk_MBTLUWXR.hasProperty)(cache.barrels, barrel)) {
|
|
28607
28670
|
return cache.barrels[barrel];
|
|
28608
28671
|
}
|
|
28609
|
-
let promise = Promise.resolve();
|
|
28672
|
+
let promise = Promise.resolve(null);
|
|
28610
28673
|
let rawBarrel = barrel;
|
|
28611
28674
|
if (barrel.endsWith(".barrel")) {
|
|
28612
28675
|
const sha1 = crypto2.createHash("sha1").update(barrel, "binary").digest("base64").replace(/[/=+]/g, "");
|
|
@@ -28619,9 +28682,9 @@ function resolve_barrel(barrel, barrelDir, products, options, cache, buildDepend
|
|
|
28619
28682
|
() => fs5.stat(localPath).then(
|
|
28620
28683
|
(localStat) => !localStat.isDirectory() || fs5.stat(barrel).then((barrelStat) => localStat.mtimeMs < barrelStat.mtimeMs),
|
|
28621
28684
|
() => true
|
|
28622
|
-
).then(
|
|
28623
|
-
needsUpdate
|
|
28624
|
-
|
|
28685
|
+
).then(
|
|
28686
|
+
(needsUpdate) => needsUpdate ? fs5.rm(localPath, { recursive: true, force: true }).catch(() => null).then(() => (0, import_extract_zip.default)(barrel, { dir: localPath })) : null
|
|
28687
|
+
)
|
|
28625
28688
|
);
|
|
28626
28689
|
}
|
|
28627
28690
|
return promise.then(() => get_jungle_and_barrels(rawBarrel, products, options, cache)).then((result) => {
|
|
@@ -28868,7 +28931,7 @@ var init_jungles = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
28868
28931
|
init_api();
|
|
28869
28932
|
init_manifest();
|
|
28870
28933
|
init_sdk_util();
|
|
28871
|
-
(0,
|
|
28934
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
28872
28935
|
depth = 0;
|
|
28873
28936
|
}
|
|
28874
28937
|
});
|
|
@@ -28896,7 +28959,7 @@ async function launchSimulator(force = true) {
|
|
|
28896
28959
|
await new Promise((r) => setTimeout(r, 200));
|
|
28897
28960
|
}
|
|
28898
28961
|
} catch (e) {
|
|
28899
|
-
(0,
|
|
28962
|
+
(0, import_chunk_67LU4GPQ.log)(e);
|
|
28900
28963
|
}
|
|
28901
28964
|
}
|
|
28902
28965
|
function checkIfSimulatorRunning() {
|
|
@@ -28927,10 +28990,10 @@ function simulateProgram(prg, device, test = false, logger2) {
|
|
|
28927
28990
|
}
|
|
28928
28991
|
}
|
|
28929
28992
|
return getSdkPath().then(
|
|
28930
|
-
(sdk) => (0,
|
|
28993
|
+
(sdk) => (0, import_chunk_67LU4GPQ.spawnByLine)(
|
|
28931
28994
|
path3.resolve(sdk, "bin", isWin ? "monkeydo.bat" : "monkeydo"),
|
|
28932
28995
|
args,
|
|
28933
|
-
logger2 || ((line) => (0,
|
|
28996
|
+
logger2 || ((line) => (0, import_chunk_67LU4GPQ.log)(line))
|
|
28934
28997
|
).then(() => {
|
|
28935
28998
|
return;
|
|
28936
28999
|
})
|
|
@@ -28940,7 +29003,7 @@ var init_launch = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
28940
29003
|
"src/launch.ts"() {
|
|
28941
29004
|
"use strict";
|
|
28942
29005
|
init_sdk_util();
|
|
28943
|
-
(0,
|
|
29006
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
28944
29007
|
}
|
|
28945
29008
|
});
|
|
28946
29009
|
function relative_path_no_dotdot(relative2) {
|
|
@@ -28961,7 +29024,7 @@ async function getCodeWorkspaceSettings(folder) {
|
|
|
28961
29024
|
let curDir = folder;
|
|
28962
29025
|
try {
|
|
28963
29026
|
while (curDir) {
|
|
28964
|
-
const code_workspaces = await (0,
|
|
29027
|
+
const code_workspaces = await (0, import_chunk_67LU4GPQ.globa)(
|
|
28965
29028
|
path4.resolve(curDir, "*.code-workspace"),
|
|
28966
29029
|
{ onlyFiles: true }
|
|
28967
29030
|
);
|
|
@@ -29084,7 +29147,7 @@ async function createLocalBarrels(targets, options) {
|
|
|
29084
29147
|
optBarrelDir
|
|
29085
29148
|
};
|
|
29086
29149
|
return promise2.then(
|
|
29087
|
-
() => (0,
|
|
29150
|
+
() => (0, import_chunk_67LU4GPQ.copyRecursiveAsNeeded)(
|
|
29088
29151
|
rawBarrelDir,
|
|
29089
29152
|
optBarrelDir,
|
|
29090
29153
|
(src) => !src.endsWith(".mc")
|
|
@@ -29386,11 +29449,11 @@ async function generateOptimizedProject(options) {
|
|
|
29386
29449
|
}
|
|
29387
29450
|
async function filesFromPaths(workspace, paths, extension) {
|
|
29388
29451
|
paths = (await Promise.all(
|
|
29389
|
-
paths?.map((pattern) => (0,
|
|
29452
|
+
paths?.map((pattern) => (0, import_chunk_67LU4GPQ.globa)(pattern, { cwd: workspace, mark: true })) || []
|
|
29390
29453
|
)).flat();
|
|
29391
29454
|
const files = await Promise.all(
|
|
29392
29455
|
paths.map(
|
|
29393
|
-
(path7) => path7.endsWith("/") ? (0,
|
|
29456
|
+
(path7) => path7.endsWith("/") ? (0, import_chunk_67LU4GPQ.globa)(`${path7}**/*${extension}`, { cwd: workspace, mark: true }) : path7
|
|
29394
29457
|
)
|
|
29395
29458
|
);
|
|
29396
29459
|
return {
|
|
@@ -29500,7 +29563,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29500
29563
|
})
|
|
29501
29564
|
);
|
|
29502
29565
|
}
|
|
29503
|
-
const actualOptimizedFiles = (await (0,
|
|
29566
|
+
const actualOptimizedFiles = (await (0, import_chunk_67LU4GPQ.globa)(path4.join(output, "**", "*.mc"), { mark: true })).filter((file) => !file.endsWith("/")).sort();
|
|
29504
29567
|
const {
|
|
29505
29568
|
hasTests,
|
|
29506
29569
|
diagnostics: prevDiagnostics,
|
|
@@ -29516,13 +29579,13 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29516
29579
|
const sdk = await getSdkPath();
|
|
29517
29580
|
const match = sdk.match(/-(\d+\.\d+\.\d+)/);
|
|
29518
29581
|
if ((match && parseSdkVersion(match[1])) === prevSdkVersion) {
|
|
29519
|
-
const source_time = await (0,
|
|
29582
|
+
const source_time = await (0, import_chunk_67LU4GPQ.last_modified)(
|
|
29520
29583
|
Object.keys(fnMap).concat(dependencyFiles)
|
|
29521
29584
|
);
|
|
29522
|
-
const opt_time = await (0,
|
|
29585
|
+
const opt_time = await (0, import_chunk_67LU4GPQ.first_modified)(
|
|
29523
29586
|
Object.values(fnMap).map((v) => v.output)
|
|
29524
29587
|
);
|
|
29525
|
-
if (source_time < opt_time &&
|
|
29588
|
+
if (source_time < opt_time && 1719699536477 < opt_time) {
|
|
29526
29589
|
return {
|
|
29527
29590
|
hasTests,
|
|
29528
29591
|
diagnostics: prevDiagnostics,
|
|
@@ -29561,7 +29624,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29561
29624
|
hasTests: hasTests2,
|
|
29562
29625
|
diagnostics,
|
|
29563
29626
|
sdkVersion,
|
|
29564
|
-
optimizerVersion: "1.1.
|
|
29627
|
+
optimizerVersion: "1.1.66",
|
|
29565
29628
|
...Object.fromEntries(
|
|
29566
29629
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
29567
29630
|
)
|
|
@@ -29575,7 +29638,7 @@ async function getProjectAnalysis(targets, analysis, manifestXML, options) {
|
|
|
29575
29638
|
try {
|
|
29576
29639
|
return getProjectAnalysisHelper(targets, analysis, manifestXML, options);
|
|
29577
29640
|
} catch (ex) {
|
|
29578
|
-
if (ex instanceof
|
|
29641
|
+
if (ex instanceof import_chunk_67LU4GPQ.AwaitedError) {
|
|
29579
29642
|
await ex.resolve();
|
|
29580
29643
|
}
|
|
29581
29644
|
throw ex;
|
|
@@ -29583,13 +29646,17 @@ async function getProjectAnalysis(targets, analysis, manifestXML, options) {
|
|
|
29583
29646
|
}
|
|
29584
29647
|
async function getProjectAnalysisHelper(targets, analysis, manifestXML, options) {
|
|
29585
29648
|
const qualifiers = /* @__PURE__ */ new Map();
|
|
29586
|
-
const addQualifier = (name, qualifier) => {
|
|
29649
|
+
const addQualifier = (name, qualifier, root) => {
|
|
29587
29650
|
const sp = qualifier.sourcePath;
|
|
29588
29651
|
const pp = qualifier.personality;
|
|
29589
29652
|
if (sp || pp) {
|
|
29590
29653
|
let q = qualifiers.get(name);
|
|
29591
29654
|
if (!q) {
|
|
29592
|
-
q = {
|
|
29655
|
+
q = {
|
|
29656
|
+
sourcePath: /* @__PURE__ */ new Set(),
|
|
29657
|
+
personality: /* @__PURE__ */ new Set(),
|
|
29658
|
+
root
|
|
29659
|
+
};
|
|
29593
29660
|
qualifiers.set(name, q);
|
|
29594
29661
|
}
|
|
29595
29662
|
sp?.forEach((s) => q.sourcePath.add(s));
|
|
@@ -29597,10 +29664,10 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
|
|
|
29597
29664
|
}
|
|
29598
29665
|
};
|
|
29599
29666
|
const products = targets.map(({ qualifier, product }) => {
|
|
29600
|
-
addQualifier("", qualifier);
|
|
29667
|
+
addQualifier("", qualifier, options.workspace);
|
|
29601
29668
|
if (qualifier.barrelMap) {
|
|
29602
29669
|
Object.entries(qualifier.barrelMap).forEach(([name, bm]) => {
|
|
29603
|
-
addQualifier(name, bm.qualifier);
|
|
29670
|
+
addQualifier(name, bm.qualifier, path4.dirname(bm.jungles[0]));
|
|
29604
29671
|
});
|
|
29605
29672
|
}
|
|
29606
29673
|
return product;
|
|
@@ -29608,7 +29675,7 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
|
|
|
29608
29675
|
const { fnMap, paths } = await Promise.all(
|
|
29609
29676
|
Array.from(qualifiers).map(
|
|
29610
29677
|
([name, qualifier]) => fileInfoFromConfig(
|
|
29611
|
-
|
|
29678
|
+
qualifier.root,
|
|
29612
29679
|
options.workspace,
|
|
29613
29680
|
{
|
|
29614
29681
|
sourcePath: Array.from(qualifier.sourcePath),
|
|
@@ -29624,7 +29691,7 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
|
|
|
29624
29691
|
if (!cur)
|
|
29625
29692
|
return result;
|
|
29626
29693
|
Object.entries(result.fnMap).forEach(
|
|
29627
|
-
([key, value2]) => cur.fnMap[key] = value2
|
|
29694
|
+
([key, value2]) => cur.fnMap[key] || (cur.fnMap[key] = value2)
|
|
29628
29695
|
);
|
|
29629
29696
|
cur.paths.push(...result.paths);
|
|
29630
29697
|
return cur;
|
|
@@ -29722,7 +29789,7 @@ var init_optimizer = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
29722
29789
|
init_could_be();
|
|
29723
29790
|
init_interp();
|
|
29724
29791
|
init_sub_type();
|
|
29725
|
-
(0,
|
|
29792
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
29726
29793
|
init_worker_pool();
|
|
29727
29794
|
init_optimizer_types();
|
|
29728
29795
|
init_types();
|
|
@@ -29782,7 +29849,7 @@ async function performTask(task) {
|
|
|
29782
29849
|
throw new Error(`Invalid task type ${type}`);
|
|
29783
29850
|
}
|
|
29784
29851
|
return Promise.resolve(handler(task.data)).then(
|
|
29785
|
-
(result) =>
|
|
29852
|
+
(result) => import_chunk_67LU4GPQ.logPromise.then(() => result)
|
|
29786
29853
|
);
|
|
29787
29854
|
}
|
|
29788
29855
|
var workerTaskHandlers;
|
|
@@ -29792,7 +29859,7 @@ var init_worker_task = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
29792
29859
|
init_optimizer();
|
|
29793
29860
|
init_readprg();
|
|
29794
29861
|
init_sdk_util();
|
|
29795
|
-
(0,
|
|
29862
|
+
(0, import_chunk_67LU4GPQ.init_logger)();
|
|
29796
29863
|
workerTaskHandlers = {
|
|
29797
29864
|
buildOptimizedProject(data) {
|
|
29798
29865
|
return buildOptimizedProject(data.product, data.options);
|
|
@@ -30009,7 +30076,7 @@ async function optimizeProgram(filepath, devKey, output, config) {
|
|
|
30009
30076
|
}
|
|
30010
30077
|
function optimizeProgramBuffer(filepath, view, debugXml, apiDebugXml, key, config) {
|
|
30011
30078
|
const { sections } = readPrgWithOffsets(view);
|
|
30012
|
-
(0,
|
|
30079
|
+
(0, import_chunk_67LU4GPQ.logger)("readprg", 5, sections);
|
|
30013
30080
|
const symbolTable = new SymbolTable();
|
|
30014
30081
|
if ((0, import_chunk_MBTLUWXR.hasProperty)(sections, 1461170197 .toString())) {
|
|
30015
30082
|
symbolTable.parse(sections[
|
|
@@ -30309,7 +30376,7 @@ var init_readprg = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
30309
30376
|
init_signer();
|
|
30310
30377
|
init_symbols();
|
|
30311
30378
|
init_sdk_util();
|
|
30312
|
-
(0,
|
|
30379
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
30313
30380
|
init_worker_pool();
|
|
30314
30381
|
}
|
|
30315
30382
|
});
|
|
@@ -30321,7 +30388,7 @@ function getSdkPath() {
|
|
|
30321
30388
|
});
|
|
30322
30389
|
}
|
|
30323
30390
|
async function getDeviceInfo() {
|
|
30324
|
-
const files = await (0,
|
|
30391
|
+
const files = await (0, import_chunk_67LU4GPQ.globa)(`${connectiq}/Devices/*/compiler.json`);
|
|
30325
30392
|
if (!files.length) {
|
|
30326
30393
|
throw new Error(
|
|
30327
30394
|
`No devices found at '${connectiq}/Devices'. Check your sdk is correctly installed`
|
|
@@ -30389,7 +30456,7 @@ async function getFunctionDocumentation() {
|
|
|
30389
30456
|
var isWin, appSupport, connectiq;
|
|
30390
30457
|
var init_sdk_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
30391
30458
|
"src/sdk-util.ts"() {
|
|
30392
|
-
(0,
|
|
30459
|
+
(0, import_chunk_67LU4GPQ.init_util)();
|
|
30393
30460
|
init_xml_util();
|
|
30394
30461
|
init_readprg();
|
|
30395
30462
|
init_bytecode();
|