@markw65/monkeyc-optimizer 1.1.23 → 1.1.25

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.
@@ -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: () => import_chunk_27ZJJM2Y.StateNodeAttributes,
22
- buildOptimizedProject: () => import_chunk_27ZJJM2Y.buildOptimizedProject,
23
- copyRecursiveAsNeeded: () => import_chunk_HHQDDCTP.copyRecursiveAsNeeded,
24
- defaultConfig: () => import_chunk_27ZJJM2Y.defaultConfig,
25
- display: () => import_chunk_27ZJJM2Y.display,
26
- generateApiMirTests: () => import_chunk_27ZJJM2Y.generateApiMirTests,
27
- generateOneConfig: () => import_chunk_27ZJJM2Y.generateOneConfig,
28
- generateOptimizedProject: () => import_chunk_27ZJJM2Y.generateOptimizedProject,
29
- getConfig: () => import_chunk_27ZJJM2Y.getConfig,
30
- getProjectAnalysis: () => import_chunk_27ZJJM2Y.getProjectAnalysis,
31
- get_jungle: () => import_chunk_27ZJJM2Y.get_jungle,
32
- isErrorWithLocation: () => import_chunk_27ZJJM2Y.isErrorWithLocation,
33
- launchSimulator: () => import_chunk_27ZJJM2Y.launchSimulator,
34
- manifestProducts: () => import_chunk_27ZJJM2Y.manifestProducts,
35
- mctree: () => import_chunk_27ZJJM2Y.mctree,
36
- simulateProgram: () => import_chunk_27ZJJM2Y.simulateProgram
21
+ StateNodeAttributes: () => import_chunk_SNWJ2FZL.StateNodeAttributes,
22
+ buildOptimizedProject: () => import_chunk_SNWJ2FZL.buildOptimizedProject,
23
+ copyRecursiveAsNeeded: () => import_chunk_QFQPBQSO.copyRecursiveAsNeeded,
24
+ defaultConfig: () => import_chunk_SNWJ2FZL.defaultConfig,
25
+ display: () => import_chunk_SNWJ2FZL.display,
26
+ generateApiMirTests: () => import_chunk_SNWJ2FZL.generateApiMirTests,
27
+ generateOneConfig: () => import_chunk_SNWJ2FZL.generateOneConfig,
28
+ generateOptimizedProject: () => import_chunk_SNWJ2FZL.generateOptimizedProject,
29
+ getConfig: () => import_chunk_SNWJ2FZL.getConfig,
30
+ getProjectAnalysis: () => import_chunk_SNWJ2FZL.getProjectAnalysis,
31
+ get_jungle: () => import_chunk_SNWJ2FZL.get_jungle,
32
+ isErrorWithLocation: () => import_chunk_SNWJ2FZL.isErrorWithLocation,
33
+ launchSimulator: () => import_chunk_SNWJ2FZL.launchSimulator,
34
+ manifestProducts: () => import_chunk_SNWJ2FZL.manifestProducts,
35
+ mctree: () => import_chunk_SNWJ2FZL.mctree,
36
+ simulateProgram: () => import_chunk_SNWJ2FZL.simulateProgram
37
37
  });
38
38
  module.exports = __toCommonJS(optimizer_exports);
39
- var import_chunk_27ZJJM2Y = require("./chunk-27ZJJM2Y.cjs");
40
- var import_chunk_HHQDDCTP = require("./chunk-HHQDDCTP.cjs");
41
- (0, import_chunk_27ZJJM2Y.init_optimizer)();
39
+ var import_chunk_SNWJ2FZL = require("./chunk-SNWJ2FZL.cjs");
40
+ var import_chunk_QFQPBQSO = require("./chunk-QFQPBQSO.cjs");
41
+ (0, import_chunk_SNWJ2FZL.init_optimizer)();
42
42
  // Annotate the CommonJS export names for ESM import in node:
43
43
  0 && (module.exports = {
44
44
  StateNodeAttributes,
@@ -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: () => import_chunk_27ZJJM2Y.SectionKinds,
22
- appSupport: () => import_chunk_27ZJJM2Y.appSupport,
23
- connectiq: () => import_chunk_27ZJJM2Y.connectiq,
24
- getDeviceInfo: () => import_chunk_27ZJJM2Y.getDeviceInfo,
25
- getFunctionDocumentation: () => import_chunk_27ZJJM2Y.getFunctionDocumentation,
26
- getLanguages: () => import_chunk_27ZJJM2Y.getLanguages,
27
- getSdkPath: () => import_chunk_27ZJJM2Y.getSdkPath,
28
- isWin: () => import_chunk_27ZJJM2Y.isWin,
29
- optimizeProgram: () => import_chunk_27ZJJM2Y.optimizeProgram,
30
- readPrg: () => import_chunk_27ZJJM2Y.readPrg,
31
- readPrgWithOffsets: () => import_chunk_27ZJJM2Y.readPrgWithOffsets,
32
- xmlUtil: () => import_chunk_27ZJJM2Y.xml_util_exports
21
+ SectionKinds: () => import_chunk_SNWJ2FZL.SectionKinds,
22
+ appSupport: () => import_chunk_SNWJ2FZL.appSupport,
23
+ connectiq: () => import_chunk_SNWJ2FZL.connectiq,
24
+ getDeviceInfo: () => import_chunk_SNWJ2FZL.getDeviceInfo,
25
+ getFunctionDocumentation: () => import_chunk_SNWJ2FZL.getFunctionDocumentation,
26
+ getLanguages: () => import_chunk_SNWJ2FZL.getLanguages,
27
+ getSdkPath: () => import_chunk_SNWJ2FZL.getSdkPath,
28
+ isWin: () => import_chunk_SNWJ2FZL.isWin,
29
+ optimizeProgram: () => import_chunk_SNWJ2FZL.optimizeProgram,
30
+ readPrg: () => import_chunk_SNWJ2FZL.readPrg,
31
+ readPrgWithOffsets: () => import_chunk_SNWJ2FZL.readPrgWithOffsets,
32
+ xmlUtil: () => import_chunk_SNWJ2FZL.xml_util_exports
33
33
  });
