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/runner/profile.js CHANGED
@@ -20,7 +20,7 @@ let spin = 0;
20
20
  let last = 0;
21
21
 
22
22
  try {
23
- const { exports } = await compile(source, process.argv.includes('--module') ? [ 'module' ] : [], {
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}KB\x1B[0m for ${pages} thing${pages === 1 ? '' : 's'} using ${wasmPages} Wasm page${wasmPages === 1 ? '' : 's'}\n\n`;
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 < pages; 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 `;
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 = async (source, _context, _filename, callback, run = true) => {
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 } = await compile(toRun, [], {}, str => {
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
- async action() {
130
+ action() {
126
131
  this.clearBufferedCommand();
127
132
 
128
133
  try {
129
134
  process.argv.push('--opt-funcs');
130
- await run('', null, null, () => {}, false);
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
- async action() {
144
+ action() {
140
145
  this.clearBufferedCommand();
141
146
  console.log(prev);
142
147
  this.displayPrompt();