porffor 0.17.0-cab4904b8 → 0.17.0-cbb73d209
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 +6 -4
- package/compiler/2c.js +28 -11
- package/compiler/assemble.js +19 -4
- package/compiler/builtins/array.ts +79 -9
- package/compiler/builtins/date.ts +104 -106
- package/compiler/builtins/error.js +2 -5
- package/compiler/builtins/set.ts +6 -14
- package/compiler/builtins/string_f64.ts +4 -6
- package/compiler/builtins/symbol.ts +2 -1
- package/compiler/builtins/typedarray.js +94 -0
- package/compiler/builtins/z_ecma262.ts +1 -0
- package/compiler/builtins.js +12 -1
- package/compiler/codegen.js +747 -140
- package/compiler/generated_builtins.js +2752 -669
- package/compiler/opt.js +3 -0
- package/compiler/pgo.js +9 -1
- package/compiler/precompile.js +4 -2
- package/compiler/prototype.js +0 -69
- package/compiler/types.js +31 -5
- package/compiler/wasmSpec.js +2 -0
- package/compiler/wrap.js +20 -5
- package/package.json +1 -1
- package/rhemyn/README.md +7 -4
- package/rhemyn/compile.js +170 -76
- package/runner/debug.js +1 -1
- package/runner/index.js +3 -3
- package/runner/profile.js +1 -1
- package/runner/repl.js +16 -11
package/runner/profile.js
CHANGED
@@ -20,7 +20,7 @@ let spin = 0;
|
|
20
20
|
let last = 0;
|
21
21
|
|
22
22
|
try {
|
23
|
-
const { exports } =
|
23
|
+
const { exports } = compile(source, process.argv.includes('--module') ? [ 'module' ] : [], {
|
24
24
|
y: n => {
|
25
25
|
tmp[n] = performance.now();
|
26
26
|
},
|
package/runner/repl.js
CHANGED
@@ -40,10 +40,9 @@ let lastMemory, lastPages;
|
|
40
40
|
const PageSize = 65536;
|
41
41
|
const memoryToString = mem => {
|
42
42
|
let out = '';
|
43
|
-
const pages = lastPages.length;
|
44
43
|
const wasmPages = mem.buffer.byteLength / PageSize;
|
45
44
|
|
46
|
-
out += `\x1B[1mallocated ${mem.buffer.byteLength / 1024}
|
45
|
+
out += `\x1B[1mallocated ${mem.buffer.byteLength / 1024}KiB\x1B[0m (using ${wasmPages} Wasm page${wasmPages === 1 ? '' : 's'})\n\n`;
|
47
46
|
|
48
47
|
const buf = new Uint8Array(mem.buffer);
|
49
48
|
|
@@ -55,10 +54,16 @@ const memoryToString = mem => {
|
|
55
54
|
}
|
56
55
|
|
57
56
|
out += `\x1B[0m\x1B[1m name${' '.repeat(longestName - 4)} \x1B[0m\x1B[90m│\x1B[0m\x1B[1m type${' '.repeat(longestType - 4)} \x1B[0m\x1B[90m│\x1B[0m\x1B[1m memory\x1B[0m\n`; // ─
|
58
|
-
for (let i = 0; i <
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
for (let i = 0; i < wasmPages; i++) {
|
58
|
+
if (lastPages[i]) {
|
59
|
+
const [ type, name ] = lastPages[i].split(': ');
|
60
|
+
// out += `\x1B[36m${lastPages[i].replace(':', '\x1B[90m:\x1B[34m')}\x1B[90m${' '.repeat(longestName - lastPages[i].length)} | \x1B[0m`;
|
61
|
+
out += ` \x1B[34m${name}${' '.repeat(longestName - name.length)} \x1B[90m│\x1B[0m \x1B[36m${type}${' '.repeat(longestType - type.length)} \x1B[90m│\x1B[0m `;
|
62
|
+
} else {
|
63
|
+
const type = '???';
|
64
|
+
const name = '???';
|
65
|
+
out += ` \x1B[34m${name}${' '.repeat(longestName - name.length)} \x1B[90m│\x1B[0m \x1B[36m${type}${' '.repeat(longestType - type.length)} \x1B[90m│\x1B[0m `;
|
66
|
+
}
|
62
67
|
|
63
68
|
for (let j = 0; j < 40; j++) {
|
64
69
|
const val = buf[i * pageSize + j];
|
@@ -75,13 +80,13 @@ const memoryToString = mem => {
|
|
75
80
|
};
|
76
81
|
|
77
82
|
let prev = '';
|
78
|
-
const run =
|
83
|
+
const run = (source, _context, _filename, callback, run = true) => {
|
79
84
|
// hack: print "secret" before latest code ran to only enable printing for new code
|
80
85
|
|
81
86
|
let toRun = (prev ? (prev + `;\nprint(-0x1337);\n`) : '') + source.trim();
|
82
87
|
|
83
88
|
let shouldPrint = !prev;
|
84
|
-
const { exports, pages } =
|
89
|
+
const { exports, pages } = compile(toRun, [], {}, str => {
|
85
90
|
if (shouldPrint) process.stdout.write(str);
|
86
91
|
if (str === '-4919') shouldPrint = true;
|
87
92
|
});
|
@@ -122,12 +127,12 @@ replServer.defineCommand('memory', {
|
|
122
127
|
});
|
123
128
|
replServer.defineCommand('asm', {
|
124
129
|
help: 'Log Wasm decompiled bytecode',
|
125
|
-
|
130
|
+
action() {
|
126
131
|
this.clearBufferedCommand();
|
127
132
|
|
128
133
|
try {
|
129
134
|
process.argv.push('--opt-funcs');
|
130
|
-
|
135
|
+
run('', null, null, () => {}, false);
|
131
136
|
process.argv.pop();
|
132
137
|
} catch { }
|
133
138
|
|
@@ -136,7 +141,7 @@ replServer.defineCommand('asm', {
|
|
136
141
|
});
|
137
142
|
replServer.defineCommand('js', {
|
138
143
|
help: 'Log JS being actually ran',
|
139
|
-
|
144
|
+
action() {
|
140
145
|
this.clearBufferedCommand();
|
141
146
|
console.log(prev);
|
142
147
|
this.displayPrompt();
|