@markw65/monkeyc-optimizer 1.1.18 → 1.1.19
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 +13 -0
- package/build/api.cjs +33 -33
- package/build/{chunk-YCLY27QH.cjs → chunk-O5LFMOIG.cjs} +27110 -22060
- package/build/optimizer.cjs +17 -18
- package/build/sdk-util.cjs +14 -14
- package/build/src/readprg/array-init.d.ts +1 -1
- package/build/src/readprg/bytecode.d.ts +3 -0
- package/build/src/readprg/cflow.d.ts +5 -0
- package/build/src/readprg/header.d.ts +15 -0
- package/build/src/readprg/switch.d.ts +5 -0
- package/build/src/readprg.d.ts +9 -0
- package/build/src/worker-task.d.ts +26 -1
- package/build/worker-pool.cjs +5 -6
- package/build/worker-thread.cjs +3 -4
- package/package.json +1 -1
- package/build/chunk-TM6GLTGC.cjs +0 -4858
package/build/optimizer.cjs
CHANGED
|
@@ -18,28 +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: () =>
|
|
21
|
+
StateNodeAttributes: () => import_chunk_O5LFMOIG.StateNodeAttributes,
|
|
22
|
+
buildOptimizedProject: () => import_chunk_O5LFMOIG.buildOptimizedProject,
|
|
23
23
|
copyRecursiveAsNeeded: () => import_chunk_IAUHYWVN.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: () =>
|
|
24
|
+
defaultConfig: () => import_chunk_O5LFMOIG.defaultConfig,
|
|
25
|
+
display: () => import_chunk_O5LFMOIG.display,
|
|
26
|
+
generateApiMirTests: () => import_chunk_O5LFMOIG.generateApiMirTests,
|
|
27
|
+
generateOneConfig: () => import_chunk_O5LFMOIG.generateOneConfig,
|
|
28
|
+
generateOptimizedProject: () => import_chunk_O5LFMOIG.generateOptimizedProject,
|
|
29
|
+
getConfig: () => import_chunk_O5LFMOIG.getConfig,
|
|
30
|
+
getProjectAnalysis: () => import_chunk_O5LFMOIG.getProjectAnalysis,
|
|
31
|
+
get_jungle: () => import_chunk_O5LFMOIG.get_jungle,
|
|
32
|
+
isErrorWithLocation: () => import_chunk_O5LFMOIG.isErrorWithLocation,
|
|
33
|
+
launchSimulator: () => import_chunk_O5LFMOIG.launchSimulator,
|
|
34
|
+
manifestProducts: () => import_chunk_O5LFMOIG.manifestProducts,
|
|
35
|
+
mctree: () => import_chunk_O5LFMOIG.mctree,
|
|
36
|
+
simulateProgram: () => import_chunk_O5LFMOIG.simulateProgram
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(optimizer_exports);
|
|
39
|
-
var
|
|
40
|
-
var import_chunk_YCLY27QH = require("./chunk-YCLY27QH.cjs");
|
|
39
|
+
var import_chunk_O5LFMOIG = require("./chunk-O5LFMOIG.cjs");
|
|
41
40
|
var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
|
|
42
|
-
(0,
|
|
41
|
+
(0, import_chunk_O5LFMOIG.init_optimizer)();
|
|
43
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
43
|
0 && (module.exports = {
|
|
45
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_O5LFMOIG.SectionKinds,
|
|
22
|
+
appSupport: () => import_chunk_O5LFMOIG.appSupport,
|
|
23
|
+
connectiq: () => import_chunk_O5LFMOIG.connectiq,
|
|
24
|
+
getDeviceInfo: () => import_chunk_O5LFMOIG.getDeviceInfo,
|
|
25
|
+
getFunctionDocumentation: () => import_chunk_O5LFMOIG.getFunctionDocumentation,
|
|
26
|
+
getLanguages: () => import_chunk_O5LFMOIG.getLanguages,
|
|
27
|
+
getSdkPath: () => import_chunk_O5LFMOIG.getSdkPath,
|
|
28
|
+
isWin: () => import_chunk_O5LFMOIG.isWin,
|
|
29
|
+
optimizeProgram: () => import_chunk_O5LFMOIG.optimizeProgram,
|
|
30
|
+
readPrg: () => import_chunk_O5LFMOIG.readPrg,
|
|
31
|
+
readPrgWithOffsets: () => import_chunk_O5LFMOIG.readPrgWithOffsets,
|
|
32
|
+
xmlUtil: () => import_chunk_O5LFMOIG.xml_util_exports
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(sdk_util_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_chunk_O5LFMOIG = require("./chunk-O5LFMOIG.cjs");
|
|
36
36
|
var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
|
|
37
|
-
(0,
|
|
37
|
+
(0, import_chunk_O5LFMOIG.init_sdk_util)();
|
|
38
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
39
|
0 && (module.exports = {
|
|
40
40
|
SectionKinds,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Block, Context, FuncEntry } from "./bytecode";
|
|
2
|
-
export declare function optimizeArrayInit(func: FuncEntry, block: Block, index: number, context: Context): boolean;
|
|
2
|
+
export declare function optimizeArrayInit(func: FuncEntry, block: Block, index: number, stackPreserving: boolean, context: Context): boolean;
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import * as crypto from "node:crypto";
|
|
3
3
|
import { xmlUtil } from "../sdk-util";
|
|
4
4
|
import { ExceptionEntry, ExceptionsMap } from "./exceptions";
|
|
5
|
+
import { Header } from "./header";
|
|
5
6
|
import { LineNumber } from "./linenum";
|
|
6
7
|
import { Bytecode, Opcodes } from "./opcodes";
|
|
7
8
|
import { SymbolTable } from "./symbols";
|
|
8
9
|
export declare const enum SectionKinds {
|
|
10
|
+
HEADER = -805253120,
|
|
9
11
|
TEXT = -1059145026,
|
|
10
12
|
DATA = -629491010,
|
|
11
13
|
SYMBOLS = 1461170197,
|
|
@@ -23,6 +25,7 @@ export declare type Logger = (module: string, level: number, message: string) =>
|
|
|
23
25
|
export declare type Context = {
|
|
24
26
|
filepath: string;
|
|
25
27
|
sections: Record<number, SectionInfo>;
|
|
28
|
+
header: Header;
|
|
26
29
|
symbolTable: SymbolTable;
|
|
27
30
|
lineTable: Map<number, LineNumber>;
|
|
28
31
|
exceptionsMap: ExceptionsMap;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Block, FuncEntry } from "./bytecode";
|
|
2
|
+
export declare function postOrderTraverse(func: FuncEntry, visitor: (block: Block) => void): void;
|
|
3
|
+
export declare function intersect<T>(a: Set<T>, b: Set<T>): Set<T>;
|
|
4
|
+
export declare type DomLike = Map<number, Set<number>>;
|
|
5
|
+
export declare function computePostDominators(func: FuncEntry): DomLike;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Context } from "./bytecode";
|
|
2
|
+
import { UpdateInfo } from "./emit";
|
|
3
|
+
export declare type SectionOffset = {
|
|
4
|
+
data: number;
|
|
5
|
+
code: number;
|
|
6
|
+
};
|
|
7
|
+
export declare type Header = {
|
|
8
|
+
ciqVersion: number;
|
|
9
|
+
backgroundOffsets: SectionOffset;
|
|
10
|
+
appLock: boolean;
|
|
11
|
+
glanceOffsets: SectionOffset;
|
|
12
|
+
flags: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function parseHeader(view: DataView): Header;
|
|
15
|
+
export declare function fixupHeader(context: Context, updateInfo: UpdateInfo): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Block, FuncEntry } from "./bytecode";
|
|
2
|
+
export declare function isSwitchLike(func: FuncEntry, block: Block, index: number): false | {
|
|
3
|
+
xpush: import("./opcodes").Ipush | import("./opcodes").Fpush | import("./opcodes").Spush | import("./opcodes").Bpush | import("./opcodes").Lpush | import("./opcodes").Dpush | import("./opcodes").Cpush;
|
|
4
|
+
index: number;
|
|
5
|
+
};
|
package/build/src/readprg.d.ts
CHANGED
|
@@ -19,3 +19,12 @@ export declare function optimizeProgramBuffer(filepath: string, view: DataView,
|
|
|
19
19
|
signature: Buffer | undefined;
|
|
20
20
|
buffer: Buffer;
|
|
21
21
|
};
|
|
22
|
+
export declare function optimizePrgAndDebug(prgName: string, prgBuffer: ArrayBuffer, prgOffset: number, prgLength: number, xmlName: string, xmlBuffer: ArrayBuffer, xmlOffset: number, xmlLength: number, key: crypto.KeyObject): Promise<{
|
|
23
|
+
sigBuffer: ArrayBufferLike | undefined;
|
|
24
|
+
sigOffset: number | undefined;
|
|
25
|
+
sigLength: number | undefined;
|
|
26
|
+
prgBuffer: ArrayBufferLike;
|
|
27
|
+
prgOffset: number;
|
|
28
|
+
prgLength: number;
|
|
29
|
+
debugXml: string;
|
|
30
|
+
}>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as crypto from "node:crypto";
|
|
1
3
|
import { JungleQualifier } from "./jungles";
|
|
2
4
|
import { BuildConfig } from "./optimizer";
|
|
3
5
|
import { xmlUtil } from "./sdk-util";
|
|
@@ -27,7 +29,21 @@ interface GenerateOptimizedProject extends BaseNode {
|
|
|
27
29
|
options: BuildConfig;
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
|
-
|
|
32
|
+
interface OptimizePrgAndDebug extends BaseNode {
|
|
33
|
+
type: "optimizePrgAndDebug";
|
|
34
|
+
data: {
|
|
35
|
+
prgName: string;
|
|
36
|
+
prgBuffer: ArrayBuffer;
|
|
37
|
+
prgOffset: number;
|
|
38
|
+
prgLength: number;
|
|
39
|
+
xmlName: string;
|
|
40
|
+
xmlBuffer: ArrayBuffer;
|
|
41
|
+
xmlOffset: number;
|
|
42
|
+
xmlLength: number;
|
|
43
|
+
key: crypto.KeyObject;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export declare type WorkerTask = BuildOptimizedProject | GenerateOptimizedProject | GenerateOneConfig | OptimizePrgAndDebug;
|
|
31
47
|
export declare const workerTaskHandlers: {
|
|
32
48
|
readonly buildOptimizedProject: (data: BuildOptimizedProject["data"]) => Promise<{
|
|
33
49
|
exe: string;
|
|
@@ -54,6 +70,15 @@ export declare const workerTaskHandlers: {
|
|
|
54
70
|
hasTests: boolean;
|
|
55
71
|
diagnostics: Record<string, import("./optimizer-types").Diagnostic[]> | undefined;
|
|
56
72
|
}>;
|
|
73
|
+
readonly optimizePrgAndDebug: (data: OptimizePrgAndDebug["data"]) => Promise<{
|
|
74
|
+
sigBuffer: ArrayBufferLike | undefined;
|
|
75
|
+
sigOffset: number | undefined;
|
|
76
|
+
sigLength: number | undefined;
|
|
77
|
+
prgBuffer: ArrayBufferLike;
|
|
78
|
+
prgOffset: number;
|
|
79
|
+
prgLength: number;
|
|
80
|
+
debugXml: string;
|
|
81
|
+
}>;
|
|
57
82
|
};
|
|
58
83
|
declare type RemovePromise<T> = T extends Promise<infer U> ? U : T;
|
|
59
84
|
export declare type WorkerTaskResult<T> = T extends WorkerTask ? RemovePromise<ReturnType<typeof workerTaskHandlers[T["type"]]>> : never;
|
package/build/worker-pool.cjs
CHANGED
|
@@ -18,15 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var worker_pool_exports = {};
|
|
20
20
|
__export(worker_pool_exports, {
|
|
21
|
-
runTaskInPool: () =>
|
|
22
|
-
startPool: () =>
|
|
23
|
-
stopPool: () =>
|
|
21
|
+
runTaskInPool: () => import_chunk_O5LFMOIG.runTaskInPool,
|
|
22
|
+
startPool: () => import_chunk_O5LFMOIG.startPool,
|
|
23
|
+
stopPool: () => import_chunk_O5LFMOIG.stopPool
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(worker_pool_exports);
|
|
26
|
-
var
|
|
27
|
-
var import_chunk_YCLY27QH = require("./chunk-YCLY27QH.cjs");
|
|
26
|
+
var import_chunk_O5LFMOIG = require("./chunk-O5LFMOIG.cjs");
|
|
28
27
|
var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
|
|
29
|
-
(0,
|
|
28
|
+
(0, import_chunk_O5LFMOIG.init_worker_pool)();
|
|
30
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
30
|
0 && (module.exports = {
|
|
32
31
|
runTaskInPool,
|
package/build/worker-thread.cjs
CHANGED
|
@@ -21,16 +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 import_chunk_YCLY27QH = require("./chunk-YCLY27QH.cjs");
|
|
24
|
+
var import_chunk_O5LFMOIG = require("./chunk-O5LFMOIG.cjs");
|
|
26
25
|
var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
|
|
27
26
|
var import_node_worker_threads = require("node:worker_threads");
|
|
28
27
|
var require_worker_thread = (0, import_chunk_IAUHYWVN.__commonJS)({
|
|
29
28
|
"src/worker-thread.ts"() {
|
|
30
|
-
(0,
|
|
29
|
+
(0, import_chunk_O5LFMOIG.init_worker_task)();
|
|
31
30
|
if (import_node_worker_threads.parentPort) {
|
|
32
31
|
import_node_worker_threads.parentPort.on("message", async (task) => {
|
|
33
|
-
return import_node_worker_threads.parentPort.postMessage(await (0,
|
|
32
|
+
return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_O5LFMOIG.performTask)(task));
|
|
34
33
|
});
|
|
35
34
|
}
|
|
36
35
|
}
|
package/package.json
CHANGED