CPU-feature dependent code in builtins

18 views
Skip to first unread message

Florian Loitsch

unread,
Sep 5, 2025, 3:48:15 AMSep 5
to v8-...@googlegroups.com
On RISC-V we need to store vector registers in the builtin Generate_WasmCompileLazy (and others). However, not all CPUs have vector support. It's dynamically detected, and then used accordingly.
Given that the builtins are precompiled, we can't use `CpuFeatures::IsSupported` as that wouldn't take the actual hardware into account.
We would either remove these functions from precompilation, or have a dynamic branch looking at the CPU feature in the generated assembly.

Did other architectures run into similar issues?
Any suggestions on how to handle this?

Thanks.

dmerc...@google.com

unread,
Sep 5, 2025, 4:11:07 AMSep 5
to v8-dev
Hi,

> have a dynamic branch looking at the CPU feature in the generated assembly.

I would suggest to do this.

You can look for instance at `IncsspqIfSupported` in builtins-x64.cc to see how you can retrieve CpuFeatures at runtime from builtins. And another example is the `supports_wasm_simd_128_address` external reference, used on a few architectures.

You should be able to do a similar thing with the CodeStubAssembler if needed.

Cheers,
Darius

Florian Loitsch

unread,
Sep 5, 2025, 4:26:51 AMSep 5
to v8-...@googlegroups.com
I will try that.
Thanks for the fast response.

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/v8-dev/ab08ef07-af9e-43f0-adeb-a59587e30e40n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages