Go assembly is a very challenging target. Simple things are easy, but anything related to memory is hard. You're much better off translating to what I call "asm.go" (using Go as though it were assembly) and letting the compiler deal with it.
Andy
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/-f3c9l_8Ypo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/a22a73fa-618d-4062-8df6-da03be0775a4n%40googlegroups.com.
--
I think I know what the issue is. It's doing one bounds check for int64(ptr)+ offset, and then another to make sure the resulting slice has at least 4 elements. What happens if you do and discard a read of m.Memory[int64(ptr)+offset+3] first? (The compiler should know that if that bounds check succeeds, the other two will succeed too, and it can elide them.)
Andy
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CAM0U__-v_ii-zTDmuBs-RftPaAZXfidbR7f5G%2BAcDUo_uZKnSQ%40mail.gmail.com.
It would be really nice to be able to say "no unsafe", though. That could be a significant distinction between wasm2go and modernc's translations.
The reason there isn't a constant for the native byte order in the standard library is explained at https://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html
If you're needing to use unsafe, and bits.ReverseBytes, to get around a limitation in the compiler, I think it would be worth filing an issue.
Andy