From d1bbcb5a390fb90ed9c9a84ae6b49089fa20d0a9 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Fri, 25 Aug 2017 14:07:18 -0700 Subject: [PATCH 01/11] 8186136: [Graal] some tests setting -Djvmci.Compiler=null fail with: jdk.vm.ci.common.JVMCIError: no JVMCI compiler selected Removed -Djvmci.Compiler=null for tests which do JIT compilation Reviewed-by: twisti --- hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java | 8 ++++---- .../jvmci/compilerToVM/HasCompiledCodeForOSRTest.java | 2 +- .../jvmci/compilerToVM/InvalidateInstalledCodeTest.java | 1 - .../jvmci/compilerToVM/IsMatureVsReprofileTest.java | 3 +-- .../jvmci/compilerToVM/MaterializeVirtualObjectTest.java | 4 ---- .../test/compiler/jvmci/compilerToVM/ReprofileTest.java | 4 ++-- 6 files changed, 8 insertions(+), 14 deletions(-) diff --git a/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java b/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java index 3d01b4adbd9..25c0b2a1e72 100644 --- a/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java +++ b/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java @@ -30,21 +30,21 @@ * @modules jdk.internal.vm.ci/jdk.vm.ci.runtime * @run main/othervm -XX:+UnlockExperimentalVMOptions * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=true - * -XX:+EnableJVMCI -Djvmci.Compiler=null + * -XX:+EnableJVMCI * compiler.jvmci.JVM_GetJVMCIRuntimeTest * @run main/othervm -XX:+UnlockExperimentalVMOptions * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=false - * -XX:-EnableJVMCI + * -XX:-EnableJVMCI -XX:-UseJVMCICompiler * compiler.jvmci.JVM_GetJVMCIRuntimeTest * @run main/othervm -XX:+UnlockExperimentalVMOptions * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=true * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.threaded=true - * -XX:+EnableJVMCI -Djvmci.Compiler=null + * -XX:+EnableJVMCI * compiler.jvmci.JVM_GetJVMCIRuntimeTest * @run main/othervm -XX:+UnlockExperimentalVMOptions * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=false * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.threaded=true - * -XX:-EnableJVMCI + * -XX:-EnableJVMCI -XX:-UseJVMCICompiler * compiler.jvmci.JVM_GetJVMCIRuntimeTest */ diff --git a/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java b/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java index f9e50cb69f8..010c230f139 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java @@ -39,7 +39,7 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-BackgroundCompilation -Djvmci.Compiler=null + * -XX:-BackgroundCompilation * compiler.jvmci.compilerToVM.HasCompiledCodeForOSRTest */ diff --git a/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java index de6f2f6f1a3..66566c2f60f 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java @@ -42,7 +42,6 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -Djvmci.Compiler=null * compiler.jvmci.compilerToVM.InvalidateInstalledCodeTest */ diff --git a/hotspot/test/compiler/jvmci/compilerToVM/IsMatureVsReprofileTest.java b/hotspot/test/compiler/jvmci/compilerToVM/IsMatureVsReprofileTest.java index b748403c2b0..0f7e8baa8c9 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/IsMatureVsReprofileTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/IsMatureVsReprofileTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8136421 - * @requires vm.jvmci + * @requires vm.jvmci & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) * @library / /test/lib * ../common/patches * @modules java.base/jdk.internal.misc @@ -38,7 +38,6 @@ * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xbatch - * -Djvmci.Compiler=null * compiler.jvmci.compilerToVM.IsMatureVsReprofileTest */ diff --git a/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java b/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java index 8e919fb5ba9..ef0d3ccca8b 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java @@ -49,7 +49,6 @@ * -XX:+DoEscapeAnalysis -XX:-UseCounterDecay * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false - * -Djvmci.Compiler=null * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest * @run main/othervm -Xmixed -Xbatch -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI @@ -61,7 +60,6 @@ * -XX:+DoEscapeAnalysis -XX:-UseCounterDecay * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=false * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false - * -Djvmci.Compiler=null * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest * @run main/othervm -Xmixed -Xbatch -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI @@ -73,7 +71,6 @@ * -XX:+DoEscapeAnalysis -XX:-UseCounterDecay * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true - * -Djvmci.Compiler=null * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest * @run main/othervm -Xmixed -Xbatch -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI @@ -85,7 +82,6 @@ * -XX:+DoEscapeAnalysis -XX:-UseCounterDecay * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=false * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true - * -Djvmci.Compiler=null * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest */ diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java index c9e24fe4f2b..558c4d607ae 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java @@ -24,7 +24,7 @@ /** * @test * @bug 8136421 - * @requires vm.jvmci & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 3) + * @requires vm.jvmci & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) * @library /test/lib / * @library ../common/patches * @modules java.base/jdk.internal.misc @@ -40,7 +40,7 @@ * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -Xmixed -Xbatch -Djvmci.Compiler=null + * -Xmixed -Xbatch * compiler.jvmci.compilerToVM.ReprofileTest */ From 192f57c11cb4ad581db5586ac609b1d37a091706 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 22 Aug 2017 15:12:26 +0200 Subject: [PATCH 02/11] 8186437: Lock held when compiler thread creation fails Reviewed-by: stuefe, kvn --- .../src/share/vm/compiler/compileBroker.cpp | 61 ++++++++++--------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index b7872380567..9dee3fa9fa2 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -720,44 +720,49 @@ JavaThread* CompileBroker::make_thread(const char* name, CompileQueue* queue, Co // At this point it may be possible that no osthread was created for the // JavaThread due to lack of memory. We would have to throw an exception // in that case. However, since this must work and we do not allow - // exceptions anyway, check and abort if this fails. + // exceptions anyway, check and abort if this fails. But first release the + // lock. - if (thread == NULL || thread->osthread() == NULL) { - vm_exit_during_initialization("java.lang.OutOfMemoryError", - os::native_thread_creation_failed_msg()); - } + if (thread != NULL && thread->osthread() != NULL) { - java_lang_Thread::set_thread(thread_oop(), thread); + java_lang_Thread::set_thread(thread_oop(), thread); - // Note that this only sets the JavaThread _priority field, which by - // definition is limited to Java priorities and not OS priorities. - // The os-priority is set in the CompilerThread startup code itself + // Note that this only sets the JavaThread _priority field, which by + // definition is limited to Java priorities and not OS priorities. + // The os-priority is set in the CompilerThread startup code itself - java_lang_Thread::set_priority(thread_oop(), NearMaxPriority); + java_lang_Thread::set_priority(thread_oop(), NearMaxPriority); - // Note that we cannot call os::set_priority because it expects Java - // priorities and we are *explicitly* using OS priorities so that it's - // possible to set the compiler thread priority higher than any Java - // thread. + // Note that we cannot call os::set_priority because it expects Java + // priorities and we are *explicitly* using OS priorities so that it's + // possible to set the compiler thread priority higher than any Java + // thread. - int native_prio = CompilerThreadPriority; - if (native_prio == -1) { - if (UseCriticalCompilerThreadPriority) { - native_prio = os::java_to_os_priority[CriticalPriority]; - } else { - native_prio = os::java_to_os_priority[NearMaxPriority]; + int native_prio = CompilerThreadPriority; + if (native_prio == -1) { + if (UseCriticalCompilerThreadPriority) { + native_prio = os::java_to_os_priority[CriticalPriority]; + } else { + native_prio = os::java_to_os_priority[NearMaxPriority]; + } } - } - os::set_native_priority(thread, native_prio); + os::set_native_priority(thread, native_prio); - java_lang_Thread::set_daemon(thread_oop()); + java_lang_Thread::set_daemon(thread_oop()); - thread->set_threadObj(thread_oop()); - if (compiler_thread) { - thread->as_CompilerThread()->set_compiler(comp); + thread->set_threadObj(thread_oop()); + if (compiler_thread) { + thread->as_CompilerThread()->set_compiler(comp); + } + Threads::add(thread); + Thread::start(thread); } - Threads::add(thread); - Thread::start(thread); + } + + // First release lock before aborting VM. + if (thread == NULL || thread->osthread() == NULL) { + vm_exit_during_initialization("java.lang.OutOfMemoryError", + os::native_thread_creation_failed_msg()); } // Let go of Threads_lock before yielding From f808590858ee8463b6e453126a34941588e8b9b2 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Fri, 25 Aug 2017 18:21:47 -0700 Subject: [PATCH 03/11] 8186144: [Graal] some tests fail with: Improperly specified VM option UseJVMCICompiler: EnableJVMCI cannot be disabled Disable Graal by switching off UseJVMCICompiler when JVMCI is disabled Reviewed-by: twisti --- hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java | 4 ++-- .../compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java | 1 - .../compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java | 3 +-- .../test/compiler/jvmci/events/JvmciShutdownEventTest.java | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java b/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java index a52e19b3817..8d9d6cf5e32 100644 --- a/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java +++ b/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java @@ -43,11 +43,11 @@ * compiler.jvmci.SecurityRestrictionsTest * ALL_PERM * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -XX:+EnableJVMCI + * -XX:+EnableJVMCI -XX:-UseJVMCICompiler * compiler.jvmci.SecurityRestrictionsTest * NO_JVMCI_ACCESS_PERM * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -XX:-EnableJVMCI + * -XX:-EnableJVMCI -XX:-UseJVMCICompiler * compiler.jvmci.SecurityRestrictionsTest * NO_JVMCI */ diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java index 09f9b94d426..dc33a461282 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java @@ -61,7 +61,6 @@ public class DisassembleCodeBlobTest { = new DisassembleCodeBlobTest(); List testCases = CompileCodeTestCase.generate(/* bci = */ -1); - testCases.addAll(CompileCodeTestCase.generate(/* bci = */ 0)); testCases.forEach(test::check); testCases.stream().findAny().ifPresent(test::checkZero); test.checkNull(); diff --git a/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java b/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java index 0c0e60bfd39..0fffa225ce1 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java @@ -35,9 +35,8 @@ * compiler.jvmci.compilerToVM.JVM_RegisterJVMCINatives * @run main/othervm -XX:+UnlockExperimentalVMOptions * -Dcompiler.jvmci.compilerToVM.JVM_RegisterJVMCINatives.positive=false - * -XX:-EnableJVMCI + * -XX:-EnableJVMCI -XX:-UseJVMCICompiler * compiler.jvmci.compilerToVM.JVM_RegisterJVMCINatives - */ package compiler.jvmci.compilerToVM; diff --git a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java index 40069651d59..34b3955f123 100644 --- a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java +++ b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java @@ -74,7 +74,7 @@ public class JvmciShutdownEventTest { "Unexpected exit code with -EnableJVMCI", "Unexpected output with -EnableJVMCI", ExitCode.OK, addTestVMOptions, "-XX:+UnlockExperimentalVMOptions", - "-XX:-EnableJVMCI", "-Xbootclasspath/a:.", + "-XX:-EnableJVMCI", "-XX:-UseJVMCICompiler", "-Xbootclasspath/a:.", JvmciShutdownEventListener.class.getName() ); } From 35d9741f1cb889e9cb97eabf5e98ef7229499a58 Mon Sep 17 00:00:00 2001 From: Daniel Stewart Date: Tue, 1 Aug 2017 14:58:38 +0800 Subject: [PATCH 04/11] 8184049: AArch64: Matching rule for ubfiz Reviewed-by: aph, adinn --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 58 ++++++++++++++++++++++++ hotspot/src/cpu/aarch64/vm/aarch64_ad.m4 | 42 +++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index 8ab4d363eea..b05b2cdfca1 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -12658,6 +12658,64 @@ instruct ubfxIConvI2L(iRegLNoSp dst, iRegIorL2I src, immI rshift, immI_bitmask m ins_pipe(ialu_reg_shift); %} +// We can use ubfiz when masking by a positive number and then left shifting the result. +// We know that the mask is positive because immI_bitmask guarantees it. +instruct ubfizwI(iRegINoSp dst, iRegIorL2I src, immI lshift, immI_bitmask mask) +%{ + match(Set dst (LShiftI (AndI src mask) lshift)); + predicate((unsigned int)n->in(2)->get_int() <= 31 && + (exact_log2(n->in(1)->in(2)->get_int()+1) + (unsigned int)n->in(2)->get_int()) <= (31+1)); + + ins_cost(INSN_COST); + format %{ "ubfizw $dst, $src, $lshift, $mask" %} + ins_encode %{ + int lshift = $lshift$$constant; + long mask = $mask$$constant; + int width = exact_log2(mask+1); + __ ubfizw(as_Register($dst$$reg), + as_Register($src$$reg), lshift, width); + %} + ins_pipe(ialu_reg_shift); +%} +// We can use ubfiz when masking by a positive number and then left shifting the result. +// We know that the mask is positive because immL_bitmask guarantees it. +instruct ubfizL(iRegLNoSp dst, iRegL src, immI lshift, immL_bitmask mask) +%{ + match(Set dst (LShiftL (AndL src mask) lshift)); + predicate((unsigned int)n->in(2)->get_int() <= 63 && + (exact_log2_long(n->in(1)->in(2)->get_long()+1) + (unsigned int)n->in(2)->get_int()) <= (63+1)); + + ins_cost(INSN_COST); + format %{ "ubfiz $dst, $src, $lshift, $mask" %} + ins_encode %{ + int lshift = $lshift$$constant; + long mask = $mask$$constant; + int width = exact_log2(mask+1); + __ ubfiz(as_Register($dst$$reg), + as_Register($src$$reg), lshift, width); + %} + ins_pipe(ialu_reg_shift); +%} + +// If there is a convert I to L block between and AndI and a LShiftL, we can also match ubfiz +instruct ubfizIConvI2L(iRegLNoSp dst, iRegIorL2I src, immI lshift, immI_bitmask mask) +%{ + match(Set dst (LShiftL (ConvI2L(AndI src mask)) lshift)); + predicate((unsigned int)n->in(2)->get_int() <= 31 && + (exact_log2((unsigned int)n->in(1)->in(1)->in(2)->get_int()+1) + (unsigned int)n->in(2)->get_int()) <= 32); + + ins_cost(INSN_COST); + format %{ "ubfiz $dst, $src, $lshift, $mask" %} + ins_encode %{ + int lshift = $lshift$$constant; + long mask = $mask$$constant; + int width = exact_log2(mask+1); + __ ubfiz(as_Register($dst$$reg), + as_Register($src$$reg), lshift, width); + %} + ins_pipe(ialu_reg_shift); +%} + // Rotations instruct extrOrL(iRegLNoSp dst, iRegL src1, iRegL src2, immI lshift, immI rshift, rFlagsReg cr) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64_ad.m4 b/hotspot/src/cpu/aarch64/vm/aarch64_ad.m4 index b2a4d379eb9..019f646ef5b 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64_ad.m4 +++ b/hotspot/src/cpu/aarch64/vm/aarch64_ad.m4 @@ -214,6 +214,48 @@ instruct ubfxIConvI2L(iRegLNoSp dst, iRegIorL2I src, immI rshift, immI_bitmask m ins_pipe(ialu_reg_shift); %} +define(`UBFIZ_INSN', +// We can use ubfiz when masking by a positive number and then left shifting the result. +// We know that the mask is positive because imm$1_bitmask guarantees it. +`instruct $2$1(iReg$1NoSp dst, iReg$1`'ORL2I($1) src, immI lshift, imm$1_bitmask mask) +%{ + match(Set dst (LShift$1 (And$1 src mask) lshift)); + predicate((unsigned int)n->in(2)->get_int() <= $3 && + (exact_log2$5(n->in(1)->in(2)->get_$4()+1) + (unsigned int)n->in(2)->get_int()) <= ($3+1)); + + ins_cost(INSN_COST); + format %{ "$2 $dst, $src, $lshift, $mask" %} + ins_encode %{ + int lshift = $lshift$$constant; + long mask = $mask$$constant; + int width = exact_log2(mask+1); + __ $2(as_Register($dst$$reg), + as_Register($src$$reg), lshift, width); + %} + ins_pipe(ialu_reg_shift); +%}') +UBFIZ_INSN(I, ubfizw, 31, int) +UBFIZ_INSN(L, ubfiz, 63, long, _long) + +// If there is a convert I to L block between and AndI and a LShiftL, we can also match ubfiz +instruct ubfizIConvI2L(iRegLNoSp dst, iRegIorL2I src, immI lshift, immI_bitmask mask) +%{ + match(Set dst (LShiftL (ConvI2L(AndI src mask)) lshift)); + predicate((unsigned int)n->in(2)->get_int() <= 31 && + (exact_log2((unsigned int)n->in(1)->in(1)->in(2)->get_int()+1) + (unsigned int)n->in(2)->get_int()) <= 32); + + ins_cost(INSN_COST); + format %{ "ubfiz $dst, $src, $lshift, $mask" %} + ins_encode %{ + int lshift = $lshift$$constant; + long mask = $mask$$constant; + int width = exact_log2(mask+1); + __ ubfiz(as_Register($dst$$reg), + as_Register($src$$reg), lshift, width); + %} + ins_pipe(ialu_reg_shift); +%} + // Rotations define(`EXTRACT_INSN', From e8821053108e83a0896b1d24a4cf1f7bd918c863 Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Sun, 27 Aug 2017 15:48:52 -0400 Subject: [PATCH 05/11] 8186706: ArchivedObjectCache obj_hash() is broken Use oop's identity_hash. Also use larger table size. Reviewed-by: ccheung, iklam, coleenp --- hotspot/src/share/vm/memory/metaspaceShared.cpp | 2 ++ hotspot/src/share/vm/memory/metaspaceShared.hpp | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/memory/metaspaceShared.cpp b/hotspot/src/share/vm/memory/metaspaceShared.cpp index f007a3bf05d..4eb22563d97 100644 --- a/hotspot/src/share/vm/memory/metaspaceShared.cpp +++ b/hotspot/src/share/vm/memory/metaspaceShared.cpp @@ -1613,6 +1613,8 @@ void VM_PopulateDumpSharedSpace::dump_java_heap_objects() { tty->print_cr("Dumping objects to open archive heap region ..."); _open_archive_heap_regions = new GrowableArray(2); MetaspaceShared::dump_open_archive_heap_objects(_open_archive_heap_regions); + + MetaspaceShared::destroy_archive_object_cache(); } G1HeapVerifier::verify_archive_regions(); diff --git a/hotspot/src/share/vm/memory/metaspaceShared.hpp b/hotspot/src/share/vm/memory/metaspaceShared.hpp index a95819af6ab..d93dea2809d 100644 --- a/hotspot/src/share/vm/memory/metaspaceShared.hpp +++ b/hotspot/src/share/vm/memory/metaspaceShared.hpp @@ -29,6 +29,7 @@ #include "memory/allocation.hpp" #include "memory/memRegion.hpp" #include "memory/virtualspace.hpp" +#include "oops/oop.inline.hpp" #include "utilities/exceptions.hpp" #include "utilities/macros.hpp" #include "utilities/resourceHash.hpp" @@ -96,11 +97,16 @@ class MetaspaceShared : AllStatic { return p1 == p2; } static unsigned obj_hash(oop const& p) { - unsigned hash = (unsigned)((uintptr_t)&p); - return hash ^ (hash >> LogMinObjAlignment); + assert(!p->mark()->has_bias_pattern(), + "this object should never have been locked"); // so identity_hash won't safepoin + unsigned hash = (unsigned)p->identity_hash(); + return hash; } typedef ResourceHashtable ArchivedObjectCache; + MetaspaceShared::obj_hash, + MetaspaceShared::obj_equals, + 15889, // prime number + ResourceObj::C_HEAP> ArchivedObjectCache; static ArchivedObjectCache* _archive_object_cache; public: @@ -115,7 +121,10 @@ class MetaspaceShared : AllStatic { NOT_CDS_JAVA_HEAP(return false;) } static void create_archive_object_cache() { - CDS_JAVA_HEAP_ONLY(_archive_object_cache = new ArchivedObjectCache();); + CDS_JAVA_HEAP_ONLY(_archive_object_cache = new (ResourceObj::C_HEAP, mtClass)ArchivedObjectCache();); + } + static void destroy_archive_object_cache() { + CDS_JAVA_HEAP_ONLY(delete _archive_object_cache; _archive_object_cache = NULL;); } static void fixup_mapped_heap_regions() NOT_CDS_JAVA_HEAP_RETURN; From 52f9c55e24b17c6e305d92ae5ea65f31f528f132 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Mon, 28 Aug 2017 00:20:35 +0200 Subject: [PATCH 06/11] 8179040: Avoid Ticks::now calls when EventClassLoad is not enabled Co-authored-by: Markus Gronlund Reviewed-by: ehelin, mgronlun, dholmes, iklam --- .../share/vm/classfile/systemDictionary.cpp | 32 ++++++------ hotspot/src/share/vm/runtime/synchronizer.cpp | 1 - hotspot/src/share/vm/trace/traceDataTypes.hpp | 8 +-- hotspot/src/share/vm/trace/traceEvent.hpp | 50 +++---------------- .../src/share/vm/trace/traceEventClasses.xsl | 7 ++- hotspot/src/share/vm/trace/traceTypes.xsl | 5 +- 6 files changed, 30 insertions(+), 73 deletions(-) diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index e33fc47821c..6a5ce5ffa8f 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -77,9 +77,8 @@ #include "services/classLoadingService.hpp" #include "services/diagnosticCommand.hpp" #include "services/threadService.hpp" -#include "trace/traceMacros.hpp" +#include "trace/tracing.hpp" #include "utilities/macros.hpp" -#include "utilities/ticks.hpp" #if INCLUDE_CDS #include "classfile/sharedClassUtil.hpp" #include "classfile/systemDictionaryShared.hpp" @@ -87,9 +86,6 @@ #if INCLUDE_JVMCI #include "jvmci/jvmciRuntime.hpp" #endif -#if INCLUDE_TRACE -#include "trace/tracing.hpp" -#endif PlaceholderTable* SystemDictionary::_placeholders = NULL; Dictionary* SystemDictionary::_shared_dictionary = NULL; @@ -615,17 +611,17 @@ InstanceKlass* SystemDictionary::handle_parallel_super_load( return NULL; } -static void post_class_load_event(const Ticks& start_time, - InstanceKlass* k, +static void post_class_load_event(EventClassLoad* event, + const InstanceKlass* k, const ClassLoaderData* init_cld) { #if INCLUDE_TRACE - EventClassLoad event(UNTIMED); - if (event.should_commit()) { - event.set_starttime(start_time); - event.set_loadedClass(k); - event.set_definingClassLoader(k->class_loader_data()); - event.set_initiatingClassLoader(init_cld); - event.commit(); + assert(event != NULL, "invariant"); + assert(k != NULL, "invariant"); + if (event->should_commit()) { + event->set_loadedClass(k); + event->set_definingClassLoader(k->class_loader_data()); + event->set_initiatingClassLoader(init_cld); + event->commit(); } #endif // INCLUDE_TRACE } @@ -653,7 +649,7 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, assert(name != NULL && !FieldType::is_array(name) && !FieldType::is_obj(name), "invalid class name"); - Ticks class_load_start_time = Ticks::now(); + EventClassLoad class_load_start_event; HandleMark hm(THREAD); @@ -899,7 +895,7 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, return NULL; } - post_class_load_event(class_load_start_time, k, loader_data); + post_class_load_event(&class_load_start_event, k, loader_data); #ifdef ASSERT { @@ -1006,7 +1002,7 @@ InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name, GrowableArray* cp_patches, TRAPS) { - Ticks class_load_start_time = Ticks::now(); + EventClassLoad class_load_start_event; ClassLoaderData* loader_data; if (host_klass != NULL) { @@ -1064,7 +1060,7 @@ InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name, JvmtiExport::post_class_load((JavaThread *) THREAD, k); } - post_class_load_event(class_load_start_time, k, loader_data); + post_class_load_event(&class_load_start_event, k, loader_data); } assert(host_klass != NULL || NULL == cp_patches, "cp_patches only found with host_klass"); diff --git a/hotspot/src/share/vm/runtime/synchronizer.cpp b/hotspot/src/share/vm/runtime/synchronizer.cpp index 7a59b3e43a5..096b43eedcd 100644 --- a/hotspot/src/share/vm/runtime/synchronizer.cpp +++ b/hotspot/src/share/vm/runtime/synchronizer.cpp @@ -1407,7 +1407,6 @@ ObjectMonitor* ObjectSynchronizer::inflate(Thread * Self, assert(inf->header()->is_neutral(), "invariant"); assert(inf->object() == object, "invariant"); assert(ObjectSynchronizer::verify_objmon_isinpool(inf), "monitor is invalid"); - event.cancel(); // let's not post an inflation event, unless we did the deed ourselves return inf; } diff --git a/hotspot/src/share/vm/trace/traceDataTypes.hpp b/hotspot/src/share/vm/trace/traceDataTypes.hpp index 31be0589f3f..5c4b13e53b6 100644 --- a/hotspot/src/share/vm/trace/traceDataTypes.hpp +++ b/hotspot/src/share/vm/trace/traceDataTypes.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -28,6 +28,7 @@ #include #include "utilities/globalDefinitions.hpp" +#include "utilities/ticks.hpp" enum { CONTENT_TYPE_NONE = 0, @@ -54,10 +55,11 @@ enum ReservedEvent { NUM_RESERVED_EVENTS = JVM_CONTENT_TYPES_END }; -typedef enum ReservedEvent ReservedEvent; - typedef u8 traceid; +class ClassLoaderData; +class Klass; +class Method; class ModuleEntry; class PackageEntry; class Symbol; diff --git a/hotspot/src/share/vm/trace/traceEvent.hpp b/hotspot/src/share/vm/trace/traceEvent.hpp index 3a083c402ce..ac8884b29de 100644 --- a/hotspot/src/share/vm/trace/traceEvent.hpp +++ b/hotspot/src/share/vm/trace/traceEvent.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -25,6 +25,7 @@ #ifndef SHARE_VM_TRACE_TRACEEVENT_HPP #define SHARE_VM_TRACE_TRACEEVENT_HPP +#include "trace/traceTime.hpp" #include "utilities/macros.hpp" enum EventStartTime { @@ -34,25 +35,18 @@ enum EventStartTime { #if INCLUDE_TRACE #include "trace/traceBackend.hpp" -#include "trace/tracing.hpp" #include "tracefiles/traceEventIds.hpp" -#include "tracefiles/traceTypes.hpp" #include "utilities/ticks.hpp" template -class TraceEvent : public StackObj { +class TraceEvent { private: bool _started; -#ifdef ASSERT - bool _committed; - bool _cancelled; - protected: - bool _ignore_check; -#endif protected: jlong _startTime; jlong _endTime; + DEBUG_ONLY(bool _committed;) void set_starttime(const TracingTime& time) { _startTime = time; @@ -67,10 +61,7 @@ class TraceEvent : public StackObj { _endTime(0), _started(false) #ifdef ASSERT - , - _committed(false), - _cancelled(false), - _ignore_check(false) + , _committed(false) #endif { if (T::is_enabled()) { @@ -100,10 +91,9 @@ class TraceEvent : public StackObj { void commit() { if (!should_commit()) { - DEBUG_ONLY(cancel()); return; } - assert(!_cancelled, "Committing an event that has already been cancelled"); + assert(!_committed, "event already committed"); if (_startTime == 0) { static_cast(this)->set_starttime(Tracing::time()); } else if (_endTime == 0) { @@ -111,8 +101,8 @@ class TraceEvent : public StackObj { } if (static_cast(this)->should_write()) { static_cast(this)->writeEvent(); + DEBUG_ONLY(_committed = true;) } - DEBUG_ONLY(set_commited()); } static TraceEventId id() { @@ -134,32 +124,6 @@ class TraceEvent : public StackObj { static bool has_stacktrace() { return T::hasStackTrace; } - - void cancel() { - assert(!_committed && !_cancelled, - "event was already committed/cancelled"); - DEBUG_ONLY(_cancelled = true); - } - - ~TraceEvent() { - if (_started) { - assert(_ignore_check || _committed || _cancelled, - "event was not committed/cancelled"); - } - } - -#ifdef ASSERT - protected: - void ignoreCheck() { - _ignore_check = true; - } - - private: - void set_commited() { - assert(!_committed, "event has already been committed"); - _committed = true; - } -#endif // ASSERT }; #endif // INCLUDE_TRACE diff --git a/hotspot/src/share/vm/trace/traceEventClasses.xsl b/hotspot/src/share/vm/trace/traceEventClasses.xsl index 0bd5619ac9d..6f77487b3f3 100644 --- a/hotspot/src/share/vm/trace/traceEventClasses.xsl +++ b/hotspot/src/share/vm/trace/traceEventClasses.xsl @@ -1,6 +1,6 @@