Files
salvium-rs/test/check-vm-internals.js
T
Matt Hess 7730b6993f ● Add AssemblyScript WASM VM for RandomX full mode
- Create assembly/vm.ts with full RandomX VM implementation
    - 256 instructions, 2048 iterations per hash
    - Native u64/f64 operations in WebAssembly
    - Full mode dataset lookups (2GB pre-computed)

  - Update miner to use WASM VM for full mode
    - mining-worker-asm.js uses pre-compiled WASM
    - ~32 H/s per thread (4x faster than light mode)
    - 8 threads achieves ~260 H/s

  - Clean up redundant code
    - Remove mining-worker-full.js (old JIT approach)
    - Consolidate 'asm' mode into 'full' mode
2026-01-18 01:16:10 +00:00

35 lines
1.2 KiB
JavaScript

import { randomx_init_cache, randomx_create_vm, randomx_superscalarhash } from '../src/randomx/vendor/index.js';
const cache = randomx_init_cache('test');
console.log('Cache properties:');
console.log(' cache.memory type:', cache.memory.constructor.name);
console.log(' cache.memory buffer size:', cache.memory.buffer.byteLength);
console.log(' cache.thunk type:', cache.thunk.constructor.name);
console.log(' cache.vm type:', cache.vm.constructor.name);
// Create superscalar hash
const ssHash = randomx_superscalarhash(cache);
console.log('\nSuperscalar hash function created');
console.log(' ssHash type:', typeof ssHash);
// Test one item
const item0 = ssHash(0n);
console.log(' item[0]:', item0);
// Check WebAssembly module imports
console.log('\nWebAssembly module analysis:');
// Get imports for cache.vm
const vmImports = WebAssembly.Module.imports(cache.vm);
console.log('VM module imports:');
for (const imp of vmImports) {
console.log(' -', imp.module, '/', imp.name, ':', imp.kind);
}
// Get exports for cache.vm
const vmExports = WebAssembly.Module.exports(cache.vm);
console.log('\nVM module exports:');
for (const exp of vmExports) {
console.log(' -', exp.name, ':', exp.kind);
}