Ensures that there is enough space for return values on the stack. This function is called at the end of all blocks and when branching from within blocks.
(
ret_area: &RetArea,
context: &mut CodeGenContext<Emission>,
masm: &mut M,
)
| 967 | /// This function is called at the end of all blocks and when branching from |
| 968 | /// within blocks. |
| 969 | fn ensure_ret_area<M>( |
| 970 | ret_area: &RetArea, |
| 971 | context: &mut CodeGenContext<Emission>, |
| 972 | masm: &mut M, |
| 973 | ) -> Result<()> |
| 974 | where |
| 975 | M: MacroAssembler, |
| 976 | { |
| 977 | ensure!(ret_area.is_sp(), CodeGenError::sp_addressing_expected()); |
| 978 | // Save any live registers and locals when exiting the block to ensure |
| 979 | // that the respective values are correctly located in memory. |
| 980 | // See [Self::adjust_stack_results] for more details. |
| 981 | context.spill(masm)?; |
| 982 | if ret_area.unwrap_sp() > masm.sp_offset()? { |
| 983 | masm.reserve_stack(ret_area.unwrap_sp().as_u32() - masm.sp_offset()?.as_u32())? |
| 984 | } |
| 985 | |
| 986 | Ok(()) |
| 987 | } |
| 988 | |
| 989 | /// Loads the return pointer, if it exists, into the next available register. |
| 990 | fn maybe_load_retptr<M>( |