[vm, compiler] Fix FFI callbacks on ARM64C.

HEAP_BITS must be initialized before any variant of LoadCompressed is used.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47259
Change-Id: I01ebb4e6c2eee1e61e15c1d8cc2913d0db27c2bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214124
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
Ryan Macnak 2021-09-22 17:11:36 +00:00 committed by commit-bot@chromium.org
parent d992af7e9c
commit 306718fe1e
2 changed files with 11 additions and 1 deletions

View file

@ -128,7 +128,7 @@ class StubCodeCompiler : public AllStatic {
#elif defined(TARGET_ARCH_ARM64)
static constexpr intptr_t kNativeCallbackTrampolineSize = 12;
#if defined(DART_COMPRESSED_POINTERS)
static constexpr intptr_t kNativeCallbackSharedStubSize = 276;
static constexpr intptr_t kNativeCallbackSharedStubSize = 292;
#else
static constexpr intptr_t kNativeCallbackSharedStubSize = 268;
#endif

View file

@ -415,6 +415,13 @@ void StubCodeCompiler::GenerateJITCallbackTrampolines(
// Load the code object.
__ LoadFromOffset(R10, THR, compiler::target::Thread::callback_code_offset());
#if defined(DART_COMPRESSED_POINTERS)
// Partially setup HEAP_BITS for LoadCompressed[FieldFromOffset].
ASSERT(IsAbiPreservedRegister(HEAP_BITS)); // Need to save and restore.
__ Push(HEAP_BITS);
__ ldr(HEAP_BITS, compiler::Address(THR, target::Thread::heap_base_offset()));
__ LsrImmediate(HEAP_BITS, HEAP_BITS, 32);
#endif
__ LoadCompressedFieldFromOffset(
R10, R10, compiler::target::GrowableObjectArray::data_offset());
__ LoadCompressed(
@ -427,6 +434,9 @@ void StubCodeCompiler::GenerateJITCallbackTrampolines(
/*array=*/R10,
/*index=*/R9,
/*temp=*/TMP));
#if defined(DART_COMPRESSED_POINTERS)
__ Pop(HEAP_BITS);
#endif
__ LoadFieldFromOffset(R10, R10,
compiler::target::Code::entry_point_offset());