[vm/ffi] Fix double shadow space on safepoint slow path

Fixes: https://github.com/dart-lang/sdk/issues/37175
Change-Id: I096a9c43ed0d500cc0d4f70a72ae53b156e1e1e2
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try, app-kernel-linux-debug-x64-try, vm-kernel-linux-debug-simdbc64-try,vm-kernel-mac-debug-simdbc64-try,vm-kernel-reload-mac-debug-simdbc64-try,vm-kernel-linux-debug-ia32-try,vm-dartkb-linux-debug-simarm64-try,vm-kernel-win-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105300
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
diff --git a/runtime/vm/compiler/assembler/assembler_x64.cc b/runtime/vm/compiler/assembler/assembler_x64.cc
index f9e725b..31b7828 100644
--- a/runtime/vm/compiler/assembler/assembler_x64.cc
+++ b/runtime/vm/compiler/assembler/assembler_x64.cc
@@ -188,7 +188,9 @@
   movq(TMP,
        Address(THR, compiler::target::Thread::enter_safepoint_stub_offset()));
   movq(TMP, FieldAddress(TMP, compiler::target::Code::entry_point_offset()));
-  CallCFunction(TMP);
+  // Use call instead of CFunctionCall to prevent having to clean up shadow
+  // space afterwards. This is possible because safepoint stub has no arguments.
+  call(TMP);
 
   Bind(&done);
 }
@@ -209,7 +211,9 @@
   movq(TMP,
        Address(THR, compiler::target::Thread::exit_safepoint_stub_offset()));
   movq(TMP, FieldAddress(TMP, compiler::target::Code::entry_point_offset()));
-  CallCFunction(TMP);
+  // Use call instead of CFunctionCall to prevent having to clean up shadow
+  // space afterwards. This is possible because safepoint stub has no arguments.
+  call(TMP);
 
   Bind(&done);