diff --git a/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp index 8a42e8fd8bf..35d34a08eaa 100644 --- a/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp @@ -1980,6 +1980,9 @@ void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, case T_ADDRESS: imm = opr2->as_constant_ptr()->as_jint(); break; + case T_METADATA: + imm = (intptr_t)(opr2->as_constant_ptr()->as_metadata()); + break; case T_OBJECT: case T_ARRAY: imm = jlong(opr2->as_constant_ptr()->as_jobject()); diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp index 0bd581aaf7a..d1a32a26eab 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @@ -1681,6 +1681,18 @@ void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, } break; + case T_METADATA: + // We only need, for now, comparison with NULL for metadata. + { assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "oops"); + Metadata* m = opr2->as_constant_ptr()->as_metadata(); + if (m == NULL) { + __ cmp(opr1->as_register(), 0); + } else { + ShouldNotReachHere(); + } + } + break; + default: ShouldNotReachHere(); break; diff --git a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp index b1ba43f7626..c1c053e66c3 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @@ -2718,6 +2718,15 @@ void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Const* c = opr2->as_constant_ptr(); if (c->type() == T_INT) { __ cmpl(reg1, c->as_jint()); + } else if (c->type() == T_METADATA) { + // All we need for now is a comparison with NULL for equality. + assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "oops"); + Metadata* m = c->as_metadata(); + if (m == NULL) { + __ cmpptr(reg1, (int32_t)0); + } else { + ShouldNotReachHere(); + } } else if (c->type() == T_OBJECT || c->type() == T_ARRAY) { // In 64bit oops are single register jobject o = c->as_jobject(); diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index c994344de24..837553ddb62 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -1305,7 +1305,7 @@ void LIRGenerator::do_isPrimitive(Intrinsic* x) { } __ move(new LIR_Address(rcvr.result(), java_lang_Class::klass_offset_in_bytes(), T_ADDRESS), temp, info); - __ cmp(lir_cond_notEqual, temp, LIR_OprFact::intConst(0)); + __ cmp(lir_cond_notEqual, temp, LIR_OprFact::metadataConst(0)); __ cmove(lir_cond_notEqual, LIR_OprFact::intConst(0), LIR_OprFact::intConst(1), result, T_BOOLEAN); } diff --git a/hotspot/test/compiler/intrinsics/klass/TestIsPrimitive.java b/hotspot/test/compiler/intrinsics/klass/TestIsPrimitive.java index cecc89ae7ae..b635b07b456 100644 --- a/hotspot/test/compiler/intrinsics/klass/TestIsPrimitive.java +++ b/hotspot/test/compiler/intrinsics/klass/TestIsPrimitive.java @@ -24,10 +24,12 @@ /* * @test * @bug 8150669 + * @bug 8233019 * @summary C1 intrinsic for Class.isPrimitive * * @run main/othervm -ea -Diters=200 -Xint TestIsPrimitive - * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=1 TestIsPrimitive + * @run main/othervm -ea -Diters=30000 -XX:-UseSharedSpaces + -XX:TieredStopAtLevel=1 TestIsPrimitive * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=4 TestIsPrimitive */ import java.lang.reflect.Field; @@ -48,6 +50,7 @@ public static void main(String... args) throws Exception { testOK(true, InlineConstants::testDouble); testOK(false, InlineConstants::testObject); testOK(false, InlineConstants::testArray); + testOK(false, InlineConstants::testBooleanArray); testOK(true, StaticConstants::testBoolean); testOK(true, StaticConstants::testByte); @@ -59,6 +62,7 @@ public static void main(String... args) throws Exception { testOK(true, StaticConstants::testDouble); testOK(false, StaticConstants::testObject); testOK(false, StaticConstants::testArray); + testOK(false, StaticConstants::testBooleanArray); testNPE( StaticConstants::testNull); testOK(true, NoConstants::testBoolean); @@ -71,6 +75,7 @@ public static void main(String... args) throws Exception { testOK(true, NoConstants::testDouble); testOK(false, NoConstants::testObject); testOK(false, NoConstants::testArray); + testOK(false, NoConstants::testBooleanArray); testNPE( NoConstants::testNull); } @@ -107,6 +112,7 @@ public static void testNPE(Callable test) throws Exception { static volatile Class classObject = Object.class; static volatile Class classArray = Object[].class; static volatile Class classNull = null; + static volatile Class classBooleanArray = boolean[].class; static final Class staticClassBoolean = boolean.class; static final Class staticClassByte = byte.class; @@ -119,6 +125,7 @@ public static void testNPE(Callable test) throws Exception { static final Class staticClassObject = Object.class; static final Class staticClassArray = Object[].class; static final Class staticClassNull = null; + static final Class staticClassBooleanArray = boolean[].class; static class InlineConstants { static boolean testBoolean() { return boolean.class.isPrimitive(); } @@ -131,6 +138,7 @@ static class InlineConstants { static boolean testDouble() { return double.class.isPrimitive(); } static boolean testObject() { return Object.class.isPrimitive(); } static boolean testArray() { return Object[].class.isPrimitive(); } + static boolean testBooleanArray() { return boolean[].class.isPrimitive(); } } static class StaticConstants { @@ -145,6 +153,7 @@ static class StaticConstants { static boolean testObject() { return staticClassObject.isPrimitive(); } static boolean testArray() { return staticClassArray.isPrimitive(); } static boolean testNull() { return staticClassNull.isPrimitive(); } + static boolean testBooleanArray() { return staticClassBooleanArray.isPrimitive(); } } static class NoConstants { @@ -159,6 +168,7 @@ static class NoConstants { static boolean testObject() { return classObject.isPrimitive(); } static boolean testArray() { return classArray.isPrimitive(); } static boolean testNull() { return classNull.isPrimitive(); } + static boolean testBooleanArray() { return classBooleanArray.isPrimitive(); } } }