/* * Copyright (c) 2018, 2020, Oracle and/or its affiliates. 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. *
*/
LIR_Opr addr_opr; if (is_array) {
addr_opr = LIR_OprFact::address(gen->emit_array_address(base.result(), offset, access.type()));
} elseif (needs_patching) { // we need to patch the offset in the instruction so don't allow // generate_address to try to be smart about emitting the -1. // Otherwise the patching code won't know how to find the // instruction to patch.
addr_opr = LIR_OprFact::address(new LIR_Address(base.result(), PATCHED_ADDR, access.type()));
} else {
addr_opr = LIR_OprFact::address(gen->generate_address(base.result(), offset, 0, 0, access.type()));
}
void BarrierSetC1::generate_referent_check(LIRAccess& access, LabelObj* cont) { // We might be reading the value of the referent field of a // Reference object in order to attach it back to the live // object graph. If G1 is enabled then we need to record // the value that is being returned in an SATB log buffer. // // We need to generate code similar to the following... // // if (offset == java_lang_ref_Reference::referent_offset()) { // if (src != NULL) { // if (klass(src)->reference_type() != REF_NONE) { // pre_barrier(..., value, ...); // } // } // }
bool gen_pre_barrier = true; // Assume we need to generate pre_barrier. bool gen_offset_check = true; // Assume we need to generate the offset guard. bool gen_source_check = true; // Assume we need to check the src object for null. bool gen_type_check = true; // Assume we need to check the reference_type.
LIRGenerator *gen = access.gen();
LIRItem& base = access.base().item();
LIR_Opr offset = access.offset().opr();
if (off_con != (jlong) java_lang_ref_Reference::referent_offset()) { // The constant offset is something other than referent_offset. // We can skip generating/checking the remaining guards and // skip generation of the code stub.
gen_pre_barrier = false;
} else { // The constant offset is the same as referent_offset - // we do not need to generate a runtime offset check.
gen_offset_check = false;
}
}
// We don't need to generate stub if the source object is an array if (gen_pre_barrier && base.type()->is_array()) {
gen_pre_barrier = false;
}
if (gen_pre_barrier) { // We still need to continue with the checks. if (base.is_constant()) {
ciObject* src_con = base.get_jobject_constant();
guarantee(src_con != NULL, "no source constant");
if (src_con->is_null_object()) { // The constant src object is null - We can skip // generating the code stub.
gen_pre_barrier = false;
} else { // Non-null constant source object. We still have to generate // the slow stub - but we don't need to generate the runtime // null object check.
gen_source_check = false;
}
}
} if (gen_pre_barrier && !PatchALot) { // Can the klass of object be statically determined to be // a sub-class of Reference?
ciType* type = base.value()->declared_type(); if ((type != NULL) && type->is_loaded()) { if (type->is_subtype_of(gen->compilation()->env()->Reference_klass())) {
gen_type_check = false;
} elseif (type->is_klass() &&
!gen->compilation()->env()->Object_klass()->is_subtype_of(type->as_klass())) { // Not Reference and not Object klass.
gen_pre_barrier = false;
}
}
}
if (gen_pre_barrier) { // We can have generate one runtime check here. Let's start with // the offset check. // Allocate temp register to base and load it here, otherwise // control flow below may confuse register allocator.
LIR_Opr base_reg = gen->new_register(T_OBJECT);
__ move(base.result(), base_reg); if (gen_offset_check) { // if (offset != referent_offset) -> continue // If offset is an int then we can do the comparison with the // referent_offset constant; otherwise we need to move // referent_offset into a temporary register and generate // a reg-reg compare.
LIR_Opr referent_off;
if (offset->type() == T_INT) {
referent_off = LIR_OprFact::intConst(java_lang_ref_Reference::referent_offset());
} else {
assert(offset->type() == T_LONG, "what else?");
referent_off = gen->new_register(T_LONG);
__ move(LIR_OprFact::longConst(java_lang_ref_Reference::referent_offset()), referent_off);
}
__ cmp(lir_cond_notEqual, offset, referent_off);
__ branch(lir_cond_notEqual, cont->label());
} if (gen_source_check) { // offset is a const and equals referent offset // if (source == null) -> continue
__ cmp(lir_cond_equal, base_reg, LIR_OprFact::oopConst(NULL));
__ branch(lir_cond_equal, cont->label());
}
LIR_Opr src_klass = gen->new_register(T_METADATA); if (gen_type_check) { // We have determined that offset == referent_offset && src != null. // if (src->_klass->_reference_type == REF_NONE) -> continue
gen->load_klass(base_reg, src_klass, NULL);
LIR_Address* reference_type_addr = new LIR_Address(src_klass, in_bytes(InstanceKlass::reference_type_offset()), T_BYTE);
LIR_Opr reference_type = gen->new_register(T_INT);
__ move(reference_type_addr, reference_type);
__ cmp(lir_cond_equal, reference_type, LIR_OprFact::intConst(REF_NONE));
__ branch(lir_cond_equal, cont->label());
}
}
}
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 und die Messung sind noch experimentell.