Xudong-Huang / generator-rs

rust stackful generator library
Apache License 2.0
303 stars 37 forks source link

Any way to get stack start of generator? #43

Open playXE opened 1 year ago

playXE commented 1 year ago

Hello! How do I get stack start of generator? I need this for conservative roots in my GC

Xudong-Huang commented 1 year ago

The Generator::into_raw API would return the internal stack memory pointer.

The Generator::from_raw API would convert from stack pointer back to Generator

playXE commented 1 year ago

Thanks! Would it also be possible to get saved context registers?

Xudong-Huang commented 1 year ago

Actually the start of the stack memory is the saved context.

playXE commented 1 year ago

Actually the start of the stack memory is the saved context.

I am a little bit confused about this? Should I still use into_raw? Also, does the pointer returned by into_raw contain registers that are saved during context switch?

Xudong-Huang commented 1 year ago

The memory looks like this: fixed size context memory(including saved registers) + real generator function stack. Yes, you should use into_raw, the pointer of the memory contains every thing needed to save.

playXE commented 1 year ago

The memory looks like this: fixed size context memory(including saved registers) + real generator function stack. Yes, you should use into_raw, the pointer of the memory contains every thing needed to save.

Alright, but how do I get the size of that pointer as well? I need to tell my GC the size for proper processing

playXE commented 1 year ago

The memory looks like this: fixed size context memory(including saved registers) + real generator function stack. Yes, you should use into_raw, the pointer of the memory contains every thing needed to save.

Alright, but how do I get the size of that pointer as well? I need to tell my GC the size for proper processing. Looking at what it returns it does not look like it actually provides full access to full context information, I actually need to calculate offsets into GeneratorImpl?