提交 a839ff9f 编写于 作者: J johnc

7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure

Summary: Allow long type for offset in G1 code in compiler implementations of Unsafe.getObject
Reviewed-by: never, iveresov
上级 1c6a3923
...@@ -489,7 +489,7 @@ void G1UnsafeGetObjSATBBarrierStub::emit_code(LIR_Assembler* ce) { ...@@ -489,7 +489,7 @@ void G1UnsafeGetObjSATBBarrierStub::emit_code(LIR_Assembler* ce) {
// Is marking active? // Is marking active?
assert(thread()->is_register(), "precondition"); assert(thread()->is_register(), "precondition");
Register thread_reg = thread()->as_register(); Register thread_reg = NOT_LP64(thread()->as_register()) LP64_ONLY(thread()->as_register_lo());
Address in_progress(thread_reg, in_bytes(JavaThread::satb_mark_queue_offset() + Address in_progress(thread_reg, in_bytes(JavaThread::satb_mark_queue_offset() +
PtrQueue::byte_offset_of_active())); PtrQueue::byte_offset_of_active()));
......
...@@ -523,7 +523,7 @@ void G1UnsafeGetObjSATBBarrierStub::emit_code(LIR_Assembler* ce) { ...@@ -523,7 +523,7 @@ void G1UnsafeGetObjSATBBarrierStub::emit_code(LIR_Assembler* ce) {
// Is marking active? // Is marking active?
assert(thread()->is_register(), "precondition"); assert(thread()->is_register(), "precondition");
Register thread_reg = thread()->as_register(); Register thread_reg = NOT_LP64(thread()->as_register()) LP64_ONLY(thread()->as_register_lo());
Address in_progress(thread_reg, in_bytes(JavaThread::satb_mark_queue_offset() + Address in_progress(thread_reg, in_bytes(JavaThread::satb_mark_queue_offset() +
PtrQueue::byte_offset_of_active())); PtrQueue::byte_offset_of_active()));
......
...@@ -2062,9 +2062,12 @@ void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) { ...@@ -2062,9 +2062,12 @@ void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) {
bool gen_source_check = true; // Assume the code stub has to check the src object for null. bool gen_source_check = true; // Assume the code stub has to check the src object for null.
if (off.is_constant()) { if (off.is_constant()) {
jint off_con = off.get_jint_constant(); jlong off_con = (off.type()->is_int() ?
(jlong) off.get_jint_constant() :
off.get_jlong_constant());
if (off_con != java_lang_ref_Reference::referent_offset) {
if (off_con != (jlong) java_lang_ref_Reference::referent_offset) {
// The constant offset is something other than referent_offset. // The constant offset is something other than referent_offset.
// We can skip generating/checking the remaining guards and // We can skip generating/checking the remaining guards and
// skip generation of the code stub. // skip generation of the code stub.
...@@ -2112,15 +2115,29 @@ void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) { ...@@ -2112,15 +2115,29 @@ void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) {
// the offset check. // the offset check.
if (gen_offset_check) { if (gen_offset_check) {
// if (offset == referent_offset) -> slow code stub // if (offset == referent_offset) -> slow code stub
__ cmp(lir_cond_equal, off.result(), // If offset is an int then we can do the comparison with the
LIR_OprFact::intConst(java_lang_ref_Reference::referent_offset)); // 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 (off.type()->is_int()) {
referent_off = LIR_OprFact::intConst(java_lang_ref_Reference::referent_offset);
} else {
assert(off.type()->is_long(), "what else?");
referent_off = new_register(T_LONG);
__ move(LIR_OprFact::longConst(java_lang_ref_Reference::referent_offset), referent_off);
}
__ cmp(lir_cond_equal, off.result(), referent_off);
// Optionally generate "src == null" check. // Optionally generate "src == null" check.
stub = new G1UnsafeGetObjSATBBarrierStub(reg, src.result(), stub = new G1UnsafeGetObjSATBBarrierStub(reg, src.result(),
src_klass, thread, src_klass, thread,
gen_source_check); gen_source_check);
__ branch(lir_cond_equal, T_INT, stub); __ branch(lir_cond_equal, as_BasicType(off.type()), stub);
} else { } else {
if (gen_source_check) { if (gen_source_check) {
// offset is a const and equals referent offset // offset is a const and equals referent offset
......
...@@ -2169,7 +2169,7 @@ void LibraryCallKit::insert_g1_pre_barrier(Node* base_oop, Node* offset, Node* p ...@@ -2169,7 +2169,7 @@ void LibraryCallKit::insert_g1_pre_barrier(Node* base_oop, Node* offset, Node* p
const int reference_type_offset = instanceKlass::reference_type_offset_in_bytes() + const int reference_type_offset = instanceKlass::reference_type_offset_in_bytes() +
sizeof(oopDesc); sizeof(oopDesc);
Node* referent_off = __ ConI(java_lang_ref_Reference::referent_offset); Node* referent_off = __ ConX(java_lang_ref_Reference::referent_offset);
__ if_then(offset, BoolTest::eq, referent_off, unlikely); { __ if_then(offset, BoolTest::eq, referent_off, unlikely); {
__ if_then(base_oop, BoolTest::ne, null(), likely); { __ if_then(base_oop, BoolTest::ne, null(), likely); {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册