|
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");
|
@@ -523,26 +526,29 @@ void NativeCallTrampolineStub::set_destination(address new_destination) {
|
523 | 526 | OrderAccess::release();
|
524 | 527 | }
|
525 | 528 |
|
| 529 | +#if INCLUDE_JVMCI |
526 | 530 | // Generate a trampoline for a branch to dest. If there's no need for a
|
527 | 531 | // trampoline, simply patch the call directly to dest.
|
528 |
| -address NativeCall::trampoline_jump(CodeBuffer &cbuf, address dest) { |
| 532 | +void NativeCall::trampoline_jump(CodeBuffer &cbuf, address dest, JVMCI_TRAPS) { |
529 | 533 | MacroAssembler a(&cbuf);
|
530 |
| - address stub = NULL; |
531 |
| - |
532 |
| - if (a.far_branches() |
533 |
| - && ! is_NativeCallTrampolineStub_at(instruction_address() + displacement())) { |
534 |
| - stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest); |
535 |
| - } |
536 | 534 |
|
537 |
| - if (stub == NULL) { |
538 |
| - // If we generated no stub, patch this call directly to dest. |
539 |
| - // This will happen if we don't need far branches or if there |
540 |
| - // already was a trampoline. |
| 535 | + if (!a.far_branches()) { |
| 536 | + // If not using far branches, patch this call directly to dest. |
541 | 537 | set_destination(dest);
|
| 538 | + } else if (!is_NativeCallTrampolineStub_at(instruction_address() + displacement())) { |
| 539 | + // If we want far branches and there isn't a trampoline stub, emit one. |
| 540 | + address stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest); |
| 541 | + if (stub == nullptr) { |
| 542 | + JVMCI_ERROR("could not emit trampoline stub - code cache is full"); |
| 543 | + } |
| 544 | + // The relocation created while emitting the stub will ensure this |
| 545 | + // call instruction is subsequently patched to call the stub. |
| 546 | + } else { |
| 547 | + // Not sure how this can be happen but be defensive |
| 548 | + JVMCI_ERROR("single-use stub should not exist"); |
542 | 549 | }
|
543 |
| - |
544 |
| - return stub; |
545 | 550 | }
|
| 551 | +#endif |
546 | 552 |
|
547 | 553 | void NativePostCallNop::make_deopt() {
|
548 | 554 | NativeDeoptInstruction::insert(addr_at(0));
|
|
0 commit comments