From bef0370063e2ca923338b7002c5d3401240ffd75 Mon Sep 17 00:00:00 2001 From: roland Date: Fri, 5 Mar 2010 13:58:34 +0100 Subject: [PATCH] 6932496: c1: deoptimization of jsr subroutine fails on sparcv9 Summary: store jsr ret bci as intptr constant in c1 debug info Reviewed-by: never --- src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp | 7 ++- src/cpu/x86/vm/c1_LIRAssembler_x86.cpp | 5 ++- src/share/vm/c1/c1_LIR.cpp | 5 ++- src/share/vm/c1/c1_LIR.hpp | 8 ++-- src/share/vm/c1/c1_LinearScan.cpp | 9 ++++ test/compiler/6932496/Test6932496.java | 51 ++++++++++++++++++++++ 6 files changed, 77 insertions(+), 8 deletions(-) create mode 100644 test/compiler/6932496/Test6932496.java diff --git a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp index 4446addd9..05804c52d 100644 --- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp +++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @@ -1072,7 +1072,8 @@ void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) { LIR_Const* c = src->as_constant_ptr(); switch (c->type()) { case T_INT: - case T_FLOAT: { + case T_FLOAT: + case T_ADDRESS: { Register src_reg = O7; int value = c->as_jint_bits(); if (value == 0) { @@ -1128,7 +1129,8 @@ void LIR_Assembler::const2mem(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmi } switch (c->type()) { case T_INT: - case T_FLOAT: { + case T_FLOAT: + case T_ADDRESS: { LIR_Opr tmp = FrameMap::O7_opr; int value = c->as_jint_bits(); if (value == 0) { @@ -1200,6 +1202,7 @@ void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_cod switch (c->type()) { case T_INT: + case T_ADDRESS: { jint con = c->as_jint(); if (to_reg->is_single_cpu()) { diff --git a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp index 5907e058c..eb1ee51bd 100644 --- a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp +++ b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @@ -628,7 +628,8 @@ void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_cod LIR_Const* c = src->as_constant_ptr(); switch (c->type()) { - case T_INT: { + case T_INT: + case T_ADDRESS: { assert(patch_code == lir_patch_none, "no patching handled here"); __ movl(dest->as_register(), c->as_jint()); break; @@ -711,6 +712,7 @@ void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) { switch (c->type()) { case T_INT: // fall through case T_FLOAT: + case T_ADDRESS: __ movl(frame_map()->address_for_slot(dest->single_stack_ix()), c->as_jint_bits()); break; @@ -746,6 +748,7 @@ void LIR_Assembler::const2mem(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmi switch (type) { case T_INT: // fall through case T_FLOAT: + case T_ADDRESS: __ movl(as_Address(addr), c->as_jint_bits()); break; diff --git a/src/share/vm/c1/c1_LIR.cpp b/src/share/vm/c1/c1_LIR.cpp index fb8cf3d01..ce8efb9b4 100644 --- a/src/share/vm/c1/c1_LIR.cpp +++ b/src/share/vm/c1/c1_LIR.cpp @@ -76,7 +76,7 @@ LIR_Opr LIR_OprFact::value_type(ValueType* type) { return LIR_OprFact::oopConst(type->as_ObjectType()->encoding()); } } - case addressTag: return LIR_OprFact::intConst(type->as_AddressConstant()->value()); + case addressTag: return LIR_OprFact::addressConst(type->as_AddressConstant()->value()); case intTag : return LIR_OprFact::intConst(type->as_IntConstant()->value()); case floatTag : return LIR_OprFact::floatConst(type->as_FloatConstant()->value()); case longTag : return LIR_OprFact::longConst(type->as_LongConstant()->value()); @@ -89,7 +89,7 @@ LIR_Opr LIR_OprFact::value_type(ValueType* type) { LIR_Opr LIR_OprFact::dummy_value_type(ValueType* type) { switch (type->tag()) { case objectTag: return LIR_OprFact::oopConst(NULL); - case addressTag: + case addressTag:return LIR_OprFact::addressConst(0); case intTag: return LIR_OprFact::intConst(0); case floatTag: return LIR_OprFact::floatConst(0.0); case longTag: return LIR_OprFact::longConst(0); @@ -1411,6 +1411,7 @@ void LIR_OprDesc::print(outputStream* out) const { // LIR_Address void LIR_Const::print_value_on(outputStream* out) const { switch (type()) { + case T_ADDRESS:out->print("address:%d",as_jint()); break; case T_INT: out->print("int:%d", as_jint()); break; case T_LONG: out->print("lng:%lld", as_jlong()); break; case T_FLOAT: out->print("flt:%f", as_jfloat()); break; diff --git a/src/share/vm/c1/c1_LIR.hpp b/src/share/vm/c1/c1_LIR.hpp index 6ee83f694..4ce123a17 100644 --- a/src/share/vm/c1/c1_LIR.hpp +++ b/src/share/vm/c1/c1_LIR.hpp @@ -85,9 +85,10 @@ class LIR_Const: public LIR_OprPtr { void type_check(BasicType t) const { assert(type() == t, "type check"); } void type_check(BasicType t1, BasicType t2) const { assert(type() == t1 || type() == t2, "type check"); } + void type_check(BasicType t1, BasicType t2, BasicType t3) const { assert(type() == t1 || type() == t2 || type() == t3, "type check"); } public: - LIR_Const(jint i) { _value.set_type(T_INT); _value.set_jint(i); } + LIR_Const(jint i, bool is_address=false) { _value.set_type(is_address?T_ADDRESS:T_INT); _value.set_jint(i); } LIR_Const(jlong l) { _value.set_type(T_LONG); _value.set_jlong(l); } LIR_Const(jfloat f) { _value.set_type(T_FLOAT); _value.set_jfloat(f); } LIR_Const(jdouble d) { _value.set_type(T_DOUBLE); _value.set_jdouble(d); } @@ -105,7 +106,7 @@ class LIR_Const: public LIR_OprPtr { virtual BasicType type() const { return _value.get_type(); } virtual LIR_Const* as_constant() { return this; } - jint as_jint() const { type_check(T_INT ); return _value.get_jint(); } + jint as_jint() const { type_check(T_INT, T_ADDRESS); return _value.get_jint(); } jlong as_jlong() const { type_check(T_LONG ); return _value.get_jlong(); } jfloat as_jfloat() const { type_check(T_FLOAT ); return _value.get_jfloat(); } jdouble as_jdouble() const { type_check(T_DOUBLE); return _value.get_jdouble(); } @@ -120,7 +121,7 @@ class LIR_Const: public LIR_OprPtr { #endif - jint as_jint_bits() const { type_check(T_FLOAT, T_INT); return _value.get_jint(); } + jint as_jint_bits() const { type_check(T_FLOAT, T_INT, T_ADDRESS); return _value.get_jint(); } jint as_jint_lo_bits() const { if (type() == T_DOUBLE) { return low(jlong_cast(_value.get_jdouble())); @@ -718,6 +719,7 @@ class LIR_OprFact: public AllStatic { static LIR_Opr intptrConst(void* p) { return (LIR_Opr)(new LIR_Const(p)); } static LIR_Opr intptrConst(intptr_t v) { return (LIR_Opr)(new LIR_Const((void*)v)); } static LIR_Opr illegal() { return (LIR_Opr)-1; } + static LIR_Opr addressConst(jint i) { return (LIR_Opr)(new LIR_Const(i, true)); } static LIR_Opr value_type(ValueType* type); static LIR_Opr dummy_value_type(ValueType* type); diff --git a/src/share/vm/c1/c1_LinearScan.cpp b/src/share/vm/c1/c1_LinearScan.cpp index ab0498321..1012e3c7d 100644 --- a/src/share/vm/c1/c1_LinearScan.cpp +++ b/src/share/vm/c1/c1_LinearScan.cpp @@ -2479,6 +2479,15 @@ int LinearScan::append_scope_value_for_constant(LIR_Opr opr, GrowableArrayappend(new ConstantLongValue(c->as_jint())); +#else + scope_values->append(new ConstantIntValue(c->as_jint())); +#endif + return 1; + } + default: ShouldNotReachHere(); return -1; diff --git a/test/compiler/6932496/Test6932496.java b/test/compiler/6932496/Test6932496.java new file mode 100644 index 000000000..2b125e626 --- /dev/null +++ b/test/compiler/6932496/Test6932496.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +/** + * @test + * @bug 6932496 + * @summary incorrect deopt of jsr subroutine on 64 bit c1 + * + * @compile -source 1.5 -target 1.5 -XDjsrlimit=0 Test6932496.java + * @run main/othervm -Xcomp -XX:CompileOnly=Test6932496.m Test6932496 + */ + +public class Test6932496 { + static class A { + volatile boolean flag = false; + } + + static void m() { + try { + } finally { + A a = new A(); + a.flag = true; + } + } + + + static public void main(String[] args) { + m(); + } +} -- GitLab