wasm32: using 64-bit registers with 32-bit pointers

81 views
Skip to first unread message

Zxilly Chou

unread,
Jun 25, 2026, 3:10:57 AM (yesterday) Jun 25
to golang-dev
Hi all, 

In the context of the accepted GOARCH=wasm32 proposal (https://github.com/golang/go/issues/63131), I have a working wasm32 branch: https://github.com/Zxilly/go/tree/feat/wasm32 

One question before polishing this further: would it be acceptable for wasm32 to have RegSize == 8 and PtrSize == 4? The current branch keeps wasm locals/registers at 64 bits, while making pointers 32 bits. Wasm always has native i64 operations, so forcing the register size down to 32 bits does not seem natural. 

I noticed Go used to have amd64p32, which also had 64-bit registers with 32-bit pointers, but I would like to check whether RegSize != PtrSize is still acceptable for the Go compiler/runtime before sending CLs in that direction. 

Thanks, 
Zxilly

Jorropo

unread,
Jun 25, 2026, 4:25:00 AM (yesterday) Jun 25
to Zxilly Chou, golang-dev
Hey, just so you know this is a recurring question, I am 80% sure you can find someone else asking the exact same question a couple of months ago in history.

IMO it's perfectly acceptable to have RegSize == 8 and PtrSize == 4 but amd64p32 was removed a long time ago and you should expect a lot of code we have written since then to silently assume that PtrSize == RegSize.

As long as you don't break other arches (I don't see how you could even if you tried) it won't be too bad, but if we merge your wasm32 port expect being pinged every month for a year with latent bugs surfacing for a year or two.

You might also want to do a `git grep -E (Ptr|Reg)Size` and review literally all codesites found manually and using the brains made of GB big matrixes.

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-dev/ff94ba1d-52e3-4b47-997e-87299c93fca2n%40googlegroups.com.

Jorropo

unread,
Jun 25, 2026, 4:27:59 AM (yesterday) Jun 25
to Zxilly Chou, golang-dev
It might make sense to mark wasm32 experimental for some time ?

Idk because I'm expecting many small bugs to be found in production so I don't want to tell people to not use it.
But if we tell people to not use it, how many bugs will we find in production ?

Zxilly Chou

unread,
Jun 25, 2026, 6:12:30 AM (yesterday) Jun 25
to golang-dev
Thanks, that makes sense. 

All wasm ports are currently still experimental, so I think wasm32 can remain under that umbrella for now. 

I have already fixed a few places where PtrSize and RegSize were mixed up , and will keep an eye out for more of these as the port progresses.

Jorropo

unread,
Jun 25, 2026, 7:19:59 AM (yesterday) Jun 25
to Zxilly Chou, golang-dev
> I have already fixed a few places where PtrSize and RegSize were mixed up

I'm pretty sure I wrote some of them :D

Reply all
Reply to author
Forward
0 new messages