/* * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// Pass the array index in Z_R1_scratch which is not managed by linear scan. if (_index->is_cpu_register()) {
__ lgr_if_needed(Z_R1_scratch, _index->as_register());
} else {
__ load_const_optimized(Z_R1_scratch, _index->as_jint());
}
void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) {
address a; if (_info->deoptimize_on_exception()) { // Deoptimize, do not throw the exception, because it is probably wrong to do it here.
a = Runtime1::entry_for (Runtime1::predicate_failed_trap_id);
} else {
a = Runtime1::entry_for (Runtime1::throw_null_pointer_exception_id);
}
void MonitorExitStub::emit_code(LIR_Assembler* ce) {
__ bind(_entry); // Move address of the BasicObjectLock into Z_R1_scratch. if (_compute_lock) { // Lock_reg was destroyed by fast unlocking attempt => recompute it.
ce->monitor_address(_monitor_ix, FrameMap::as_opr(Z_R1_scratch));
} else {
__ lgr_if_needed(Z_R1_scratch, _lock_reg->as_register());
} // Note: non-blocking leaf routine => no call info needed.
Runtime1::StubID exit_id; if (ce->compilation()->has_fpu_code()) {
exit_id = Runtime1::monitorexit_id;
} else {
exit_id = Runtime1::monitorexit_nofpu_id;
}
ce->emit_call_c(Runtime1::entry_for (exit_id));
CHECK_BAILOUT();
__ branch_optimized(Assembler::bcondAlways, _continuation);
}
// Implementation of patching: // - Copy the code at given offset to an inlined buffer (first the bytes, then the number of bytes). // - Replace original code with a call to the stub. // At Runtime: // - call to stub, jump to runtime. // - in runtime: Preserve all registers (especially objects, i.e., source and destination object). // - in runtime: After initializing class, restore original code, reexecute instruction.
void PatchingStub::align_patch_site(MacroAssembler* masm) { #ifndef PRODUCT constchar* bc; switch (_id) { case access_field_id: bc = "patch site (access_field)"; break; case load_klass_id: bc = "patch site (load_klass)"; break; case load_mirror_id: bc = "patch site (load_mirror)"; break; case load_appendix_id: bc = "patch site (load_appendix)"; break; default: bc = "patch site (unknown patch id)"; break;
}
masm->block_comment(bc); #endif
void PatchingStub::emit_code(LIR_Assembler* ce) { // Copy original code here.
assert(NativeGeneralJump::instruction_size <= _bytes_to_copy && _bytes_to_copy <= 0xFF, "not enough room for call, need %d", _bytes_to_copy);
NearLabel call_patch;
int being_initialized_entry = __ offset();
if (_id == load_klass_id) { // Produce a copy of the load klass instruction for use by the case being initialized. #ifdef ASSERT
address start = __ pc(); #endif
AddressLiteral addrlit((intptr_t)0, metadata_Relocation::spec(_index));
__ load_const(_obj, addrlit);
#ifdef ASSERT for (int i = 0; i < _bytes_to_copy; i++) {
address ptr = (address)(_pc_start + i); int a_byte = (*ptr) & 0xFF;
assert(a_byte == *start++, "should be the same code");
} #endif
} elseif (_id == load_mirror_id || _id == load_appendix_id) { // Produce a copy of the load mirror instruction for use by the case being initialized. #ifdef ASSERT
address start = __ pc(); #endif
AddressLiteral addrlit((intptr_t)0, oop_Relocation::spec(_index));
__ load_const(_obj, addrlit);
#ifdef ASSERT for (int i = 0; i < _bytes_to_copy; i++) {
address ptr = (address)(_pc_start + i); int a_byte = (*ptr) & 0xFF;
assert(a_byte == *start++, "should be the same code");
} #endif
} else { // Make a copy of the code which is going to be patched. for (int i = 0; i < _bytes_to_copy; i++) {
address ptr = (address)(_pc_start + i); int a_byte = (*ptr) & 0xFF;
__ emit_int8 (a_byte);
}
}
address end_of_patch = __ pc(); int bytes_to_skip = 0; if (_id == load_mirror_id) { int offset = __ offset(); if (CommentedAssembly) {
__ block_comment(" being_initialized check");
}
// Static field accesses have special semantics while the class // initializer is being run, so we emit a test which can be used to // check that this code is being executed by the initializing // thread.
assert(_obj != noreg, "must be a valid register");
assert(_index >= 0, "must have oop index");
__ z_lg(Z_R1_scratch, java_lang_Class::klass_offset(), _obj);
__ z_cg(Z_thread, Address(Z_R1_scratch, InstanceKlass::init_thread_offset()));
__ branch_optimized(Assembler::bcondNotEqual, call_patch);
// Load_klass patches may execute the patched code before it's // copied back into place so we need to jump back into the main // code of the nmethod to continue execution.
__ branch_optimized(Assembler::bcondAlways, _patch_site_continuation);
// Make sure this extra code gets skipped.
bytes_to_skip += __ offset() - offset;
}
// Now emit the patch record telling the runtime how to find the // pieces of the patch. We only need 3 bytes but to help the disassembler // we make the data look like the following add instruction: // A R1, D2(X2, B2) // which requires 4 bytes. int sizeof_patch_record = 4;
bytes_to_skip += sizeof_patch_record;
// Emit the offsets needed to find the code to patch. int being_initialized_entry_offset = __ offset() - being_initialized_entry + sizeof_patch_record;
// Emit the patch record: opcode of the add followed by 3 bytes patch record data.
__ emit_int8((int8_t)(A_ZOPC>>24));
__ emit_int8(being_initialized_entry_offset);
__ emit_int8(bytes_to_skip);
__ emit_int8(_bytes_to_copy);
address patch_info_pc = __ pc();
assert(patch_info_pc - end_of_patch == bytes_to_skip, "incorrect patch info");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.