sway icon indicating copy to clipboard operation
sway copied to clipboard

Add raw untyped pointer type

Open canndrew opened this issue 3 years ago • 5 comments

This PR adds a raw_ptr type to sway. These are implemented in sway-core as TypeInfo::RawUntypedPtr, but are (currently) lowered to Uint(64) in sway-ir. Raw pointers can only be created and manipulated using asm blocks or by using the memory-manipulating functions in the standard library which have been updated to use this type rather than u64.

It's still possible to return a raw_ptr across a script boundary, so #2551 isn't fixed yet. But this PR puts the groundwork in place so that the necessary checks can be added in a follow-up PR.

canndrew avatar Sep 02 '22 10:09 canndrew

CI failure @canndrew

otrho avatar Sep 03 '22 03:09 otrho

@otrho: This should be good to go now.

canndrew avatar Sep 06 '22 09:09 canndrew

Marking as a draft pending discussions w/ SDK team and an RFC.

sezna avatar Sep 08 '22 14:09 sezna

This is certainly the right approach here and I think this is a good change! Thanks @canndrew.

Thant being said, this feels a bit rushed and I'm not comfortable with disabling tests until further notice. I'd like to sync up with the SDK team on this first and make sure we have path forward before merging it and breaking a bunch of things.

I will turn this into a draft in the mean time.

mohammadfawaz avatar Sep 08 '22 14:09 mohammadfawaz

There are a bunch of new functions in std related to the gtf opcode which are explicitly meant to return pointers (but currently return u64s). They would probably be good candidates for using this new type when it lands. i.e: https://github.com/FuelLabs/sway/blob/69ea1c9b787929d3cfc942ece5f9df7fdc675ef9/sway-lib-std/src/tx.sw#L156

nfurfaro avatar Sep 22 '22 12:09 nfurfaro

Closing this in favor of https://github.com/FuelLabs/sway/pull/2828.

mohammadfawaz avatar Oct 15 '22 16:10 mohammadfawaz