merged_wasm_arm_tail-call_free_scratch_register_earlier.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Thibaud Michaud <[email protected]>
  3. Date: Wed, 18 Dec 2024 12:14:14 +0100
  4. Subject: Merged: [wasm][arm][tail-call] Free scratch register earlier
  5. In Liftoff's PrepareTailCall, we kept the UseScratchRegisterScope open
  6. for longer than necessary. Close the scope earlier to ensure that we
  7. don't run out of scratch registers in the last "sub" instruction if it
  8. needs one.
  9. [email protected]
  10. Fixed: 384565015
  11. (cherry picked from commit 7c9e628fd07a457635db098483f7a956ecfa385a)
  12. Change-Id: I0100569d5276aa9188ccbc3c7ee409a9dd49be31
  13. Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6148448
  14. Reviewed-by: Daniel Lehmann <[email protected]>
  15. Commit-Queue: Thibaud Michaud <[email protected]>
  16. Cr-Commit-Position: refs/branch-heads/13.0@{#49}
  17. Cr-Branched-From: 4be854bd71ea878a25b236a27afcecffa2e29360-refs/heads/13.0.245@{#1}
  18. Cr-Branched-From: 1f5183f7ad6cca21029fd60653d075730c644432-refs/heads/main@{#96103}
  19. diff --git a/src/wasm/baseline/arm/liftoff-assembler-arm-inl.h b/src/wasm/baseline/arm/liftoff-assembler-arm-inl.h
  20. index 959dbf3b1c36e32c473b233a95f0bb149ceebaff..cb95a6f03aa4873525da2ff2eab3f9573372e3b8 100644
  21. --- a/src/wasm/baseline/arm/liftoff-assembler-arm-inl.h
  22. +++ b/src/wasm/baseline/arm/liftoff-assembler-arm-inl.h
  23. @@ -486,21 +486,23 @@ void LiftoffAssembler::CallFrameSetupStub(int declared_function_index) {
  24. void LiftoffAssembler::PrepareTailCall(int num_callee_stack_params,
  25. int stack_param_delta) {
  26. - UseScratchRegisterScope temps(this);
  27. - Register scratch = temps.Acquire();
  28. + {
  29. + UseScratchRegisterScope temps(this);
  30. + Register scratch = temps.Acquire();
  31. - // Push the return address and frame pointer to complete the stack frame.
  32. - sub(sp, sp, Operand(8));
  33. - ldr(scratch, MemOperand(fp, 4));
  34. - str(scratch, MemOperand(sp, 4));
  35. - ldr(scratch, MemOperand(fp, 0));
  36. - str(scratch, MemOperand(sp, 0));
  37. -
  38. - // Shift the whole frame upwards.
  39. - int slot_count = num_callee_stack_params + 2;
  40. - for (int i = slot_count - 1; i >= 0; --i) {
  41. - ldr(scratch, MemOperand(sp, i * 4));
  42. - str(scratch, MemOperand(fp, (i - stack_param_delta) * 4));
  43. + // Push the return address and frame pointer to complete the stack frame.
  44. + sub(sp, sp, Operand(8));
  45. + ldr(scratch, MemOperand(fp, 4));
  46. + str(scratch, MemOperand(sp, 4));
  47. + ldr(scratch, MemOperand(fp, 0));
  48. + str(scratch, MemOperand(sp, 0));
  49. +
  50. + // Shift the whole frame upwards.
  51. + int slot_count = num_callee_stack_params + 2;
  52. + for (int i = slot_count - 1; i >= 0; --i) {
  53. + ldr(scratch, MemOperand(sp, i * 4));
  54. + str(scratch, MemOperand(fp, (i - stack_param_delta) * 4));
  55. + }
  56. }
  57. // Set the new stack and frame pointer.