diff --git a/compiler/builtins.js b/compiler/builtins.js index 23b131f7..3ac8afcd 100644 --- a/compiler/builtins.js +++ b/compiler/builtins.js @@ -364,13 +364,13 @@ export const BuiltinFuncs = function() { const prngSeed0 = (Math.random() * (2 ** 30)) | 0, prngSeed1 = (Math.random() * (2 ** 30)) | 0; const prng = ({ - 'lcg32_glibc': { + 'lcg32': { globals: [ Valtype.i32 ], locals: [], returns: Valtype.i32, wasm: [ + // use glibc/musl's constants // seed = (MULTIPLIER * seed + INCREMENT) % MODULUS - // MULTIPLIER * state0 [ Opcodes.global_get, 0 ], number(1103515245, Valtype.i32), [ Opcodes.i32_mul ], @@ -380,30 +380,8 @@ export const BuiltinFuncs = function() { [ Opcodes.i32_add ], // % MODULUS - number(2 ** 31, Valtype.i32), - [ Opcodes.i32_rem_s ], - - // state0 = - [ Opcodes.global_set, 0 ], - - // state0 - [ Opcodes.global_get, 0 ], - ], - }, - 'lcg32_minstd': { - globals: [ Valtype.i32 ], - locals: [], - returns: Valtype.i32, - wasm: [ - // seed = (MULTIPLIER * seed + INCREMENT) % MODULUS - // MULTIPLIER * state0 - [ Opcodes.global_get, 0 ], - number(48271, Valtype.i32), - [ Opcodes.i32_mul ], - - // % MODULUS - number((2 ** 31) - 1, Valtype.i32), - [ Opcodes.i32_rem_s ], + number(0x7fffffff, Valtype.i32), + [ Opcodes.i32_and ], // state0 = [ Opcodes.global_set, 0 ], @@ -484,11 +462,6 @@ export const BuiltinFuncs = function() { // state0 = s1 [ Opcodes.global_set, 0 ], - // // s1 * 0x2545F4914F6CDD1D - // [ Opcodes.local_get, 0 ], - // [ Opcodes.i64_const, 0x9d, 0xba, 0xb3, 0xfb, 0x94, 0x92, 0xfd, 0xa2, 0x25 ], - // [ Opcodes.i64_mul ] - // s1 [ Opcodes.local_get, 0 ], ], diff --git a/package.json b/package.json index 73a95e31..cc1a3d1d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "porffor", "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js", - "version": "0.50.27", + "version": "0.50.28", "author": "CanadaHonk", "license": "MIT", "scripts": {}, diff --git a/runner/index.js b/runner/index.js index 84b0d3e0..e779ffad 100644 --- a/runner/index.js +++ b/runner/index.js @@ -1,6 +1,6 @@ #!/usr/bin/env node import fs from 'node:fs'; -globalThis.version = '0.50.27'; +globalThis.version = '0.50.28'; // deno compat if (typeof process === 'undefined' && typeof Deno !== 'undefined') { @@ -63,7 +63,7 @@ if (process.argv.includes('--help')) { pgo: 'Enable PGO (profile-guided optimization)', 'profile-compiler': 'Log general compiler performance (on by default when compiling to a file)', valtype: 'Valtype to use (i32|i64|\x1B[1mf64\x1B[0m)', - prng: 'PRNG algorithm to use (lcg32_glibc|lcg32_minstd|xorshift32+|xorshift64+|\x1B[1mxorshift128+\x1B[0m|xoroshiro128+|xoshiro128+)', + prng: 'PRNG algorithm to use (lcg32|xorshift32+|xorshift64+|\x1B[1mxorshift128+\x1B[0m|xoroshiro128+|xoshiro128+)', allocator: 'Allocator to use (oneshot|\x1B[1mchunk\x1B[0m)', 'exception-mode': 'Exception mode to use (lut|\x1B[1mstack\x1B[0m)', fastLength: 'Spec non-compliant optimization to make .length faster',