@markw65/monkeyc-optimizer 1.1.20 → 1.1.21
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 +18 -0
- package/build/api.cjs +34 -34
- package/build/{chunk-APACX34C.cjs → chunk-HHQDDCTP.cjs} +6 -4
- package/build/{chunk-DCGJCC63.cjs → chunk-ZDTW2QRS.cjs} +19002 -18291
- package/build/optimizer.cjs +19 -19
- package/build/sdk-util.cjs +15 -15
- package/build/src/readprg/bytecode.d.ts +3 -2
- package/build/src/readprg/cflow.d.ts +3 -0
- package/build/src/readprg/dce.d.ts +4 -1
- package/build/src/readprg/interp.d.ts +19 -0
- package/build/src/readprg/locals.d.ts +2 -0
- package/build/util.cjs +24 -24
- package/build/worker-thread.cjs +5 -5
- package/package.json +3 -3
- package/build/worker-pool.cjs +0 -34
package/README.md
CHANGED
|
@@ -793,3 +793,21 @@ Bug Fixes
|
|
|
793
793
|
|
|
794
794
|
- Optimizations
|
|
795
795
|
- Improve dce in the post build optimizer a little, by computing which locals are live out of each block.
|
|
796
|
+
|
|
797
|
+
### 1.1.20
|
|
798
|
+
|
|
799
|
+
- Bug fixes
|
|
800
|
+
|
|
801
|
+
- fixed a bug that could cause dead-store elimination to delete stores that might be used if an exception was thrown. eg `try { x=1; foo(); x=2; } catch (ex) { System.println(x); x=3; }` could delete the first store to `x`, breaking the println if `foo` actually throws.
|
|
802
|
+
|
|
803
|
+
- Source to Source Optimizations
|
|
804
|
+
|
|
805
|
+
- convert `++` and `--` to `+= 1` and `-= 1`. Garmin's compiler generates exactly the same code for both, but when the `1` is written explicitly, its available for `sizeBasedPRE` to optimize.
|
|
806
|
+
- convert `-x` to `0 - x`. Again, Garmin's compiler generates exactly the same code, but being explicit makes the `0` available to `sizeBasedPRE`.
|
|
807
|
+
- rewrite some optimizations so that `-x` and `0-x` are treated identically. eg `(0-x) + y` => `y - x` (for suitably typed `x` and `y`).
|
|
808
|
+
- optimize `-1 - x` to `~x` (for suitably typed x), saving 5 bytes (or 2 if pre was going to replace the -1 with a local)
|
|
809
|
+
|
|
810
|
+
- Post Build Optimizations
|
|
811
|
+
- Keep better track of exceptional edges in dce, allowing it to be more aggressive.
|
|
812
|
+
- Add a (very simple) bytecode interpreter which keeps track of the values in locals, and on the stack. This allows us to opportunistically replace constants (typically 5+ bytes) with a 2 byte load from a register, or from a stack location. This (together with dce) will form the infrastructure for a future minimize-locals pass.
|
|
813
|
+
- when replacing constants with locals/stack accesses, look for uses of `~`. Eg if the value `2` is in the local `x`, and we need to produce the value `-3`, we can use `~x` (costing 3 bytes, instead of 5).
|
package/build/api.cjs
CHANGED
|
@@ -18,42 +18,42 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var api_exports = {};
|
|
20
20
|
__export(api_exports, {
|
|
21
|
-
checkCompilerVersion: () =>
|
|
22
|
-
collectNamespaces: () =>
|
|
23
|
-
createDocumentationMap: () =>
|
|
24
|
-
diagnostic: () =>
|
|
25
|
-
diagnosticHelper: () =>
|
|
26
|
-
findNamesInScope: () =>
|
|
27
|
-
findUsingForNode: () =>
|
|
28
|
-
formatAst: () =>
|
|
29
|
-
formatAstLongLines: () =>
|
|
30
|
-
getApiFunctionInfo: () =>
|
|
31
|
-
getApiMapping: () =>
|
|
32
|
-
getSuperClasses: () =>
|
|
33
|
-
hasProperty: () =>
|
|
34
|
-
isClassVariable: () =>
|
|
35
|
-
isLocal: () =>
|
|
36
|
-
isLookupCandidate: () =>
|
|
37
|
-
isStateNode: () =>
|
|
38
|
-
lookupByFullName: () =>
|
|
39
|
-
lookupNext: () =>
|
|
40
|
-
lookupResultContains: () =>
|
|
41
|
-
lookupWithType: () =>
|
|
42
|
-
makeToyboxLink: () =>
|
|
43
|
-
mapVarDeclsByType: () =>
|
|
44
|
-
markInvokeClassMethod: () =>
|
|
45
|
-
parseSdkVersion: () =>
|
|
46
|
-
sameLookupResult: () =>
|
|
47
|
-
traverseAst: () =>
|
|
48
|
-
variableDeclarationName: () =>
|
|
49
|
-
visitReferences: () =>
|
|
50
|
-
visit_resources: () =>
|
|
51
|
-
visitorNode: () =>
|
|
21
|
+
checkCompilerVersion: () => import_chunk_ZDTW2QRS.checkCompilerVersion,
|
|
22
|
+
collectNamespaces: () => import_chunk_ZDTW2QRS.collectNamespaces,
|
|
23
|
+
createDocumentationMap: () => import_chunk_ZDTW2QRS.createDocumentationMap,
|
|
24
|
+
diagnostic: () => import_chunk_ZDTW2QRS.diagnostic,
|
|
25
|
+
diagnosticHelper: () => import_chunk_ZDTW2QRS.diagnosticHelper,
|
|
26
|
+
findNamesInScope: () => import_chunk_ZDTW2QRS.findNamesInScope,
|
|
27
|
+
findUsingForNode: () => import_chunk_ZDTW2QRS.findUsingForNode,
|
|
28
|
+
formatAst: () => import_chunk_ZDTW2QRS.formatAst,
|
|
29
|
+
formatAstLongLines: () => import_chunk_ZDTW2QRS.formatAstLongLines,
|
|
30
|
+
getApiFunctionInfo: () => import_chunk_ZDTW2QRS.getApiFunctionInfo,
|
|
31
|
+
getApiMapping: () => import_chunk_ZDTW2QRS.getApiMapping,
|
|
32
|
+
getSuperClasses: () => import_chunk_ZDTW2QRS.getSuperClasses,
|
|
33
|
+
hasProperty: () => import_chunk_ZDTW2QRS.hasProperty,
|
|
34
|
+
isClassVariable: () => import_chunk_ZDTW2QRS.isClassVariable,
|
|
35
|
+
isLocal: () => import_chunk_ZDTW2QRS.isLocal,
|
|
36
|
+
isLookupCandidate: () => import_chunk_ZDTW2QRS.isLookupCandidate,
|
|
37
|
+
isStateNode: () => import_chunk_ZDTW2QRS.isStateNode,
|
|
38
|
+
lookupByFullName: () => import_chunk_ZDTW2QRS.lookupByFullName,
|
|
39
|
+
lookupNext: () => import_chunk_ZDTW2QRS.lookupNext,
|
|
40
|
+
lookupResultContains: () => import_chunk_ZDTW2QRS.lookupResultContains,
|
|
41
|
+
lookupWithType: () => import_chunk_ZDTW2QRS.lookupWithType,
|
|
42
|
+
makeToyboxLink: () => import_chunk_ZDTW2QRS.makeToyboxLink,
|
|
43
|
+
mapVarDeclsByType: () => import_chunk_ZDTW2QRS.mapVarDeclsByType,
|
|
44
|
+
markInvokeClassMethod: () => import_chunk_ZDTW2QRS.markInvokeClassMethod,
|
|
45
|
+
parseSdkVersion: () => import_chunk_ZDTW2QRS.parseSdkVersion,
|
|
46
|
+
sameLookupResult: () => import_chunk_ZDTW2QRS.sameLookupResult,
|
|
47
|
+
traverseAst: () => import_chunk_ZDTW2QRS.traverseAst,
|
|
48
|
+
variableDeclarationName: () => import_chunk_ZDTW2QRS.variableDeclarationName,
|
|
49
|
+
visitReferences: () => import_chunk_ZDTW2QRS.visitReferences,
|
|
50
|
+
visit_resources: () => import_chunk_ZDTW2QRS.visit_resources,
|
|
51
|
+
visitorNode: () => import_chunk_ZDTW2QRS.visitorNode
|
|
52
52
|
});
|
|
53
53
|
module.exports = __toCommonJS(api_exports);
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
(0,
|
|
54
|
+
var import_chunk_ZDTW2QRS = require("./chunk-ZDTW2QRS.cjs");
|
|
55
|
+
var import_chunk_HHQDDCTP = require("./chunk-HHQDDCTP.cjs");
|
|
56
|
+
(0, import_chunk_ZDTW2QRS.init_api)();
|
|
57
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
58
|
0 && (module.exports = {
|
|
59
59
|
checkCompilerVersion,
|
|
@@ -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_HHQDDCTP_exports = {};
|
|
30
|
+
__export(chunk_HHQDDCTP_exports, {
|
|
31
31
|
GenericQueue: () => GenericQueue,
|
|
32
32
|
__commonJS: () => __commonJS,
|
|
33
33
|
__esm: () => __esm,
|
|
@@ -41,6 +41,7 @@ __export(chunk_APACX34C_exports, {
|
|
|
41
41
|
forEach: () => forEach,
|
|
42
42
|
globSome: () => globSome,
|
|
43
43
|
globa: () => globa,
|
|
44
|
+
init_logger: () => init_logger,
|
|
44
45
|
init_util: () => init_util,
|
|
45
46
|
last_modified: () => last_modified,
|
|
46
47
|
log: () => log,
|
|
@@ -57,7 +58,7 @@ __export(chunk_APACX34C_exports, {
|
|
|
57
58
|
spawnByLine: () => spawnByLine,
|
|
58
59
|
wouldLog: () => wouldLog
|
|
59
60
|
});
|
|
60
|
-
module.exports = __toCommonJS(
|
|
61
|
+
module.exports = __toCommonJS(chunk_HHQDDCTP_exports);
|
|
61
62
|
var child_process = __toESM(require("child_process"));
|
|
62
63
|
var fsc = __toESM(require("fs"));
|
|
63
64
|
var fs = __toESM(require("fs/promises"));
|
|
@@ -5461,7 +5462,7 @@ function wouldLog(module2, level) {
|
|
|
5461
5462
|
if (!loggerSettings) {
|
|
5462
5463
|
loggerSettings = getLoggerSettings();
|
|
5463
5464
|
}
|
|
5464
|
-
return (loggerSettings.get(module2) ?? 0) >= level + loggerLevelOffset;
|
|
5465
|
+
return (loggerSettings.get(module2) ?? loggerSettings.get("*") ?? 0) >= level + loggerLevelOffset;
|
|
5465
5466
|
}
|
|
5466
5467
|
function bumpLogging(module2, amount) {
|
|
5467
5468
|
if (!module2) {
|
|
@@ -5802,6 +5803,7 @@ run-parallel/index.js:
|
|
|
5802
5803
|
forEach,
|
|
5803
5804
|
globSome,
|
|
5804
5805
|
globa,
|
|
5806
|
+
init_logger,
|
|
5805
5807
|
init_util,
|
|
5806
5808
|
last_modified,
|
|
5807
5809
|
log,
|