|
39 | 39 | #ifdef COMPILER1
|
40 | 40 | #include "c1/c1_Runtime1.hpp"
|
41 | 41 | #endif
|
| 42 | +#if INCLUDE_JVMCI |
| 43 | +#include "jvmci/jvmciEnv.hpp" |
| 44 | +#endif |
42 | 45 |
|
43 | 46 | void NativeCall::verify() {
|
44 | 47 | assert(NativeCall::is_call_at((address)this), "unexpected code at call site");
|
@@ -524,23 +527,26 @@ void NativeCallTrampolineStub::set_destination(address new_destination) {
|
524 | 527 | OrderAccess::release();
|
525 | 528 | }
|
526 | 529 |
|
| 530 | +#if INCLUDE_JVMCI |
527 | 531 | // Generate a trampoline for a branch to dest. If there's no need for a
|
528 | 532 | // trampoline, simply patch the call directly to dest.
|
529 |
| -address NativeCall::trampoline_jump(CodeBuffer &cbuf, address dest) { |
| 533 | +void NativeCall::trampoline_jump(CodeBuffer &cbuf, address dest, JVMCI_TRAPS) { |
530 | 534 | MacroAssembler a(&cbuf);
|
531 |
| - address stub = NULL; |
532 |
| - |
533 |
| - if (a.far_branches() |
534 |
| - && ! is_NativeCallTrampolineStub_at(instruction_address() + displacement())) { |
535 |
| - stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest); |
536 |
| - } |
537 | 535 |
|
538 |
| - if (stub == NULL) { |
539 |
| - // If we generated no stub, patch this call directly to dest. |
540 |
| - // This will happen if we don't need far branches or if there |
541 |
| - // already was a trampoline. |
| 536 | + if (!a.far_branches()) { |
| 537 | + // If not using far branches, patch this call directly to dest. |
542 | 538 | set_destination(dest);
|
| 539 | + } else if (!is_NativeCallTrampolineStub_at(instruction_address() + displacement())) { |
| 540 | + // If we want far branches and there isn't a trampoline stub, emit one. |
| 541 | + address stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest); |
| 542 | + if (stub == nullptr) { |
| 543 | + JVMCI_ERROR("could not emit trampoline stub - code cache is full"); |
| 544 | + } |
| 545 | + // The relocation created while emitting the stub will ensure this |
| 546 | + // call instruction is subsequently patched to call the stub. |
| 547 | + } else { |
| 548 | + // Not sure how this can be happen but be defensive |
| 549 | + JVMCI_ERROR("single-use stub should not exist"); |
543 | 550 | }
|
544 |
| - |
545 |
| - return stub; |
546 | 551 | }
|
| 552 | +#endif |
0 commit comments