-
-
Notifications
You must be signed in to change notification settings - Fork 670
Will AS have support for pointers and references? #1228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
One aspect there is that AssemblyScript doesn't have a stack on its own (in linear memory) but exclusively relies on Wasm's execution stack, which one can't take an address of / into. So, typically, one would either make a heap allocation or reserve some space in static memory to reuse for this purpose, as Max pointed out. Open to suggestions on how to improve this :) |
Related: #1233 Might be useful here since it works very much like |
Well, I had something like this in my mind. But, to be honest, I don't really understand all the implications... Add the following global functions:
After that, * and & could be syntactic sugar that calls these functions in the background. |
WebAssembly hasn't shadow stack. It means only heap or objects in static sections could be interpret as references. In this case only objects could reference and dereference via |
Btw if you want more high-level and safe pointer (and zero-cost btw) you may interested in this experiment: https://github.com/AssemblyScript/assemblyscript/blob/master/tests/compiler/std/pointer.ts#L3 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hey guys,
I was just curious about this and I wanted to hear your thoughts.
Do you guys intend to add support for * and & to the language?
I understand that this might have consequences with the GC implementation and to TS Portability, but there are situations in which we need to call another application ABI and they take pointers as parameters.
See this example from Yuval Kohavi (@yuval-k) here:
https://github.com/solo-io/proxy-runtime/blob/master/assembly/runtime.ts#L207-L212
In order to make this work, he had to create a Reference object like so:
https://github.com/solo-io/proxy-runtime/blob/master/assembly/runtime.ts#L33-L39
This was a clever workaround, but do you guys intend to provide better syntax for such things? What are your thoughts about it?
Thanks,
Mario
The text was updated successfully, but these errors were encountered: