WASM is NOT implemented for Opcode primitives (and not needed for performance).
Pure TypeScript is Optimal: Opcode operations are already optimal in TypeScript. WASM would provide zero benefit and make most operations 10-100x SLOWER due to call overhead.
import { isWasmOpcodeAvailable } from '@tevm/primitives/Opcode/Opcode.wasm.js'if (isWasmOpcodeAvailable()) { // Never reaches here console.log("WASM available")} else { console.log("Using pure TypeScript (optimal)")}
Get detailed implementation status and performance recommendations.
Copy
Ask AI
import { getOpcodeImplementationStatus } from '@tevm/primitives/Opcode/Opcode.wasm.js'const status = getOpcodeImplementationStatus()console.log(status)// {// available: false,// reason: "Pure TS optimal - WASM overhead exceeds benefit",// recommendation: "Use pure TypeScript implementation - already optimal for opcode lookups and bytecode parsing",// performance: {// typescriptAvg: "15-200ns for lookups, 5-100μs for bytecode parsing",// wasmOverhead: "1-2μs per WASM call",// verdict: "TypeScript 10-100x faster for lookups; comparable for large bytecode parsing but not worth complexity"// },// notes: "Bytecode parsing of very large contracts (>10KB) might benefit from WASM, but this is rare and the 2-3x speedup doesn't justify the implementation complexity."// }
class OpcodeCache { private infoCache = new Map<BrandedOpcode, Info>() getInfo(opcode: BrandedOpcode): Info | undefined { if (!this.infoCache.has(opcode)) { const info = Opcode.info(opcode) if (info) this.infoCache.set(opcode, info) } return this.infoCache.get(opcode) }}
Pure TypeScript implementation is optimal for all opcode operations:✅ Use TypeScript for:
All opcode lookups (isPush, isDup, etc.)
All metadata queries (getInfo, getName, etc.)
All bytecode parsing (any size)
All disassembly operations
❌ Don’t use WASM for:
Opcode operations (10-100x slower)
Small bytecode parsing (<1KB)
Individual opcode checks
Optimization Strategy: Focus on parsing once and reusing the instruction array rather than attempting WASM optimization. This provides 10-100x better speedup than WASM ever could.