@markw65/monkeyc-optimizer 1.1.22 → 1.1.24
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/README.md +19 -0
- package/build/api.cjs +34 -34
- package/build/{chunk-563GVBVT.cjs → chunk-3HVXWNU4.cjs} +1435 -452
- package/build/{chunk-HHQDDCTP.cjs → chunk-QFQPBQSO.cjs} +4 -4
- package/build/optimizer.cjs +19 -19
- package/build/sdk-util.cjs +15 -15
- package/build/src/optimizer-types.d.ts +1 -0
- package/build/src/readprg/bytecode.d.ts +3 -1
- package/build/src/readprg/cflow.d.ts +2 -1
- package/build/src/readprg/emit.d.ts +10 -1
- package/build/src/readprg/interp.d.ts +1 -0
- package/build/src/readprg/opcodes.d.ts +18 -2
- package/build/src/readprg/pre.d.ts +2 -0
- package/build/src/readprg/symbols.d.ts +1 -0
- package/build/src/type-flow/interp.d.ts +1 -0
- package/build/util.cjs +24 -24
- package/build/worker-thread.cjs +5 -5
- package/package.json +1 -1
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_QFQPBQSO_exports = {};
|
|
30
|
+
__export(chunk_QFQPBQSO_exports, {
|
|
31
31
|
GenericQueue: () => GenericQueue,
|
|
32
32
|
__commonJS: () => __commonJS,
|
|
33
33
|
__esm: () => __esm,
|
|
@@ -58,7 +58,7 @@ __export(chunk_HHQDDCTP_exports, {
|
|
|
58
58
|
spawnByLine: () => spawnByLine,
|
|
59
59
|
wouldLog: () => wouldLog
|
|
60
60
|
});
|
|
61
|
-
module.exports = __toCommonJS(
|
|
61
|
+
module.exports = __toCommonJS(chunk_QFQPBQSO_exports);
|
|
62
62
|
var child_process = __toESM(require("child_process"));
|
|
63
63
|
var fsc = __toESM(require("fs"));
|
|
64
64
|
var fs = __toESM(require("fs/promises"));
|
|
@@ -5455,7 +5455,7 @@ var require_priorityqueuejs = __commonJS({
|
|
|
5455
5455
|
});
|
|
5456
5456
|
function logger(module2, level, message) {
|
|
5457
5457
|
if (wouldLog(module2, level)) {
|
|
5458
|
-
log(message);
|
|
5458
|
+
log(typeof message === "function" ? message() : message);
|
|
5459
5459
|
}
|
|
5460
5460
|
}
|
|
5461
5461
|
function wouldLog(module2, level) {
|
package/build/optimizer.cjs
CHANGED
|
@@ -18,27 +18,27 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var optimizer_exports = {};
|
|
20
20
|
__export(optimizer_exports, {
|
|
21
|
-
StateNodeAttributes: () =>
|
|
22
|
-
buildOptimizedProject: () =>
|
|
23
|
-
copyRecursiveAsNeeded: () =>
|
|
24
|
-
defaultConfig: () =>
|
|
25
|
-
display: () =>
|
|
26
|
-
generateApiMirTests: () =>
|
|
27
|
-
generateOneConfig: () =>
|
|
28
|
-
generateOptimizedProject: () =>
|
|
29
|
-
getConfig: () =>
|
|
30
|
-
getProjectAnalysis: () =>
|
|
31
|
-
get_jungle: () =>
|
|
32
|
-
isErrorWithLocation: () =>
|
|
33
|
-
launchSimulator: () =>
|
|
34
|
-
manifestProducts: () =>
|
|
35
|
-
mctree: () =>
|
|
36
|
-
simulateProgram: () =>
|
|
21
|
+
StateNodeAttributes: () => import_chunk_3HVXWNU4.StateNodeAttributes,
|
|
22
|
+
buildOptimizedProject: () => import_chunk_3HVXWNU4.buildOptimizedProject,
|
|
23
|
+
copyRecursiveAsNeeded: () => import_chunk_QFQPBQSO.copyRecursiveAsNeeded,
|
|
24
|
+
defaultConfig: () => import_chunk_3HVXWNU4.defaultConfig,
|
|
25
|
+
display: () => import_chunk_3HVXWNU4.display,
|
|
26
|
+
generateApiMirTests: () => import_chunk_3HVXWNU4.generateApiMirTests,
|
|
27
|
+
generateOneConfig: () => import_chunk_3HVXWNU4.generateOneConfig,
|
|
28
|
+
generateOptimizedProject: () => import_chunk_3HVXWNU4.generateOptimizedProject,
|
|
29
|
+
getConfig: () => import_chunk_3HVXWNU4.getConfig,
|
|
30
|
+
getProjectAnalysis: () => import_chunk_3HVXWNU4.getProjectAnalysis,
|
|
31
|
+
get_jungle: () => import_chunk_3HVXWNU4.get_jungle,
|
|
32
|
+
isErrorWithLocation: () => import_chunk_3HVXWNU4.isErrorWithLocation,
|
|
33
|
+
launchSimulator: () => import_chunk_3HVXWNU4.launchSimulator,
|
|
34
|
+
manifestProducts: () => import_chunk_3HVXWNU4.manifestProducts,
|
|
35
|
+
mctree: () => import_chunk_3HVXWNU4.mctree,
|
|
36
|
+
simulateProgram: () => import_chunk_3HVXWNU4.simulateProgram
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(optimizer_exports);
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
(0,
|
|
39
|
+
var import_chunk_3HVXWNU4 = require("./chunk-3HVXWNU4.cjs");
|
|
40
|
+
var import_chunk_QFQPBQSO = require("./chunk-QFQPBQSO.cjs");
|
|
41
|
+
(0, import_chunk_3HVXWNU4.init_optimizer)();
|
|
42
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
43
|
0 && (module.exports = {
|
|
44
44
|
StateNodeAttributes,
|
package/build/sdk-util.cjs
CHANGED
|
@@ -18,23 +18,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var sdk_util_exports = {};
|
|
20
20
|
__export(sdk_util_exports, {
|
|
21
|
-
SectionKinds: () =>
|
|
22
|
-
appSupport: () =>
|
|
23
|
-
connectiq: () =>
|
|
24
|
-
getDeviceInfo: () =>
|
|
25
|
-
getFunctionDocumentation: () =>
|
|
26
|
-
getLanguages: () =>
|
|
27
|
-
getSdkPath: () =>
|
|
28
|
-
isWin: () =>
|
|
29
|
-
optimizeProgram: () =>
|
|
30
|
-
readPrg: () =>
|
|
31
|
-
readPrgWithOffsets: () =>
|
|
32
|
-
xmlUtil: () =>
|
|
21
|
+
SectionKinds: () => import_chunk_3HVXWNU4.SectionKinds,
|
|
22
|
+
appSupport: () => import_chunk_3HVXWNU4.appSupport,
|
|
23
|
+
connectiq: () => import_chunk_3HVXWNU4.connectiq,
|
|
24
|
+
getDeviceInfo: () => import_chunk_3HVXWNU4.getDeviceInfo,
|
|
25
|
+
getFunctionDocumentation: () => import_chunk_3HVXWNU4.getFunctionDocumentation,
|
|
26
|
+
getLanguages: () => import_chunk_3HVXWNU4.getLanguages,
|
|
27
|
+
getSdkPath: () => import_chunk_3HVXWNU4.getSdkPath,
|
|
28
|
+
isWin: () => import_chunk_3HVXWNU4.isWin,
|
|
29
|
+
optimizeProgram: () => import_chunk_3HVXWNU4.optimizeProgram,
|
|
30
|
+
readPrg: () => import_chunk_3HVXWNU4.readPrg,
|
|
31
|
+
readPrgWithOffsets: () => import_chunk_3HVXWNU4.readPrgWithOffsets,
|
|
32
|
+
xmlUtil: () => import_chunk_3HVXWNU4.xml_util_exports
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(sdk_util_exports);
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
(0,
|
|
35
|
+
var import_chunk_3HVXWNU4 = require("./chunk-3HVXWNU4.cjs");
|
|
36
|
+
var import_chunk_QFQPBQSO = require("./chunk-QFQPBQSO.cjs");
|
|
37
|
+
(0, import_chunk_3HVXWNU4.init_sdk_util)();
|
|
38
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
39
|
0 && (module.exports = {
|
|
40
40
|
SectionKinds,
|
|
@@ -45,6 +45,7 @@ export declare type BuildConfig = {
|
|
|
45
45
|
covarianceWarnings?: boolean;
|
|
46
46
|
checkTypes?: DiagnosticType | "OFF";
|
|
47
47
|
removeArgc?: boolean;
|
|
48
|
+
postBuildPRE?: boolean;
|
|
48
49
|
};
|
|
49
50
|
export declare type StateNodeDecl = StateNode | mctree.EnumStringMember | mctree.TypedIdentifier;
|
|
50
51
|
export declare type StateNodeDecls = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as crypto from "node:crypto";
|
|
3
|
-
import { BuildConfig } from "
|
|
3
|
+
import { BuildConfig } from "../optimizer-types";
|
|
4
4
|
import { xmlUtil } from "../sdk-util";
|
|
5
5
|
import { ExceptionEntry, ExceptionsMap } from "./exceptions";
|
|
6
6
|
import { Header } from "./header";
|
|
@@ -35,6 +35,7 @@ export declare type Context = {
|
|
|
35
35
|
key?: crypto.KeyObject;
|
|
36
36
|
debugXml: xmlUtil.Document;
|
|
37
37
|
nextOffset: number;
|
|
38
|
+
nextLocalId: number;
|
|
38
39
|
};
|
|
39
40
|
export declare type Block = {
|
|
40
41
|
offset: number;
|
|
@@ -48,6 +49,7 @@ export declare type Block = {
|
|
|
48
49
|
export declare type FuncEntry = {
|
|
49
50
|
name?: string;
|
|
50
51
|
offset: number;
|
|
52
|
+
argc?: number;
|
|
51
53
|
blocks: Map<number, Block>;
|
|
52
54
|
};
|
|
53
55
|
export declare function offsetToString(offset: number): string;
|
|
@@ -4,6 +4,7 @@ export declare function postOrderTraverse(func: FuncEntry, visitor: (block: Bloc
|
|
|
4
4
|
export declare function intersect<T>(a: Set<T>, b: Set<T>): Set<T>;
|
|
5
5
|
export declare type DomLike = Map<number, Set<number>>;
|
|
6
6
|
export declare function computePostDominators(func: FuncEntry): DomLike;
|
|
7
|
+
export declare function computeDominators(func: FuncEntry): DomLike;
|
|
7
8
|
export declare function postOrderPropagate<T>(func: FuncEntry, preBlock: (block: Block) => T, processBc: (block: Block, bc: Bytecode, state: T) => void, postBlock: (block: Block, state: T) => void, merge: (state: T, predBlock: Block, isExPred: boolean) => boolean): void;
|
|
8
9
|
export declare enum RpoFlags {
|
|
9
10
|
EnqueueTaken = 1,
|
|
@@ -12,4 +13,4 @@ export declare enum RpoFlags {
|
|
|
12
13
|
SkipNext = 8,
|
|
13
14
|
RestartBlock = 16
|
|
14
15
|
}
|
|
15
|
-
export declare function rpoPropagate<T>(func: FuncEntry, preBlock: (block: Block) => T, processBc: (block: Block, bc: Bytecode, state: T) => RpoFlags | null | undefined | void, postBlock: (block: Block, state: T) => void, merge: (from: Block, state: T,
|
|
16
|
+
export declare function rpoPropagate<T>(func: FuncEntry, preBlock: (block: Block) => T, processBc: ((block: Block, bc: Bytecode, state: T) => RpoFlags | null | undefined | void) | null, postBlock: (block: Block, state: T) => void, merge: (from: Block, state: T, succBlock: Block, isExSucc: boolean) => boolean): void;
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { Context, FuncEntry } from "./bytecode";
|
|
2
2
|
import { ExceptionsMap } from "./exceptions";
|
|
3
3
|
import { LineNumber } from "./linenum";
|
|
4
|
+
declare type LocalXmlInfo = {
|
|
5
|
+
name: string;
|
|
6
|
+
startPc: number;
|
|
7
|
+
endPc: number;
|
|
8
|
+
isParam: boolean;
|
|
9
|
+
slot: number;
|
|
10
|
+
id: number;
|
|
11
|
+
};
|
|
4
12
|
export declare type LocalsMap = Map<number, {
|
|
5
13
|
startPc: number;
|
|
6
14
|
endPc: number;
|
|
7
15
|
}>;
|
|
8
16
|
export declare type UpdateInfo = {
|
|
9
17
|
offsetMap: Map<number, number>;
|
|
10
|
-
|
|
18
|
+
localRanges: LocalXmlInfo[];
|
|
11
19
|
lineMap: LineNumber[];
|
|
12
20
|
exceptionsMap: ExceptionsMap;
|
|
13
21
|
};
|
|
14
22
|
export declare function emitFunc(func: FuncEntry, view: DataView, start: number, updateInfo: UpdateInfo, context: Context): number;
|
|
23
|
+
export {};
|
|
@@ -15,6 +15,7 @@ export declare function interpBytecode(bc: Bytecode, localState: InterpState, co
|
|
|
15
15
|
export declare function interpFunc(func: FuncEntry, context: Context): {
|
|
16
16
|
liveInState: Map<number, InterpState>;
|
|
17
17
|
equivSets: Map<Lputv, Set<number>>;
|
|
18
|
+
changes: number;
|
|
18
19
|
};
|
|
19
20
|
export declare function instForType(type: ExactOrUnion, offset: number): Bytecode | null;
|
|
20
21
|
export {};
|
|
@@ -139,10 +139,18 @@ export interface Agetv extends Argless {
|
|
|
139
139
|
export interface Aputv extends Argless {
|
|
140
140
|
op: Opcodes.aputv;
|
|
141
141
|
}
|
|
142
|
-
export
|
|
142
|
+
export declare type LocalRange = {
|
|
143
|
+
name: string;
|
|
144
|
+
id: number;
|
|
145
|
+
isParam?: true | undefined;
|
|
146
|
+
};
|
|
147
|
+
export interface LocalInst extends ByteArg {
|
|
148
|
+
range?: LocalRange;
|
|
149
|
+
}
|
|
150
|
+
export interface Lgetv extends LocalInst {
|
|
143
151
|
op: Opcodes.lgetv;
|
|
144
152
|
}
|
|
145
|
-
export interface Lputv extends
|
|
153
|
+
export interface Lputv extends LocalInst {
|
|
146
154
|
op: Opcodes.lputv;
|
|
147
155
|
}
|
|
148
156
|
export interface Newa extends Argless {
|
|
@@ -258,6 +266,14 @@ export declare function getOpInfo(bytecode: Bytecode): {
|
|
|
258
266
|
pop: number;
|
|
259
267
|
push: number;
|
|
260
268
|
};
|
|
269
|
+
export declare const enum Effects {
|
|
270
|
+
None = 0,
|
|
271
|
+
Local = 1,
|
|
272
|
+
Global = 2,
|
|
273
|
+
ArrayLike = 4,
|
|
274
|
+
Call = 8
|
|
275
|
+
}
|
|
276
|
+
export declare function getOpEffects(bytecode: Bytecode): number;
|
|
261
277
|
export declare function isBoolOp(op: Opcodes): boolean;
|
|
262
278
|
export declare function isCondBranch(op: Opcodes): boolean;
|
|
263
279
|
export {};
|
|
@@ -23,6 +23,7 @@ export declare function evaluateExpr(state: ProgramStateAnalysis, expr: mctree.E
|
|
|
23
23
|
export declare function preEvaluate(istate: InterpState, node: mctree.Node): null | (keyof mctree.NodeAll)[];
|
|
24
24
|
export declare function evaluate(istate: InterpState, node: mctree.Expression): InterpStackElem;
|
|
25
25
|
export declare function evaluate(istate: InterpState, node: mctree.Node): InterpStackElem | undefined;
|
|
26
|
+
export declare function evaluateUnaryTypes(op: mctree.UnaryOperator, argument: ExactOrUnion): ExactOrUnion;
|
|
26
27
|
export declare function deEnumerate(t: ExactOrUnion): ExactOrUnion;
|
|
27
28
|
export declare function evaluateNode(istate: InterpState, node: mctree.Node): void;
|
|
28
29
|
export declare function roundToFloat(value: number): number;
|
package/build/util.cjs
CHANGED
|
@@ -18,32 +18,32 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var util_exports = {};
|
|
20
20
|
__export(util_exports, {
|
|
21
|
-
GenericQueue: () =>
|
|
22
|
-
bumpLogging: () =>
|
|
23
|
-
copyRecursiveAsNeeded: () =>
|
|
24
|
-
every: () =>
|
|
25
|
-
first_modified: () =>
|
|
26
|
-
forEach: () =>
|
|
27
|
-
globSome: () =>
|
|
28
|
-
globa: () =>
|
|
29
|
-
last_modified: () =>
|
|
30
|
-
log: () =>
|
|
31
|
-
logger: () =>
|
|
32
|
-
map: () =>
|
|
33
|
-
popcount: () =>
|
|
34
|
-
promiseAll: () =>
|
|
35
|
-
pushUnique: () =>
|
|
36
|
-
readByLine: () =>
|
|
37
|
-
reduce: () =>
|
|
38
|
-
sameArrays: () =>
|
|
39
|
-
setBanner: () =>
|
|
40
|
-
some: () =>
|
|
41
|
-
spawnByLine: () =>
|
|
42
|
-
wouldLog: () =>
|
|
21
|
+
GenericQueue: () => import_chunk_QFQPBQSO.GenericQueue,
|
|
22
|
+
bumpLogging: () => import_chunk_QFQPBQSO.bumpLogging,
|
|
23
|
+
copyRecursiveAsNeeded: () => import_chunk_QFQPBQSO.copyRecursiveAsNeeded,
|
|
24
|
+
every: () => import_chunk_QFQPBQSO.every,
|
|
25
|
+
first_modified: () => import_chunk_QFQPBQSO.first_modified,
|
|
26
|
+
forEach: () => import_chunk_QFQPBQSO.forEach,
|
|
27
|
+
globSome: () => import_chunk_QFQPBQSO.globSome,
|
|
28
|
+
globa: () => import_chunk_QFQPBQSO.globa,
|
|
29
|
+
last_modified: () => import_chunk_QFQPBQSO.last_modified,
|
|
30
|
+
log: () => import_chunk_QFQPBQSO.log,
|
|
31
|
+
logger: () => import_chunk_QFQPBQSO.logger,
|
|
32
|
+
map: () => import_chunk_QFQPBQSO.map,
|
|
33
|
+
popcount: () => import_chunk_QFQPBQSO.popcount,
|
|
34
|
+
promiseAll: () => import_chunk_QFQPBQSO.promiseAll,
|
|
35
|
+
pushUnique: () => import_chunk_QFQPBQSO.pushUnique,
|
|
36
|
+
readByLine: () => import_chunk_QFQPBQSO.readByLine,
|
|
37
|
+
reduce: () => import_chunk_QFQPBQSO.reduce,
|
|
38
|
+
sameArrays: () => import_chunk_QFQPBQSO.sameArrays,
|
|
39
|
+
setBanner: () => import_chunk_QFQPBQSO.setBanner,
|
|
40
|
+
some: () => import_chunk_QFQPBQSO.some,
|
|
41
|
+
spawnByLine: () => import_chunk_QFQPBQSO.spawnByLine,
|
|
42
|
+
wouldLog: () => import_chunk_QFQPBQSO.wouldLog
|
|
43
43
|
});
|
|
44
44
|
module.exports = __toCommonJS(util_exports);
|
|
45
|
-
var
|
|
46
|
-
(0,
|
|
45
|
+
var import_chunk_QFQPBQSO = require("./chunk-QFQPBQSO.cjs");
|
|
46
|
+
(0, import_chunk_QFQPBQSO.init_util)();
|
|
47
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
48
|
0 && (module.exports = {
|
|
49
49
|
GenericQueue,
|
package/build/worker-thread.cjs
CHANGED
|
@@ -21,15 +21,15 @@ __export(worker_thread_exports, {
|
|
|
21
21
|
default: () => worker_thread_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(worker_thread_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
24
|
+
var import_chunk_3HVXWNU4 = require("./chunk-3HVXWNU4.cjs");
|
|
25
|
+
var import_chunk_QFQPBQSO = require("./chunk-QFQPBQSO.cjs");
|
|
26
26
|
var import_node_worker_threads = require("node:worker_threads");
|
|
27
|
-
var require_worker_thread = (0,
|
|
27
|
+
var require_worker_thread = (0, import_chunk_QFQPBQSO.__commonJS)({
|
|
28
28
|
"src/worker-thread.ts"() {
|
|
29
|
-
(0,
|
|
29
|
+
(0, import_chunk_3HVXWNU4.init_worker_task)();
|
|
30
30
|
if (import_node_worker_threads.parentPort) {
|
|
31
31
|
import_node_worker_threads.parentPort.on("message", async (task) => {
|
|
32
|
-
return import_node_worker_threads.parentPort.postMessage(await (0,
|
|
32
|
+
return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_3HVXWNU4.performTask)(task));
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
}
|
package/package.json
CHANGED