porffor 0.25.0 → 0.25.1

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.
@@ -1772,10 +1772,10 @@ const RTArrayUtil = {
1772
1772
  ]
1773
1773
  };
1774
1774
 
1775
- const createNewTarget = (scope, decl, idx) => {
1775
+ const createNewTarget = (scope, decl, idx = 0) => {
1776
1776
  if (decl._new) {
1777
1777
  return [
1778
- ...number(idx),
1778
+ ...(typeof idx === 'number' ? number(idx) : idx),
1779
1779
  ...number(TYPES.function, Valtype.i32)
1780
1780
  ];
1781
1781
  }
@@ -1786,7 +1786,7 @@ const createNewTarget = (scope, decl, idx) => {
1786
1786
  ];
1787
1787
  };
1788
1788
 
1789
- const createThisArg = (scope, decl, getFunc, knownThis = undefined) => {
1789
+ const createThisArg = (scope, decl, knownThis = undefined) => {
1790
1790
  if (knownThis) {
1791
1791
  // todo: check compliance
1792
1792
  return knownThis;
@@ -2248,6 +2248,12 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2248
2248
  ];
2249
2249
  }
2250
2250
 
2251
+ const newTargetWasm = decl._newTargetWasm ?? createNewTarget(scope, decl, [
2252
+ [ Opcodes.local_get, funcLocal ],
2253
+ Opcodes.i32_from_u
2254
+ ]);
2255
+ const thisWasm = decl._thisWasm ?? createThisArg(scope, decl, knownThis);
2256
+
2251
2257
  const gen = argc => {
2252
2258
  const argsOut = [];
2253
2259
  for (let i = 0; i < argc; i++) {
@@ -2273,8 +2279,8 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2273
2279
  // no type return
2274
2280
  checkFlag(0b10, [
2275
2281
  // no type return & constr
2276
- ...createNewTarget(scope, decl),
2277
- ...createThisArg(scope, decl, [], knownThis),
2282
+ ...newTargetWasm,
2283
+ ...thisWasm,
2278
2284
  ...argsOut,
2279
2285
  [ Opcodes.local_get, funcLocal ],
2280
2286
  [ Opcodes.call_indirect, argc + 2, 0, 'no_type_return' ],
@@ -2288,8 +2294,8 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2288
2294
  // type return
2289
2295
  checkFlag(0b10, [
2290
2296
  // type return & constr
2291
- ...createNewTarget(scope, decl),
2292
- ...createThisArg(scope, decl, [], knownThis),
2297
+ ...newTargetWasm,
2298
+ ...thisWasm,
2293
2299
  ...argsOut,
2294
2300
  [ Opcodes.local_get, funcLocal ],
2295
2301
  [ Opcodes.call_indirect, argc + 2, 0 ],
@@ -2371,8 +2377,8 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2371
2377
  }
2372
2378
 
2373
2379
  if (func && func.constr) {
2374
- out.push(...createNewTarget(scope, decl, idx - importedFuncs.length));
2375
- out.push(...createThisArg(scope, decl, func));
2380
+ out.push(...(decl._newTargetWasm ?? createNewTarget(scope, decl, idx - importedFuncs.length)));
2381
+ out.push(...(decl._thisWasm ?? createThisArg(scope, decl)));
2376
2382
  paramOffset += 4;
2377
2383
  }
2378
2384
 
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.25.0+65ef4f661",
4
+ "version": "0.25.1+b0893a7c3",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.25.0+65ef4f661';
3
+ globalThis.version = '0.25.1+b0893a7c3';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {