RFR: 8299570: [JVMCI] Insufficient error handling when CodeBuffer is exhausted [v4]

Doug Simon dnsimon at openjdk.org
Wed Mar 8 11:12:16 UTC 2023


On Wed, 8 Mar 2023 11:01:18 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> I'm not following - isn't this exactly what the code is doing? Maybe you could demonstrate how you think it should look.
>
> Maybe it would be nicer to get the `! far_branches` code path out of the way first, and return immediately.

Something like this?

diff --git a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp
index 88dc59f80d0..83ec182d2c7 100644
--- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp
@@ -532,21 +532,22 @@ void NativeCallTrampolineStub::set_destination(address new_destination) {
 void NativeCall::trampoline_jump(CodeBuffer &cbuf, address dest, JVMCI_TRAPS) {
   MacroAssembler a(&cbuf);
 
-  if (a.far_branches()) {
-    if (!is_NativeCallTrampolineStub_at(instruction_address() + displacement())) {
-      address stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest);
-      if (stub == nullptr) {
-        JVMCI_ERROR("could not emit trampoline stub - code cache is full");
-      }
-      // The relocation is created while emitting the stub will ensure this
-      // call instruction is subsequently patched to call the stub.
-    } else {
-      // Not sure how this can be happen but be defensive
-      JVMCI_ERROR("single-use stub should not exist");
-    }
-  } else {
+  if (!a.far_branches()) {
     // If not using far branches, patch this call directly to dest.
     set_destination(dest);
+    return;
+  }
+
+  if (!is_NativeCallTrampolineStub_at(instruction_address() + displacement())) {
+    address stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest);
+    if (stub == nullptr) {
+      JVMCI_ERROR("could not emit trampoline stub - code cache is full");
+    }
+    // The relocation is created while emitting the stub will ensure this
+    // call instruction is subsequently patched to call the stub.
+  } else {
+    // Not sure how this can be happen but be defensive
+    JVMCI_ERROR("single-use stub should not exist");
   }
 }
 #endif

-------------

PR: https://git.openjdk.org/jdk/pull/11945


More information about the hotspot-compiler-dev mailing list