porffor 0.16.0-30af62694 → 0.16.0-6572d1c74

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.
@@ -3270,7 +3270,7 @@ const makeArray = (scope, decl, global = false, name = '$undeclared', initEmpty
3270
3270
  firstAssign = true;
3271
3271
 
3272
3272
  // todo: can we just have 1 undeclared array? probably not? but this is not really memory efficient
3273
- const uniqueName = name === '$undeclared' ? name + randId() : name;
3273
+ const uniqueName = name === '$undeclared' ? name + Math.random().toString().slice(2) : name;
3274
3274
 
3275
3275
  let page;
3276
3276
  if (Prefs.scopedPageNames) page = allocPage(scope, `${getAllocType(itemType)}: ${scope.name}/${uniqueName}`, itemType);
@@ -3658,7 +3658,7 @@ const generateMember = (scope, decl, _global, _name) => {
3658
3658
  });
3659
3659
  };
3660
3660
 
3661
- const randId = () => Math.random().toString(16).slice(1, -2).padEnd(12, '0');
3661
+ const randId = () => Math.random().toString(16).slice(0, -4);
3662
3662
 
3663
3663
  const objectHack = node => {
3664
3664
  if (!node) return node;
@@ -3710,7 +3710,7 @@ const generateFunc = (scope, decl) => {
3710
3710
  if (decl.async) return todo(scope, 'async functions are not supported');
3711
3711
  if (decl.generator) return todo(scope, 'generator functions are not supported');
3712
3712
 
3713
- const name = decl.id ? decl.id.name : `anonymous${randId()}`;
3713
+ const name = decl.id ? decl.id.name : `anonymous_${randId()}`;
3714
3714
  const params = decl.params ?? [];
3715
3715
 
3716
3716
  // TODO: share scope/locals between !!!
package/compiler/index.js CHANGED
@@ -158,23 +158,10 @@ export default (code, flags) => {
158
158
 
159
159
  if (process.version) {
160
160
  if (Prefs.native) {
161
- const cleanup = () => {
162
- try {
163
- fs.unlinkSync(outFile);
164
- } catch {}
165
- };
166
-
167
- process.on('exit', cleanup);
168
- process.on('beforeExit', cleanup);
169
- process.on('SIGINT', () => {
170
- cleanup();
171
- process.exit();
172
- });
173
-
174
161
  const runArgs = process.argv.slice(2).filter(x => !x.startsWith('-'));
175
- try {
176
- execSync([ outFile, ...runArgs.slice(1) ].join(' '), { stdio: 'inherit' });
177
- } catch {}
162
+ process.on('beforeExit', () => { fs.unlinkSync(outFile); });
163
+
164
+ execSync([ outFile, ...runArgs.slice(1) ].join(' '), { stdio: 'inherit' });
178
165
  }
179
166
 
180
167
  process.exit();
package/compiler/pgo.js CHANGED
@@ -11,7 +11,7 @@ export const setup = () => {
11
11
 
12
12
  // enable these prefs by default for pgo
13
13
  Prefs.typeswitchUniqueTmp = Prefs.typeswitchUniqueTmp === false ? false : true;
14
- Prefs.cyclone = Prefs.cyclone === false ? false : true;
14
+ Prefs.cyclone = Prefs.cyclone === false ? false : true;;
15
15
  };
16
16
 
17
17
  export const run = obj => {
@@ -131,18 +131,16 @@ export const run = obj => {
131
131
  func.localValues = localValues;
132
132
 
133
133
  let counts = new Array(10).fill(0);
134
- const consistents = localData[i].map((x, j) => {
135
- if (j < func.params.length) return false; // param
136
- if (x.length === 0 || !x.every((y, i) => i < 1 ? true : y === x[i - 1])) return false; // not consistent
134
+ const consistents = localData[i].map(x => {
135
+ if (x.length === 0 || !x.every((y, i) => i < 1 ? true : y === x[i - 1])) return false;
137
136
 
138
137
  counts[0]++;
139
138
  return x[0];
140
139
  });
141
140
 
142
141
  const integerOnlyF64s = localData[i].map((x, j) => {
143
- if (j < func.params.length) return false; // param
144
142
  if (localValues[j].type === Valtype.i32) return false; // already i32
145
- if (x.length === 0 || !x.every(y => Number.isInteger(y))) return false; // not all integer values
143
+ if (x.length === 0 || !x.every(y => Number.isInteger(y))) return false;
146
144
 
147
145
  counts[1]++;
148
146
  return true;
@@ -153,14 +151,14 @@ export const run = obj => {
153
151
 
154
152
  log += ` ${func.name}: identified ${counts[0]}/${total} locals as consistent${Prefs.verbosePgo ? ':' : ''}\n`;
155
153
  if (Prefs.verbosePgo) {
156
- for (let j = func.params.length; j < localData[i].length; j++) {
154
+ for (let j = 0; j < localData[i].length; j++) {
157
155
  log += ` ${consistents[j] !== false ? '\u001b[92m' : '\u001b[91m'}${localKeys[j]}\u001b[0m: ${new Set(localData[i][j]).size} unique values set\n`;
158
156
  }
159
157
  }
160
158
 
161
159
  log += ` ${func.name}: identified ${counts[1]}/${localValues.reduce((acc, x) => acc + (x.type === Valtype.f64 ? 1 : 0), 0)} f64 locals as integer usage only${Prefs.verbosePgo ? ':' : ''}\n`;
162
160
  if (Prefs.verbosePgo) {
163
- for (let j = func.params.length; j < localData[i].length; j++) {
161
+ for (let j = 0; j < localData[i].length; j++) {
164
162
  if (localValues[j].type !== Valtype.f64) continue;
165
163
  log += ` ${integerOnlyF64s[j] ? '\u001b[92m' : '\u001b[91m'}${localKeys[j]}\u001b[0m\n`;
166
164
  }
@@ -180,6 +178,7 @@ export const run = obj => {
180
178
  for (let i = 0; i < x.integerOnlyF64s.length; i++) {
181
179
  const c = x.integerOnlyF64s[i];
182
180
  if (c === false) continue;
181
+ if (i < x.params.length) continue;
183
182
 
184
183
  targets.push(i);
185
184
  }
@@ -192,6 +191,7 @@ export const run = obj => {
192
191
  for (let i = 0; i < x.consistents.length; i++) {
193
192
  const c = x.consistents[i];
194
193
  if (c === false) continue;
194
+ if (i < x.params.length) continue;
195
195
 
196
196
  targets.push(i);
197
197
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
4
- "version": "0.16.0-30af62694",
4
+ "version": "0.16.0-6572d1c74",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -28,5 +28,5 @@
28
28
  "bugs": {
29
29
  "url": "https://github.com/CanadaHonk/porffor/issues"
30
30
  },
31
- "homepage": "https://porffor.dev"
31
+ "homepage": "https://porffor.goose.icu"
32
32
  }