This commit is contained in:
Phil Race 2018-05-04 09:46:08 -07:00
commit 69c55eb2de
15 changed files with 159 additions and 22 deletions

View File

@ -407,7 +407,7 @@ void TemplateTable::fast_aldc(bool wide)
__ bind(resolved); __ bind(resolved);
{ // Check for the null sentinel. { // Check for the null sentinel.
// If we just called the VM, that already did the mapping for us, // If we just called the VM, it already did the mapping for us,
// but it's harmless to retry. // but it's harmless to retry.
Label notNull; Label notNull;

View File

@ -753,6 +753,8 @@ void InterpreterMacroAssembler::load_resolved_reference_at_index(
// Add in the index // Add in the index
add(result, index, result); add(result, index, result);
load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result, tmp); load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result, tmp);
// The resulting oop is null if the reference is not yet resolved.
// It is Universe::the_null_sentinel() if the reference resolved to NULL via condy.
} }

View File

@ -256,7 +256,7 @@ void TemplateTable::sipush() {
void TemplateTable::ldc(bool wide) { void TemplateTable::ldc(bool wide) {
transition(vtos, vtos); transition(vtos, vtos);
Label call_ldc, notInt, isString, notString, notClass, exit; Label call_ldc, notInt, isString, notString, notClass, notFloat, exit;
if (wide) { if (wide) {
__ get_2_byte_integer_at_bcp(1, G3_scratch, O1, InterpreterMacroAssembler::Unsigned); __ get_2_byte_integer_at_bcp(1, G3_scratch, O1, InterpreterMacroAssembler::Unsigned);
@ -286,7 +286,8 @@ void TemplateTable::ldc(bool wide) {
__ set(wide, O1); __ set(wide, O1);
call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), O1); call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), O1);
__ push(atos); __ push(atos);
__ ba_short(exit); __ ba(exit);
__ delayed()->nop();
__ bind(notClass); __ bind(notClass);
// __ add(O0, base_offset, O0); // __ add(O0, base_offset, O0);
@ -296,19 +297,30 @@ void TemplateTable::ldc(bool wide) {
__ delayed()->cmp(O2, JVM_CONSTANT_String); __ delayed()->cmp(O2, JVM_CONSTANT_String);
__ ld(O0, O1, Otos_i); __ ld(O0, O1, Otos_i);
__ push(itos); __ push(itos);
__ ba_short(exit); __ ba(exit);
__ delayed()->nop();
__ bind(notInt); __ bind(notInt);
// __ cmp(O2, JVM_CONSTANT_String); // __ cmp(O2, JVM_CONSTANT_String);
__ brx(Assembler::notEqual, true, Assembler::pt, notString); __ brx(Assembler::notEqual, true, Assembler::pt, notString);
__ delayed()->ldf(FloatRegisterImpl::S, O0, O1, Ftos_f); __ delayed()->cmp(O2, JVM_CONSTANT_Float);
__ bind(isString); __ bind(isString);
__ stop("string should be rewritten to fast_aldc"); __ stop("string should be rewritten to fast_aldc");
__ ba_short(exit); __ ba(exit);
__ delayed()->nop();
__ bind(notString); __ bind(notString);
// __ ldf(FloatRegisterImpl::S, O0, O1, Ftos_f); //__ cmp(O2, JVM_CONSTANT_Float);
__ brx(Assembler::notEqual, true, Assembler::pt, notFloat);
__ delayed()->nop();
__ ldf(FloatRegisterImpl::S, O0, O1, Ftos_f);
__ push(ftos); __ push(ftos);
__ ba(exit);
__ delayed()->nop();
// assume the tag is for condy; if not, the VM runtime will tell us
__ bind(notFloat);
condy_helper(exit);
__ bind(exit); __ bind(exit);
} }
@ -336,12 +348,27 @@ void TemplateTable::fast_aldc(bool wide) {
// first time invocation - must resolve first // first time invocation - must resolve first
__ call_VM(Otos_i, entry, O1); __ call_VM(Otos_i, entry, O1);
__ bind(resolved); __ bind(resolved);
{ // Check for the null sentinel.
// If we just called the VM, it already did the mapping for us,
// but it's harmless to retry.
Label notNull;
__ set(ExternalAddress((address)Universe::the_null_sentinel_addr()), G3_scratch);
__ ld_ptr(G3_scratch, 0, G3_scratch);
__ cmp(G3_scratch, Otos_i);
__ br(Assembler::notEqual, true, Assembler::pt, notNull);
__ delayed()->nop();
__ clr(Otos_i); // NULL object reference
__ bind(notNull);
}
// Safe to call with 0 result
__ verify_oop(Otos_i); __ verify_oop(Otos_i);
} }
void TemplateTable::ldc2_w() { void TemplateTable::ldc2_w() {
transition(vtos, vtos); transition(vtos, vtos);
Label Long, exit; Label notDouble, notLong, exit;
__ get_2_byte_integer_at_bcp(1, G3_scratch, O1, InterpreterMacroAssembler::Unsigned); __ get_2_byte_integer_at_bcp(1, G3_scratch, O1, InterpreterMacroAssembler::Unsigned);
__ get_cpool_and_tags(O0, O2); __ get_cpool_and_tags(O0, O2);
@ -355,7 +382,7 @@ void TemplateTable::ldc2_w() {
__ sll(O1, LogBytesPerWord, O1); __ sll(O1, LogBytesPerWord, O1);
__ add(O0, O1, G3_scratch); __ add(O0, O1, G3_scratch);
__ cmp_and_brx_short(O2, JVM_CONSTANT_Double, Assembler::notEqual, Assembler::pt, Long); __ cmp_and_brx_short(O2, JVM_CONSTANT_Double, Assembler::notEqual, Assembler::pt, notDouble);
// A double can be placed at word-aligned locations in the constant pool. // A double can be placed at word-aligned locations in the constant pool.
// Check out Conversions.java for an example. // Check out Conversions.java for an example.
// Also ConstantPool::header_size() is 20, which makes it very difficult // Also ConstantPool::header_size() is 20, which makes it very difficult
@ -364,9 +391,127 @@ void TemplateTable::ldc2_w() {
__ push(dtos); __ push(dtos);
__ ba_short(exit); __ ba_short(exit);
__ bind(Long); __ bind(notDouble);
__ cmp_and_brx_short(O2, JVM_CONSTANT_Long, Assembler::notEqual, Assembler::pt, notLong);
__ ldx(G3_scratch, base_offset, Otos_l); __ ldx(G3_scratch, base_offset, Otos_l);
__ push(ltos); __ push(ltos);
__ ba_short(exit);
__ bind(notLong);
condy_helper(exit);
__ bind(exit);
}
void TemplateTable::condy_helper(Label& exit) {
Register Robj = Otos_i;
Register Roffset = G4_scratch;
Register Rflags = G1_scratch;
address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc);
__ set((int)bytecode(), O1);
__ call_VM(Robj, entry, O1);
// Get vm_result_2 has flags = (tos, off) using format CPCE::_flags
__ get_vm_result_2(G3_scratch);
// Get offset
__ set((int)ConstantPoolCacheEntry::field_index_mask, Roffset);
__ and3(G3_scratch, Roffset, Roffset);
// compute type
__ srl(G3_scratch, ConstantPoolCacheEntry::tos_state_shift, Rflags);
// Make sure we don't need to mask Rflags after the above shift
ConstantPoolCacheEntry::verify_tos_state_shift();
switch (bytecode()) {
case Bytecodes::_ldc:
case Bytecodes::_ldc_w:
{
// tos in (itos, ftos, stos, btos, ctos, ztos)
Label notInt, notFloat, notShort, notByte, notChar, notBool;
__ cmp(Rflags, itos);
__ br(Assembler::notEqual, false, Assembler::pt, notInt);
__ delayed()->cmp(Rflags, ftos);
// itos
__ ld(Robj, Roffset, Otos_i);
__ push(itos);
__ ba_short(exit);
__ bind(notInt);
__ br(Assembler::notEqual, false, Assembler::pt, notFloat);
__ delayed()->cmp(Rflags, stos);
// ftos
__ ldf(FloatRegisterImpl::S, Robj, Roffset, Ftos_f);
__ push(ftos);
__ ba_short(exit);
__ bind(notFloat);
__ br(Assembler::notEqual, false, Assembler::pt, notShort);
__ delayed()->cmp(Rflags, btos);
// stos
__ ldsh(Robj, Roffset, Otos_i);
__ push(itos);
__ ba_short(exit);
__ bind(notShort);
__ br(Assembler::notEqual, false, Assembler::pt, notByte);
__ delayed()->cmp(Rflags, ctos);
// btos
__ ldsb(Robj, Roffset, Otos_i);
__ push(itos);
__ ba_short(exit);
__ bind(notByte);
__ br(Assembler::notEqual, false, Assembler::pt, notChar);
__ delayed()->cmp(Rflags, ztos);
// ctos
__ lduh(Robj, Roffset, Otos_i);
__ push(itos);
__ ba_short(exit);
__ bind(notChar);
__ br(Assembler::notEqual, false, Assembler::pt, notBool);
__ delayed()->nop();
// ztos
__ ldsb(Robj, Roffset, Otos_i);
__ push(itos);
__ ba_short(exit);
__ bind(notBool);
break;
}
case Bytecodes::_ldc2_w:
{
Label notLong, notDouble;
__ cmp(Rflags, ltos);
__ br(Assembler::notEqual, false, Assembler::pt, notLong);
__ delayed()->cmp(Rflags, dtos);
// ltos
// load must be atomic
__ ld_long(Robj, Roffset, Otos_l);
__ push(ltos);
__ ba_short(exit);
__ bind(notLong);
__ br(Assembler::notEqual, false, Assembler::pt, notDouble);
__ delayed()->nop();
// dtos
__ ldf(FloatRegisterImpl::D, Robj, Roffset, Ftos_d);
__ push(dtos);
__ ba_short(exit);
__ bind(notDouble);
break;
}
default:
ShouldNotReachHere();
}
__ stop("bad ldc/condy");
__ bind(exit); __ bind(exit);
} }

View File

@ -442,7 +442,7 @@ void TemplateTable::fast_aldc(bool wide) {
__ bind(resolved); __ bind(resolved);
{ // Check for the null sentinel. { // Check for the null sentinel.
// If we just called the VM, that already did the mapping for us, // If we just called the VM, it already did the mapping for us,
// but it's harmless to retry. // but it's harmless to retry.
Label notNull; Label notNull;
ExternalAddress null_sentinel((address)Universe::the_null_sentinel_addr()); ExternalAddress null_sentinel((address)Universe::the_null_sentinel_addr());

View File

@ -24,7 +24,7 @@
/* /*
* @test * @test
* @summary Make sure CDS works with a minimal test case that uses a CONSTANT_Dynamic constant-pool entry * @summary Make sure CDS works with a minimal test case that uses a CONSTANT_Dynamic constant-pool entry
* @requires (os.arch != "sparcv9") & (vm.cds) * @requires (vm.cds)
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* @library /test/lib /test/hotspot/jtreg/runtime/appcds * @library /test/lib /test/hotspot/jtreg/runtime/appcds
* @build CondyHello * @build CondyHello

View File

@ -25,7 +25,6 @@
* @test * @test
* @bug 8186211 * @bug 8186211
* @summary CONSTANT_Dynamic_info structure's tries to use a BSM index whose signature is for an invokedynamic and vice versa. * @summary CONSTANT_Dynamic_info structure's tries to use a BSM index whose signature is for an invokedynamic and vice versa.
* @requires os.arch != "sparcv9"
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* @library /test/lib * @library /test/lib
* @compile CondyUsesIndyBSM.jcod * @compile CondyUsesIndyBSM.jcod

View File

@ -25,7 +25,6 @@
* @test * @test
* @bug 8186211 * @bug 8186211
* @summary CONSTANT_Dynamic_info structure present with various bad BSM index, BSM array attribute checks. * @summary CONSTANT_Dynamic_info structure present with various bad BSM index, BSM array attribute checks.
* @requires os.arch != "sparcv9"
* @compile CondyBadBSMIndex.jcod * @compile CondyBadBSMIndex.jcod
* @compile CondyEmptyBSMArray1.jcod * @compile CondyEmptyBSMArray1.jcod
* @compile CondyNoBSMArray.jcod * @compile CondyNoBSMArray.jcod

View File

@ -25,7 +25,6 @@
* @test * @test
* @bug 8186211 * @bug 8186211
* @summary CONSTANT_Dynamic_info structure's name_and_type_index item does not point at CONSANT_NameAndType_info * @summary CONSTANT_Dynamic_info structure's name_and_type_index item does not point at CONSANT_NameAndType_info
* @requires os.arch != "sparcv9"
* @compile CondyBadNameType.jcod * @compile CondyBadNameType.jcod
* @run main/othervm -Xverify:all CondyBadNameTypeTest * @run main/othervm -Xverify:all CondyBadNameTypeTest
*/ */

View File

@ -25,7 +25,6 @@
* @test * @test
* @bug 8186211 * @bug 8186211
* @summary CONSTANT_Dynamic_info structure present within an unsupported class file version. * @summary CONSTANT_Dynamic_info structure present within an unsupported class file version.
* @requires os.arch != "sparcv9"
* @compile CondyCFVCheck.jcod * @compile CondyCFVCheck.jcod
* @run main/othervm -Xverify:all CondyCFVCheckTest * @run main/othervm -Xverify:all CondyCFVCheckTest
*/ */

View File

@ -25,7 +25,6 @@
* @test * @test
* @bug 8186211 * @bug 8186211
* @summary Tests various ldc, ldc_w, ldc2_w instructions of CONSTANT_Dynamic. * @summary Tests various ldc, ldc_w, ldc2_w instructions of CONSTANT_Dynamic.
* @requires os.arch != "sparcv9"
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* @library /test/lib * @library /test/lib
* @compile CondyUseLDC_W.jasm * @compile CondyUseLDC_W.jasm

View File

@ -25,7 +25,6 @@
* @test * @test
* @bug 8186211 * @bug 8186211
* @summary Test CONSTANT_Dynamic where the BSM is invoked via a REF_newInvokeSpecial. * @summary Test CONSTANT_Dynamic where the BSM is invoked via a REF_newInvokeSpecial.
* @requires os.arch != "sparcv9"
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* @library /test/lib * @library /test/lib
* @compile CondyNewInvokeSpecial.jasm * @compile CondyNewInvokeSpecial.jasm

View File

@ -25,7 +25,6 @@
* @test * @test
* @bug 8186211 * @bug 8186211
* @summary Test basic invocation of multiple ldc's of the same dynamic constant that fail resolution * @summary Test basic invocation of multiple ldc's of the same dynamic constant that fail resolution
* @requires os.arch != "sparcv9"
* @library /lib/testlibrary/bytecode /java/lang/invoke/common * @library /lib/testlibrary/bytecode /java/lang/invoke/common
* @build jdk.experimental.bytecode.BasicClassBuilder * @build jdk.experimental.bytecode.BasicClassBuilder
* @run testng CondyRepeatFailedResolution * @run testng CondyRepeatFailedResolution

View File

@ -25,7 +25,6 @@
* @test * @test
* @bug 8186046 * @bug 8186046
* @summary Test for condy BSMs returning primitive values or null * @summary Test for condy BSMs returning primitive values or null
* @requires os.arch != "sparcv9"
* @library /lib/testlibrary/bytecode * @library /lib/testlibrary/bytecode
* @build jdk.experimental.bytecode.BasicClassBuilder * @build jdk.experimental.bytecode.BasicClassBuilder
* @run testng CondyReturnPrimitiveTest * @run testng CondyReturnPrimitiveTest

View File

@ -25,7 +25,6 @@
* @test * @test
* @bug 8186046 * @bug 8186046
* @summary Test bootstrap methods returning the wrong type * @summary Test bootstrap methods returning the wrong type
* @requires os.arch != "sparcv9"
* @library /lib/testlibrary/bytecode /java/lang/invoke/common * @library /lib/testlibrary/bytecode /java/lang/invoke/common
* @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.InstructionHelper * @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.InstructionHelper
* @run testng CondyWrongType * @run testng CondyWrongType

View File

@ -25,7 +25,6 @@
* @test * @test
* @bug 8186046 8195694 * @bug 8186046 8195694
* @summary Test dynamic constant bootstraps * @summary Test dynamic constant bootstraps
* @requires os.arch != "sparcv9"
* @library /lib/testlibrary/bytecode /java/lang/invoke/common * @library /lib/testlibrary/bytecode /java/lang/invoke/common
* @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.InstructionHelper * @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.InstructionHelper
* @run testng ConstantBootstrapsTest * @run testng ConstantBootstrapsTest