83 // instruction-word-aligned.
84 //
85 // Used in the runtime linkage of calls; see class CompiledIC.
86 //
87 // Add parameter assert_lock to switch off assertion
88 // during code generation, where no patching lock is needed.
89 void NativeCall::set_destination_mt_safe(address dest, bool assert_lock) {
90 assert(!assert_lock ||
91 (Patching_lock->is_locked() || SafepointSynchronize::is_at_safepoint()),
92 "concurrent code patching");
93
94 ResourceMark rm;
95 int code_size = 1 * BytesPerInstWord;
96 address addr_call = addr_at(0);
97 assert(MacroAssembler::is_bl(*(int*)addr_call), "unexpected code at call-site");
98
99 CodeBuffer cb(addr_call, code_size + 1);
100 MacroAssembler* a = new MacroAssembler(&cb);
101
102 // Patch the call.
103 if (ReoptimizeCallSequences &&
104 a->is_within_range_of_b(dest, addr_call)) {
105 a->bl(dest);
106 } else {
107 address trampoline_stub_addr = get_trampoline();
108
109 // We did not find a trampoline stub because the current codeblob
110 // does not provide this information. The branch will be patched
111 // later during a final fixup, when all necessary information is
112 // available.
113 if (trampoline_stub_addr == 0)
114 return;
115
116 // Patch the constant in the call's trampoline stub.
117 NativeCallTrampolineStub_at(trampoline_stub_addr)->set_destination(dest);
118
119 a->bl(trampoline_stub_addr);
120 }
121 ICache::ppc64_flush_icache_bytes(addr_call, code_size);
122 }
123
124 address NativeCall::get_trampoline() {
125 address call_addr = addr_at(0);
126
127 CodeBlob *code = CodeCache::find_blob(call_addr);
128 assert(code != NULL, "Could not find the containing code blob");
129
130 // There are no relocations available when the code gets relocated
131 // because of CodeBuffer expansion.
132 if (code->relocation_size() == 0)
133 return NULL;
134
135 address bl_destination = Assembler::bxx_destination(call_addr);
136 if (code->content_contains(bl_destination) &&
137 is_NativeCallTrampolineStub_at(bl_destination))
138 return bl_destination;
139
140 // If the codeBlob is not a nmethod, this is because we get here from the
|
83 // instruction-word-aligned.
84 //
85 // Used in the runtime linkage of calls; see class CompiledIC.
86 //
87 // Add parameter assert_lock to switch off assertion
88 // during code generation, where no patching lock is needed.
89 void NativeCall::set_destination_mt_safe(address dest, bool assert_lock) {
90 assert(!assert_lock ||
91 (Patching_lock->is_locked() || SafepointSynchronize::is_at_safepoint()),
92 "concurrent code patching");
93
94 ResourceMark rm;
95 int code_size = 1 * BytesPerInstWord;
96 address addr_call = addr_at(0);
97 assert(MacroAssembler::is_bl(*(int*)addr_call), "unexpected code at call-site");
98
99 CodeBuffer cb(addr_call, code_size + 1);
100 MacroAssembler* a = new MacroAssembler(&cb);
101
102 // Patch the call.
103 if (!ReoptimizeCallSequences || !a->is_within_range_of_b(dest, addr_call)) {
104 address trampoline_stub_addr = get_trampoline();
105
106 // We did not find a trampoline stub because the current codeblob
107 // does not provide this information. The branch will be patched
108 // later during a final fixup, when all necessary information is
109 // available.
110 if (trampoline_stub_addr == 0)
111 return;
112
113 // Patch the constant in the call's trampoline stub.
114 NativeCallTrampolineStub_at(trampoline_stub_addr)->set_destination(dest);
115 dest = trampoline_stub_addr;
116 }
117
118 OrderAccess::release();
119 a->bl(dest);
120
121 ICache::ppc64_flush_icache_bytes(addr_call, code_size);
122 }
123
124 address NativeCall::get_trampoline() {
125 address call_addr = addr_at(0);
126
127 CodeBlob *code = CodeCache::find_blob(call_addr);
128 assert(code != NULL, "Could not find the containing code blob");
129
130 // There are no relocations available when the code gets relocated
131 // because of CodeBuffer expansion.
132 if (code->relocation_size() == 0)
133 return NULL;
134
135 address bl_destination = Assembler::bxx_destination(call_addr);
136 if (code->content_contains(bl_destination) &&
137 is_NativeCallTrampolineStub_at(bl_destination))
138 return bl_destination;
139
140 // If the codeBlob is not a nmethod, this is because we get here from the
|