porffor 0.16.0-8107e135a → 0.16.0-97bb4f33b
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/CONTRIBUTING.md +1 -1
- package/compiler/assemble.js +1 -7
- package/compiler/builtins/date.ts +4 -2
- package/compiler/builtins/set.ts +4 -2
- package/compiler/codegen.js +293 -227
- package/compiler/cyclone.js +12 -12
- package/compiler/generated_builtins.js +46 -46
- package/compiler/havoc.js +1 -1
- package/compiler/index.js +4 -29
- package/compiler/opt.js +5 -7
- package/compiler/parse.js +1 -1
- package/compiler/pgo.js +10 -11
- package/compiler/precompile.js +7 -12
- package/compiler/prefs.js +1 -1
- package/compiler/prototype.js +43 -34
- package/compiler/wasmSpec.js +2 -2
- package/compiler/wrap.js +2 -3
- package/no_pgo.txt +923 -0
- package/package.json +5 -3
- package/pgo.txt +916 -0
- package/runner/index.js +3 -10
- package/bf +0 -0
- package/compiler/allocators/grow.js +0 -25
- package/compiler/allocators/index.js +0 -10
- package/compiler/allocators/static.js +0 -42
package/runner/index.js
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
+
|
3
|
+
import compile from '../compiler/wrap.js';
|
2
4
|
import fs from 'node:fs';
|
3
5
|
|
4
6
|
const start = performance.now();
|
@@ -57,15 +59,10 @@ if (process.argv.includes('--help')) {
|
|
57
59
|
}
|
58
60
|
|
59
61
|
let file = process.argv.slice(2).find(x => x[0] !== '-');
|
60
|
-
if (['
|
62
|
+
if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(file)) {
|
61
63
|
// remove this arg
|
62
64
|
process.argv.splice(process.argv.indexOf(file), 1);
|
63
65
|
|
64
|
-
if (file === 'precompile') {
|
65
|
-
await import('../compiler/precompile.js');
|
66
|
-
await new Promise(() => {}); // do nothing for the rest of this file
|
67
|
-
}
|
68
|
-
|
69
66
|
if (file === 'profile') {
|
70
67
|
await import('./profile.js');
|
71
68
|
await new Promise(() => {}); // do nothing for the rest of this file
|
@@ -92,8 +89,6 @@ if (['precompile', 'run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm
|
|
92
89
|
}
|
93
90
|
}
|
94
91
|
|
95
|
-
globalThis.file = file;
|
96
|
-
|
97
92
|
if (!file) {
|
98
93
|
if (process.argv.includes('-v') || process.argv.includes('--version')) {
|
99
94
|
// just print version
|
@@ -108,8 +103,6 @@ if (!file) {
|
|
108
103
|
|
109
104
|
const source = fs.readFileSync(file, 'utf8');
|
110
105
|
|
111
|
-
const compile = (await import('../compiler/wrap.js')).default;
|
112
|
-
|
113
106
|
let cache = '';
|
114
107
|
const print = str => {
|
115
108
|
/* cache += str;
|
package/bf
DELETED
Binary file
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { Opcodes, Valtype } from '../wasmSpec.js';
|
2
|
-
import { number } from '../embedding.js';
|
3
|
-
import Prefs from '../prefs.js';
|
4
|
-
|
5
|
-
export default class GrowAllocator {
|
6
|
-
constructor() {
|
7
|
-
Prefs.rmUnusedTypes = false;
|
8
|
-
}
|
9
|
-
|
10
|
-
alloc() {
|
11
|
-
return [
|
12
|
-
// get current page count
|
13
|
-
[ Opcodes.memory_size, 0 ],
|
14
|
-
|
15
|
-
// grow by 1 page
|
16
|
-
[ Opcodes.i32_const, 1 ],
|
17
|
-
[ Opcodes.memory_grow, 0 ],
|
18
|
-
[ Opcodes.drop ],
|
19
|
-
|
20
|
-
// get ptr (page count * page size)
|
21
|
-
number(65536, Valtype.i32)[0],
|
22
|
-
[ Opcodes.i32_mul ]
|
23
|
-
];
|
24
|
-
}
|
25
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import StaticAllocator from './static.js';
|
2
|
-
import GrowAllocator from './grow.js';
|
3
|
-
|
4
|
-
export default name => {
|
5
|
-
switch (name) {
|
6
|
-
case 'static': return new StaticAllocator();
|
7
|
-
case 'grow': return new GrowAllocator();
|
8
|
-
default: throw new Error(`unknown allocator: ${name}`);
|
9
|
-
}
|
10
|
-
};
|
@@ -1,42 +0,0 @@
|
|
1
|
-
import { Valtype } from '../wasmSpec.js';
|
2
|
-
import { number } from '../embedding.js';
|
3
|
-
import Prefs from '../prefs.js';
|
4
|
-
|
5
|
-
const allocType = itemType => {
|
6
|
-
switch (itemType) {
|
7
|
-
case 'i8': return 'bytestring';
|
8
|
-
case 'i16': return 'string';
|
9
|
-
|
10
|
-
default: return 'array';
|
11
|
-
}
|
12
|
-
};
|
13
|
-
|
14
|
-
const ptr = ind => {
|
15
|
-
if (ind === 0) return 1;
|
16
|
-
return ind * pageSize;
|
17
|
-
};
|
18
|
-
|
19
|
-
|
20
|
-
export default class StaticAllocator {
|
21
|
-
constructor() {
|
22
|
-
}
|
23
|
-
|
24
|
-
alloc({ scope, pages }, name, { itemType }) {
|
25
|
-
const reason = `${allocType(itemType)}: ${Prefs.scopedPageNames ? (scope.name + '/') : ''}${name}`;
|
26
|
-
|
27
|
-
if (pages.has(reason)) return number(ptr(pages.get(reason).ind), Valtype.i32);
|
28
|
-
|
29
|
-
if (reason.startsWith('array:')) pages.hasArray = true;
|
30
|
-
if (reason.startsWith('string:')) pages.hasString = true;
|
31
|
-
if (reason.startsWith('bytestring:')) pages.hasByteString = true;
|
32
|
-
if (reason.includes('string:')) pages.hasAnyString = true;
|
33
|
-
|
34
|
-
let ind = pages.size;
|
35
|
-
pages.set(reason, { ind, type: itemType });
|
36
|
-
|
37
|
-
scope.pages ??= new Map();
|
38
|
-
scope.pages.set(reason, { ind, type: itemType });
|
39
|
-
|
40
|
-
return number(ptr(ind), Valtype.i32);
|
41
|
-
}
|
42
|
-
}
|