@@ -21,9 +21,12 @@ DEFINE_FLAG(bool,
2121 false ,
2222 " Generate always trampolines (for testing purposes)." );
2323
24- // The trampolines will have a 1-word object header in front of them.
24+ // The trampolines will be disguised as FreeListElement objects, with a 1-word
25+ // object header in front of the jump code.
2526const intptr_t kOffsetInTrampoline = kWordSize ;
26- const intptr_t kTrampolineSize = OS::kMaxPreferredCodeAlignment ;
27+ const intptr_t kTrampolineSize = Utils::RoundUp(
28+ kOffsetInTrampoline + PcRelativeTrampolineJumpPattern::kLengthInBytes ,
29+ kObjectAlignment );
2730
2831CodeRelocator::CodeRelocator (Thread* thread,
2932 GrowableArray<RawCode*>* code_objects,
@@ -408,7 +411,12 @@ bool CodeRelocator::IsTargetInRangeFor(UnresolvedCall* unresolved_call,
408411static void MarkAsFreeListElement (uint8_t * trampoline_bytes,
409412 intptr_t trampoline_length) {
410413 uint32_t tags = 0 ;
414+ #if defined(IS_SIMARM_X64)
415+ // Account for difference in kObjectAlignment between host and target.
416+ tags = RawObject::SizeTag::update (trampoline_length * 2 , tags);
417+ #else
411418 tags = RawObject::SizeTag::update (trampoline_length, tags);
419+ #endif
412420 tags = RawObject::ClassIdTag::update (kFreeListElement , tags);
413421 tags = RawObject::OldBit::update (true , tags);
414422 tags = RawObject::OldAndNotMarkedBit::update (true , tags);
@@ -464,9 +472,6 @@ void CodeRelocator::BuildTrampolinesForAlmostOutOfRangeCalls() {
464472 // buffer.
465473 auto trampoline_bytes = new uint8_t [kTrampolineSize ];
466474 memset (trampoline_bytes, 0x00 , kTrampolineSize );
467- ASSERT ((kOffsetInTrampoline +
468- PcRelativeTrampolineJumpPattern::kLengthInBytes ) <
469- kTrampolineSize );
470475 auto unresolved_trampoline = new UnresolvedTrampoline{
471476 unresolved_call->callee ,
472477 unresolved_call->offset_into_target ,
0 commit comments