34
34
  module.exports = __toCommonJS(sdk_util_exports);
35
- var import_chunk_27ZJJM2Y = require("./chunk-27ZJJM2Y.cjs");
36
- var import_chunk_HHQDDCTP = require("./chunk-HHQDDCTP.cjs");
37
- (0, import_chunk_27ZJJM2Y.init_sdk_util)();
35
+ var import_chunk_SNWJ2FZL = require("./chunk-SNWJ2FZL.cjs");
36
+ var import_chunk_QFQPBQSO = require("./chunk-QFQPBQSO.cjs");
37
+ (0, import_chunk_SNWJ2FZL.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 = {
@@ -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, predBlock: Block, isExSucc: boolean) => boolean): void;
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
- localsMap: Map<FuncEntry, LocalsMap>;
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 interface Lgetv extends ByteArg {
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 ByteArg {
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 {};
@@ -0,0 +1,2 @@
1
+ import { Context, FuncEntry } from "./bytecode";
2
+ export declare function sizeBasedPRE(func: FuncEntry, context: Context): true | undefined;
@@ -9,6 +9,7 @@ export declare class SymbolTable {
9
9
  methods: Map<number, {
10
10
  name: string;
11
11
  id: number | null;
12
+ argc: number | null;
12
13
  }>;
13
14
  decoder: import("util").TextDecoder;
14
15
  parseSymbolTable(view: DataView): number;
@@ -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: () => import_chunk_HHQDDCTP.GenericQueue,
22
- bumpLogging: () => import_chunk_HHQDDCTP.bumpLogging,
23
- copyRecursiveAsNeeded: () => import_chunk_HHQDDCTP.copyRecursiveAsNeeded,
24
- every: () => import_chunk_HHQDDCTP.every,
25
- first_modified: () => import_chunk_HHQDDCTP.first_modified,
26
- forEach: () => import_chunk_HHQDDCTP.forEach,
27
- globSome: () => import_chunk_HHQDDCTP.globSome,
28
- globa: () => import_chunk_HHQDDCTP.globa,
29
- last_modified: () => import_chunk_HHQDDCTP.last_modified,
30
- log: () => import_chunk_HHQDDCTP.log,
31
- logger: () => import_chunk_HHQDDCTP.logger,
32
- map: () => import_chunk_HHQDDCTP.map,
33
- popcount: () => import_chunk_HHQDDCTP.popcount,
34
- promiseAll: () => import_chunk_HHQDDCTP.promiseAll,
35
- pushUnique: () => import_chunk_HHQDDCTP.pushUnique,
36
- readByLine: () => import_chunk_HHQDDCTP.readByLine,
37
- reduce: () => import_chunk_HHQDDCTP.reduce,
38
- sameArrays: () => import_chunk_HHQDDCTP.sameArrays,
39
- setBanner: () => import_chunk_HHQDDCTP.setBanner,
40
- some: () => import_chunk_HHQDDCTP.some,
41
- spawnByLine: () => import_chunk_HHQDDCTP.spawnByLine,
42
- wouldLog: () => import_chunk_HHQDDCTP.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 import_chunk_HHQDDCTP = require("./chunk-HHQDDCTP.cjs");
46
- (0, import_chunk_HHQDDCTP.init_util)();
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,
@@ -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 import_chunk_27ZJJM2Y = require("./chunk-27ZJJM2Y.cjs");
25
- var import_chunk_HHQDDCTP = require("./chunk-HHQDDCTP.cjs");
24
+ var import_chunk_SNWJ2FZL = require("./chunk-SNWJ2FZL.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, import_chunk_HHQDDCTP.__commonJS)({
27
+ var require_worker_thread = (0, import_chunk_QFQPBQSO.__commonJS)({
28
28
  "src/worker-thread.ts"() {
29
- (0, import_chunk_27ZJJM2Y.init_worker_task)();
29
+ (0, import_chunk_SNWJ2FZL.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, import_chunk_27ZJJM2Y.performTask)(task));
32
+ return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_SNWJ2FZL.performTask)(task));
33
33
  });
34
34
  }
35
35
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markw65/monkeyc-optimizer",
3
3
  "type": "commonjs",
4
- "version": "1.1.23",
4
+ "version": "1.1.25",
5
5
  "description": "Source to source optimizer for Garmin Monkey C code",
6
6
  "main": "build/optimizer.cjs",
7
7
  "types": "build/src/optimizer.d.ts",