stack frame header struct#12
Conversation
| let num_args_with_receiver = num_parameters.max(header.argc) + 1; | ||
|
|
||
| let receiver_ptr = self.fp.add(RECEIVER_SLOT_INDEX) as *mut Value; | ||
| let receiver_ptr = self.fp.add(StackFrameHeader::RECEIVER_SLOT) as *mut Value; |
There was a problem hiding this comment.
For this, is it not possible to simply read the receiver?
There was a problem hiding this comment.
this was reading both the receiver and the args below it (for gc), which is why we couldn't just read receiver -- but that is awkward I agree, so I changed now to just have this function return args and then we visit the receiver separately
this commit:
visit reciever separately for gc
(this function still calls from_raw_parts_mut to get the args and is scary -- I think we can potentially do something about that too...)
| #[inline] | ||
| fn push_value<T>(&mut self, value: T) { | ||
| // inside const block evaluates at compile-time instead of at runtime | ||
| const { |
| // Patch the address of the return value in the stack frame | ||
| let mut return_value = Value::undefined(); | ||
| stack_frame.set_return_value_address((&mut return_value) as *mut Value); | ||
| stack_frame.header_mut().return_value_address = (&mut return_value) as *mut Value; |
There was a problem hiding this comment.
Similar to comment above, can we do this unsafety in one function? e.g. rather than header_mut you have set_return_value_addr which takes &mut return_value and does the unsafe stuff inside.
| /// not read or write directly — use [`StackFrame::return_address`], | ||
| /// [`StackFrame::set_return_address`], [`StackFrame::is_rust_caller`]. | ||
| return_address: usize, | ||
| pub return_value_address: *mut Value, |
There was a problem hiding this comment.
can we encapsulate all of these and just have getters and setters? This stuff is super unsafe so I think it is actually worth having methods for getting / setting these.
| @@ -205,24 +203,24 @@ impl<W: Width> Register<W> { | |||
| /// Construct a register referencing the current `this` value. | |||
| #[inline] | |||
| pub fn this() -> Self { | |||
There was a problem hiding this comment.
Can you explain exactly what's going on here? I'm a bit by confused. This holds the offset of the receiver field relative to the base address of the StackFrameHeader's base addr?
StackFrameHeader struct to make pushing onto stack a bit nicer and to avoid the raw indexing
ran these to test