porffor 0.57.14 → 0.57.16
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/compiler/assemble.js +1 -1
- package/compiler/builtins/_internal_object.ts +10 -113
- package/compiler/builtins_precompiled.js +22 -22
- package/compiler/codegen.js +4 -1
- package/compiler/disassemble.js +3 -2
- package/compiler/pgo.js +2 -2
- package/compiler/precompile.js +8 -2
- package/foo.js +24 -8
- package/package.json +1 -1
- package/runtime/flamegraph.js +441 -158
- package/runtime/hotlines.js +3 -3
- package/runtime/index.js +1 -1
package/compiler/disassemble.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Blocktype, Opcodes, Valtype } from './wasmSpec.js';
|
2
2
|
import { read_ieee754_binary64, read_signedLEB128, read_unsignedLEB128 } from './encoding.js';
|
3
|
+
import { importedFuncs } from './builtins.js';
|
3
4
|
|
4
5
|
const inv = (obj, keyMap = x => x) => Object.keys(obj).reduce((acc, x) => { acc[keyMap(obj[x])] = x; return acc; }, {});
|
5
6
|
const invOpcodes = inv(Opcodes);
|
@@ -99,8 +100,8 @@ export default (wasm, name = '', ind = 0, locals = {}, params = [], returns = []
|
|
99
100
|
const idx = inst[1];
|
100
101
|
const callFunc = funcs.find(x => x.index === idx);
|
101
102
|
if (callFunc) out += ` ;; $${callFunc.name} ${makeSignature(callFunc.params, callFunc.returns)}`;
|
102
|
-
if (
|
103
|
-
const importFunc =
|
103
|
+
if (idx < importedFuncs.length) {
|
104
|
+
const importFunc = importedFuncs[idx];
|
104
105
|
out += ` ;; import ${importFunc.name} ${makeSignature(importFunc.params, importFunc.returns)}`;
|
105
106
|
}
|
106
107
|
}
|
package/compiler/pgo.js
CHANGED
@@ -35,10 +35,10 @@ export const run = obj => {
|
|
35
35
|
time(0, `injecting PGO logging...`);
|
36
36
|
|
37
37
|
let activeFunc = null, abort = false;
|
38
|
-
createImport('profile1',
|
38
|
+
createImport('profile1', [ Valtype.i32 ], 0, n => {
|
39
39
|
activeFunc = n;
|
40
40
|
});
|
41
|
-
createImport('profile2',
|
41
|
+
createImport('profile2', [ Valtype.i32, Valtype.f64 ], 0, (i, n) => {
|
42
42
|
if (activeFunc == null) throw 'fail';
|
43
43
|
localData[activeFunc][i].push(n);
|
44
44
|
});
|
package/compiler/precompile.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Opcodes, Valtype } from './wasmSpec.js';
|
2
2
|
import { read_signedLEB128 } from './encoding.js';
|
3
3
|
import { TYPES, TYPE_NAMES } from './types.js';
|
4
|
-
import { createImport } from './builtins.js';
|
4
|
+
import { createImport, importedFuncs } from './builtins.js';
|
5
5
|
import { log } from './log.js';
|
6
6
|
|
7
7
|
createImport('print', 1, 0);
|
@@ -112,7 +112,13 @@ const compile = async (file, _funcs) => {
|
|
112
112
|
if (y[0] === Opcodes.call) {
|
113
113
|
const idx = y[1];
|
114
114
|
const f = funcs.find(x => x.index === idx);
|
115
|
-
if (!f)
|
115
|
+
if (!f) {
|
116
|
+
if (idx < importedFuncs.length) {
|
117
|
+
y.splice(1, 10, importedFuncs[idx].name);
|
118
|
+
}
|
119
|
+
|
120
|
+
continue;
|
121
|
+
}
|
116
122
|
|
117
123
|
y.splice(1, 10, f.name);
|
118
124
|
}
|
package/foo.js
CHANGED
@@ -1,10 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
function buildString(args) {
|
2
|
+
// Use member expressions rather than destructuring `args` for improved
|
3
|
+
// compatibility with engines that only implement assignment patterns
|
4
|
+
// partially or not at all.
|
5
|
+
const loneCodePoints = args.loneCodePoints;
|
6
|
+
const ranges = args.ranges;
|
7
|
+
const CHUNK_SIZE = 10000;
|
8
|
+
let result = String.fromCodePoint.apply(null, loneCodePoints);
|
9
|
+
for (let i = 0; i < ranges.length; i++) {
|
10
|
+
let range = ranges[i];
|
11
|
+
let start = range[0];
|
12
|
+
let end = range[1];
|
13
|
+
let codePoints = [];
|
14
|
+
for (let length = 0, codePoint = start; codePoint <= end; codePoint++) {
|
15
|
+
codePoints[length++] = codePoint;
|
16
|
+
if (length === CHUNK_SIZE) {
|
17
|
+
result += String.fromCodePoint.apply(null, codePoints);
|
18
|
+
codePoints.length = length = 0;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
result += String.fromCodePoint.apply(null, codePoints);
|
5
22
|
}
|
23
|
+
return result;
|
24
|
+
}
|
6
25
|
|
7
|
-
|
8
|
-
};
|
9
|
-
|
10
|
-
console.log(wow(1337));
|
26
|
+
console.log(buildString({ loneCodePoints: [1337], ranges: [] }));
|