From dbd29ed12b98c44688606efa72986138334b792a Mon Sep 17 00:00:00 2001 From: Dhruv Chopra Date: Mon, 7 Oct 2019 16:13:26 -0700 Subject: [PATCH] Use JITServer check to create a relocation record for interface calls [skip ci] Signed-off-by: Dhruv Chopra --- runtime/compiler/p/codegen/CallSnippet.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/compiler/p/codegen/CallSnippet.cpp b/runtime/compiler/p/codegen/CallSnippet.cpp index 569d2a3e316..1166a858043 100644 --- a/runtime/compiler/p/codegen/CallSnippet.cpp +++ b/runtime/compiler/p/codegen/CallSnippet.cpp @@ -719,7 +719,7 @@ uint8_t *TR::PPCInterfaceCallSnippet::emitSnippetBody() { int32_t *patchAddr = (int32_t *)getLowerInstruction()->getBinaryEncoding(); intptrj_t addrValue = (intptrj_t)cursor; - if (!comp->compileRelocatableCode()) + if (!comp->compileRelocatableCode() && !comp->isOutOfProcessCompilation()) { // If the high nibble is 0 and the next nibble's high bit is clear, change the first instruction to a nop and the third to a li // Next nibble's high bit needs to be clear in order to use li (because li will sign extend the immediate) @@ -744,6 +744,10 @@ uint8_t *TR::PPCInterfaceCallSnippet::emitSnippetBody() } else { + // We must take this path for all compiles that need to generate relocatable code (ex. AOT, outOfProcess). + // The immediate fields of relocatable instructions must be clear. This is because when performing the relocation, + // we OR the new address into the fields. So if the fields are not already clear, then OR'ing the new address can + // result in garbage data. cg()->addExternalRelocation(new (cg()->trHeapMemory()) TR::BeforeBinaryEncodingExternalRelocation(getUpperInstruction(), (uint8_t *)(addrValue), (uint8_t *)fixedSequence4,