[a64] Implement support for large stack sizes

The `SUB` instruction can only encode immediates in the form of `0xFFF`
or `0xFFF000`. In the case that the stack size is greater than `0xFFF`,
then just align the stack-size by `0x1000` to keep the bottom 12 bits
clear.
This commit is contained in:
Wunkolo 2024-06-23 14:38:06 -07:00
parent 9c572c3937
commit a8b9cd8e65
1 changed files with 8 additions and 1 deletions

View File

@ -196,7 +196,14 @@ bool A64Emitter::Emit(HIRBuilder* builder, EmitFunctionInfo& func_info) {
// IMPORTANT: any changes to the prolog must be kept in sync with // IMPORTANT: any changes to the prolog must be kept in sync with
// A64CodeCache, which dynamically generates exception information. // A64CodeCache, which dynamically generates exception information.
// Adding or changing anything here must be matched! // Adding or changing anything here must be matched!
const size_t stack_size = StackLayout::GUEST_STACK_SIZE + stack_offset; size_t stack_size = StackLayout::GUEST_STACK_SIZE + stack_offset;
// The SUB instruction can only encode immediates withi 0xFFF or 0xFFF000
// If the stack size is greater than 0xFFF, then just align it to 0x1000
if (stack_size > 0xFFF) {
stack_size = xe::align(stack_size, static_cast<size_t>(0x1000));
}
assert_true(stack_size % 16 == 0); assert_true(stack_size % 16 == 0);
func_info.stack_size = stack_size; func_info.stack_size = stack_size;
stack_size_ = stack_size; stack_size_ = stack_size;