8 ms·
> "WASM translated to register-based bytecode. That's awesome!" If the hardware executing this code is "stack-based" (or, does not offer enough general purpose
by uasm 7y ago
> "WASM translated to register-based bytecode. That's awesome!"
If the hardware executing this code is "stack-based" (or, does not offer enough general purpose registers to accomodate the funtion call) - this will need to be converted back to a stack-based function call (either at runtime, or beforehand). Wouldn't this intermediate WASM-to-register-based-bytecode translation be redundant then?
- tyingq 7y agoI don't know of any current physical stack machine CPUs.
- uasm 7y agoStacks are used extensively across the x86 family [0] [0] - https://en.wikipedia.org/wiki/X86_calling_conventions https://en.wikipedia.org/wiki/X86_calling_conventions
- tyingq 7y ago"Has a stack" isn't the same as "Has a stack based ISA".
- colejohnson66 7y agoTo expand: a Forth machine or similar would be a stack based ISA. Using a stack is a different matters; Pretty much every ISA uses stacks.
- jeltz 7y agoNo, stack machine CPUs are pretty obscure things, especially today. See the link below for some examples. All or virtually all modern commercial CPUs are register based. https://en.wikipedia.org/wiki/Stack_machine#Commercial_stack_machines https://en.wikipedia.org/wiki/Stack_machine#Commercial_stack...
- AlEinstein 7y agoWhat proportion of machines running web assembly are stack-based, would you say? I would guess negligible.
- tom_mellior 7y agoYou seem to be asking something like "if we always hit the algorithm's slow path, isn't the algorithm slow?". The answer is "yes, but we will (hopefully) almost never hit the slow path". On x64-64 you will typically be able to pass 6 integer/pointer values and 8 floating-point values in registers. That should be enough for most function calls in real-world code.