# HG changeset patch # User amurillo # Date 1414103527 25200 # Node ID 8b9ec2da541a74ac698560b6a2bc45fccb789919 # Parent 8538a606a105b92d273899b640bc8b5e9b6f4fdb# Parent 8e15758b2e94e80c3356b933a690284934ef6892 Merge diff -r 8538a606a105 -r 8b9ec2da541a make/excludeSrc.make --- a/make/excludeSrc.make Wed Oct 22 11:18:17 2014 -0700 +++ b/make/excludeSrc.make Thu Oct 23 15:32:07 2014 -0700 @@ -97,6 +97,7 @@ ageTable.cpp \ collectorCounters.cpp \ cSpaceCounters.cpp \ + gcId.cpp \ gcPolicyCounters.cpp \ gcStats.cpp \ gcTimer.cpp \ diff -r 8538a606a105 -r 8b9ec2da541a make/hotspot_version --- a/make/hotspot_version Wed Oct 22 11:18:17 2014 -0700 +++ b/make/hotspot_version Thu Oct 23 15:32:07 2014 -0700 @@ -35,7 +35,7 @@ HS_MAJOR_VER=25 HS_MINOR_VER=40 -HS_BUILD_NUMBER=15 +HS_BUILD_NUMBER=16 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 diff -r 8538a606a105 -r 8b9ec2da541a make/jprt.properties --- a/make/jprt.properties Wed Oct 22 11:18:17 2014 -0700 +++ b/make/jprt.properties Thu Oct 23 15:32:07 2014 -0700 @@ -374,21 +374,25 @@ ${jprt.my.windows.i586}-fastdebug-c2-internalvmtests, \ ${jprt.my.windows.x64}-fastdebug-c2-internalvmtests -jprt.make.rule.test.targets.standard.wbapi = \ - ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.solaris.x64}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.linux.i586}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.linux.x64}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.windows.i586}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.windows.x64}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.linux.i586}-{product|fastdebug}-c1-wbapitest, \ - ${jprt.my.windows.i586}-{product|fastdebug}-c1-wbapitest +jprt.make.rule.test.targets.standard.reg.group = \ + ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.linux.i586}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.linux.x64}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.windows.i586}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.windows.x64}-{product|fastdebug}-c2-GROUP, \ + ${jprt.my.linux.i586}-{product|fastdebug}-c1-GROUP, \ + ${jprt.my.windows.i586}-{product|fastdebug}-c1-GROUP jprt.make.rule.test.targets.standard = \ ${jprt.make.rule.test.targets.standard.client}, \ ${jprt.make.rule.test.targets.standard.server}, \ ${jprt.make.rule.test.targets.standard.internalvmtests}, \ - ${jprt.make.rule.test.targets.standard.wbapi} + ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_wbapitest}, \ + ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_compiler}, \ + ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_gc}, \ + ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_runtime}, \ + ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_serviceability} jprt.make.rule.test.targets.embedded = \ ${jprt.make.rule.test.targets.standard.client} diff -r 8538a606a105 -r 8b9ec2da541a src/cpu/x86/vm/vm_version_x86.cpp --- a/src/cpu/x86/vm/vm_version_x86.cpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/cpu/x86/vm/vm_version_x86.cpp Thu Oct 23 15:32:07 2014 -0700 @@ -873,14 +873,19 @@ if (supports_bmi1()) { // tzcnt does not require VEX prefix if (FLAG_IS_DEFAULT(UseCountTrailingZerosInstruction)) { - UseCountTrailingZerosInstruction = true; + if (!UseBMI1Instructions && !FLAG_IS_DEFAULT(UseBMI1Instructions)) { + // Don't use tzcnt if BMI1 is switched off on command line. + UseCountTrailingZerosInstruction = false; + } else { + UseCountTrailingZerosInstruction = true; + } } } else if (UseCountTrailingZerosInstruction) { warning("tzcnt instruction is not available on this CPU"); FLAG_SET_DEFAULT(UseCountTrailingZerosInstruction, false); } - // BMI instructions use an encoding with VEX prefix. + // BMI instructions (except tzcnt) use an encoding with VEX prefix. // VEX prefix is generated only when AVX > 0. if (supports_bmi1() && supports_avx()) { if (FLAG_IS_DEFAULT(UseBMI1Instructions)) { diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/classfile/classFileParser.cpp --- a/src/share/vm/classfile/classFileParser.cpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/classfile/classFileParser.cpp Thu Oct 23 15:32:07 2014 -0700 @@ -4165,8 +4165,12 @@ tty->print("[Loaded %s from %s]\n", this_klass->external_name(), cfs->source()); } else if (class_loader.is_null()) { - if (THREAD->is_Java_thread()) { - Klass* caller = ((JavaThread*)THREAD)->security_get_caller_class(1); + Klass* caller = + THREAD->is_Java_thread() + ? ((JavaThread*)THREAD)->security_get_caller_class(1) + : NULL; + // caller can be NULL, for example, during a JVMTI VM_Init hook + if (caller != NULL) { tty->print("[Loaded %s by instance of %s]\n", this_klass->external_name(), InstanceKlass::cast(caller)->external_name()); diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/opto/doCall.cpp --- a/src/share/vm/opto/doCall.cpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/opto/doCall.cpp Thu Oct 23 15:32:07 2014 -0700 @@ -799,10 +799,16 @@ // each arm of the Phi. If I know something clever about the exceptions // I'm loading the class from, I can replace the LoadKlass with the // klass constant for the exception oop. - if( ex_node->is_Phi() ) { - ex_klass_node = new (C) PhiNode( ex_node->in(0), TypeKlassPtr::OBJECT ); - for( uint i = 1; i < ex_node->req(); i++ ) { - Node* p = basic_plus_adr( ex_node->in(i), ex_node->in(i), oopDesc::klass_offset_in_bytes() ); + if (ex_node->is_Phi()) { + ex_klass_node = new (C) PhiNode(ex_node->in(0), TypeKlassPtr::OBJECT); + for (uint i = 1; i < ex_node->req(); i++) { + Node* ex_in = ex_node->in(i); + if (ex_in == top() || ex_in == NULL) { + // This path was not taken. + ex_klass_node->init_req(i, top()); + continue; + } + Node* p = basic_plus_adr(ex_in, ex_in, oopDesc::klass_offset_in_bytes()); Node* k = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT) ); ex_klass_node->init_req( i, k ); } diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/prims/whitebox.cpp --- a/src/share/vm/prims/whitebox.cpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/prims/whitebox.cpp Thu Oct 23 15:32:07 2014 -0700 @@ -331,7 +331,36 @@ } WB_END +WB_ENTRY(jboolean, WB_NMTChangeTrackingLevel(JNIEnv* env)) + // Test that we can downgrade NMT levels but not upgrade them. + if (MemTracker::tracking_level() == NMT_off) { + MemTracker::transition_to(NMT_off); + return MemTracker::tracking_level() == NMT_off; + } else { + assert(MemTracker::tracking_level() == NMT_detail, "Should start out as detail tracking"); + MemTracker::transition_to(NMT_summary); + assert(MemTracker::tracking_level() == NMT_summary, "Should be summary now"); + // Can't go to detail once NMT is set to summary. + MemTracker::transition_to(NMT_detail); + assert(MemTracker::tracking_level() == NMT_summary, "Should still be summary now"); + + // Shutdown sets tracking level to minimal. + MemTracker::shutdown(); + assert(MemTracker::tracking_level() == NMT_minimal, "Should be minimal now"); + + // Once the tracking level is minimal, we cannot increase to summary. + // The code ignores this request instead of asserting because if the malloc site + // table overflows in another thread, it tries to change the code to summary. + MemTracker::transition_to(NMT_summary); + assert(MemTracker::tracking_level() == NMT_minimal, "Should still be minimal now"); + + // Really can never go up to detail, verify that the code would never do this. + MemTracker::transition_to(NMT_detail); + assert(MemTracker::tracking_level() == NMT_minimal, "Should still be minimal now"); + return MemTracker::tracking_level() == NMT_minimal; + } +WB_END #endif // INCLUDE_NMT static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { @@ -936,6 +965,7 @@ {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory }, {CC"NMTOverflowHashBucket", CC"(J)V", (void*)&WB_NMTOverflowHashBucket}, {CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported}, + {CC"NMTChangeTrackingLevel", CC"()Z", (void*)&WB_NMTChangeTrackingLevel}, #endif // INCLUDE_NMT {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Executable;Z)I", diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/runtime/os.hpp --- a/src/share/vm/runtime/os.hpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/runtime/os.hpp Thu Oct 23 15:32:07 2014 -0700 @@ -214,13 +214,14 @@ // Interface for detecting multiprocessor system static inline bool is_MP() { -#if !INCLUDE_NMT - assert(_processor_count > 0, "invalid processor count"); - return _processor_count > 1 || AssumeMP; -#else - // NMT needs atomic operations before this initialization. - return true; -#endif + // During bootstrap if _processor_count is not yet initialized + // we claim to be MP as that is safest. If any platform has a + // stub generator that might be triggered in this phase and for + // which being declared MP when in fact not, is a problem - then + // the bootstrap routine for the stub generator needs to check + // the processor count directly and leave the bootstrap routine + // in place until called after initialization has ocurred. + return (_processor_count != 1) || AssumeMP; } static julong available_memory(); static julong physical_memory(); diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/services/mallocTracker.cpp --- a/src/share/vm/services/mallocTracker.cpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/services/mallocTracker.cpp Thu Oct 23 15:32:07 2014 -0700 @@ -51,14 +51,6 @@ return amount; } - -void MallocMemorySnapshot::reset() { - _tracking_header.reset(); - for (int index = 0; index < mt_number_of_types; index ++) { - _malloc[index].reset(); - } -} - // Make adjustment by subtracting chunks used by arenas // from total chunks to get total free chunck size void MallocMemorySnapshot::make_adjustment() { @@ -116,14 +108,9 @@ bool MallocTracker::transition(NMT_TrackingLevel from, NMT_TrackingLevel to) { assert(from != NMT_off, "Can not transition from off state"); assert(to != NMT_off, "Can not transition to off state"); - if (from == NMT_minimal) { - MallocMemorySummary::reset(); - } + assert (from != NMT_minimal, "cannot transition from minimal state"); - if (to == NMT_detail) { - assert(from == NMT_minimal || from == NMT_summary, "Just check"); - return MallocSiteTable::initialize(); - } else if (from == NMT_detail) { + if (from == NMT_detail) { assert(to == NMT_minimal || to == NMT_summary, "Just check"); MallocSiteTable::shutdown(); } diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/services/mallocTracker.hpp --- a/src/share/vm/services/mallocTracker.hpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/services/mallocTracker.hpp Thu Oct 23 15:32:07 2014 -0700 @@ -51,14 +51,6 @@ DEBUG_ONLY(_peak_size = 0;) } - // Reset counters - void reset() { - _size = 0; - _count = 0; - DEBUG_ONLY(_peak_size = 0;) - DEBUG_ONLY(_peak_count = 0;) - } - inline void allocate(size_t sz) { Atomic::add(1, (volatile MemoryCounterType*)&_count); if (sz > 0) { @@ -124,11 +116,6 @@ _arena.resize(sz); } - void reset() { - _malloc.reset(); - _arena.reset(); - } - inline size_t malloc_size() const { return _malloc.size(); } inline size_t malloc_count() const { return _malloc.count();} inline size_t arena_size() const { return _arena.size(); } @@ -176,8 +163,6 @@ return s->by_type(mtThreadStack)->malloc_count(); } - void reset(); - void copy_to(MallocMemorySnapshot* s) { s->_tracking_header = _tracking_header; for (int index = 0; index < mt_number_of_types; index ++) { @@ -240,11 +225,6 @@ return as_snapshot()->malloc_overhead()->size(); } - // Reset all counters to zero - static void reset() { - as_snapshot()->reset(); - } - static MallocMemorySnapshot* as_snapshot() { return (MallocMemorySnapshot*)_snapshot; } diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/services/memBaseline.hpp --- a/src/share/vm/services/memBaseline.hpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/services/memBaseline.hpp Thu Oct 23 15:32:07 2014 -0700 @@ -90,10 +90,6 @@ _class_count(0) { } - ~MemBaseline() { - reset(); - } - bool baseline(bool summaryOnly = true); BaselineType baseline_type() const { return _baseline_type; } @@ -169,8 +165,7 @@ // reset the baseline for reuse void reset() { _baseline_type = Not_baselined; - _malloc_memory_snapshot.reset(); - _virtual_memory_snapshot.reset(); + // _malloc_memory_snapshot and _virtual_memory_snapshot are copied over. _class_count = 0; _malloc_sites.clear(); diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/services/memReporter.hpp --- a/src/share/vm/services/memReporter.hpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/services/memReporter.hpp Thu Oct 23 15:32:07 2014 -0700 @@ -96,20 +96,6 @@ size_t _class_count; public: - // Report summary tracking data from global snapshots directly. - // This constructor is used for final reporting and hs_err reporting. - MemSummaryReporter(MallocMemorySnapshot* malloc_snapshot, - VirtualMemorySnapshot* vm_snapshot, outputStream* output, - size_t class_count = 0, size_t scale = K) : - MemReporterBase(output, scale), - _malloc_snapshot(malloc_snapshot), - _vm_snapshot(vm_snapshot) { - if (class_count == 0) { - _class_count = InstanceKlass::number_of_instance_classes(); - } else { - _class_count = class_count; - } - } // This constructor is for normal reporting from a recent baseline. MemSummaryReporter(MemBaseline& baseline, outputStream* output, size_t scale = K) : MemReporterBase(output, scale), diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/services/memTracker.cpp --- a/src/share/vm/services/memTracker.cpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/services/memTracker.cpp Thu Oct 23 15:32:07 2014 -0700 @@ -144,11 +144,9 @@ } -// Shutdown can only be issued via JCmd, and NMT JCmd is serialized -// by lock +// Shutdown can only be issued via JCmd, and NMT JCmd is serialized by lock void MemTracker::shutdown() { - // We can only shutdown NMT to minimal tracking level if it is - // ever on. + // We can only shutdown NMT to minimal tracking level if it is ever on. if (tracking_level () > NMT_minimal) { transition_to(NMT_minimal); } @@ -157,45 +155,36 @@ bool MemTracker::transition_to(NMT_TrackingLevel level) { NMT_TrackingLevel current_level = tracking_level(); + assert(level != NMT_off || current_level == NMT_off, "Cannot transition NMT to off"); + if (current_level == level) { return true; } else if (current_level > level) { - // Downgrade tracking level, we want to lower the tracking - // level first + // Downgrade tracking level, we want to lower the tracking level first _tracking_level = level; // Make _tracking_level visible immediately. OrderAccess::fence(); VirtualMemoryTracker::transition(current_level, level); MallocTracker::transition(current_level, level); - - if (level == NMT_minimal) _baseline.reset(); } else { - VirtualMemoryTracker::transition(current_level, level); - MallocTracker::transition(current_level, level); - - _tracking_level = level; - // Make _tracking_level visible immediately. - OrderAccess::fence(); + // Upgrading tracking level is not supported and has never been supported. + // Allocating and deallocating malloc tracking structures is not thread safe and + // leads to inconsistencies unless a lot coarser locks are added. } - return true; } -void MemTracker::final_report(outputStream* output) { - assert(output != NULL, "No output stream"); - if (tracking_level() >= NMT_summary) { - MallocMemorySnapshot* malloc_memory_snapshot = - MallocMemorySummary::as_snapshot(); - malloc_memory_snapshot->make_adjustment(); - - VirtualMemorySnapshot* virtual_memory_snapshot = - VirtualMemorySummary::as_snapshot(); - - MemSummaryReporter rptr(malloc_memory_snapshot, - virtual_memory_snapshot, output); - rptr.report(); - // shutdown NMT, the data no longer accurate - shutdown(); +void MemTracker::report(bool summary_only, outputStream* output) { + assert(output != NULL, "No output stream"); + MemBaseline baseline; + if (baseline.baseline(summary_only)) { + if (summary_only) { + MemSummaryReporter rpt(baseline, output); + rpt.report(); + } else { + MemDetailReporter rpt(baseline, output); + rpt.report(); + } } } diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/services/memTracker.hpp --- a/src/share/vm/services/memTracker.hpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/services/memTracker.hpp Thu Oct 23 15:32:07 2014 -0700 @@ -70,6 +70,7 @@ static inline void release_thread_stack(void* addr, size_t size) { } static void final_report(outputStream*) { } + static void error_report(outputStream*) { } }; #else @@ -270,13 +271,20 @@ // other tools. static inline Mutex* query_lock() { return _query_lock; } - // Make a final report and shutdown. - // This function generates summary report without creating snapshots, - // to avoid additional memory allocation. It uses native memory summary - // counters, and makes adjustment to them, once the adjustment is made, - // the counters are no longer accurate. As the result, this function - // should only be used for final reporting before shutting down. - static void final_report(outputStream*); + // Make a final report or report for hs_err file. + static void error_report(outputStream* output) { + if (tracking_level() >= NMT_summary) { + report(true, output); // just print summary for error case. + } + } + + static void final_report(outputStream* output) { + NMT_TrackingLevel level = tracking_level(); + if (level >= NMT_summary) { + report(level == NMT_summary, output); + } + } + // Stored baseline static inline MemBaseline& get_baseline() { @@ -291,6 +299,7 @@ private: static NMT_TrackingLevel init_tracking_level(); + static void report(bool summary_only, outputStream* output); private: // Tracking level diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/services/virtualMemoryTracker.cpp --- a/src/share/vm/services/virtualMemoryTracker.cpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/services/virtualMemoryTracker.cpp Thu Oct 23 15:32:07 2014 -0700 @@ -443,26 +443,28 @@ bool VirtualMemoryTracker::walk_virtual_memory(VirtualMemoryWalker* walker) { assert(_reserved_regions != NULL, "Sanity check"); ThreadCritical tc; - LinkedListNode* head = _reserved_regions->head(); - while (head != NULL) { - const ReservedMemoryRegion* rgn = head->peek(); - if (!walker->do_allocation_site(rgn)) { - return false; + // Check that the _reserved_regions haven't been deleted. + if (_reserved_regions != NULL) { + LinkedListNode* head = _reserved_regions->head(); + while (head != NULL) { + const ReservedMemoryRegion* rgn = head->peek(); + if (!walker->do_allocation_site(rgn)) { + return false; + } + head = head->next(); } - head = head->next(); - } + } return true; } // Transition virtual memory tracking level. bool VirtualMemoryTracker::transition(NMT_TrackingLevel from, NMT_TrackingLevel to) { - if (from == NMT_minimal) { - assert(to == NMT_summary || to == NMT_detail, "Just check"); - VirtualMemorySummary::reset(); - } else if (to == NMT_minimal) { + assert (from != NMT_minimal, "cannot convert from the lowest tracking level to anything"); + if (to == NMT_minimal) { assert(from == NMT_summary || from == NMT_detail, "Just check"); // Clean up virtual memory tracking data structures. ThreadCritical tc; + // Check for potential race with other thread calling transition if (_reserved_regions != NULL) { delete _reserved_regions; _reserved_regions = NULL; diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/services/virtualMemoryTracker.hpp --- a/src/share/vm/services/virtualMemoryTracker.hpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/services/virtualMemoryTracker.hpp Thu Oct 23 15:32:07 2014 -0700 @@ -62,11 +62,6 @@ _committed -= sz; } - void reset() { - _reserved = 0; - _committed = 0; - } - inline size_t reserved() const { return _reserved; } inline size_t committed() const { return _committed; } }; @@ -123,12 +118,6 @@ return amount; } - inline void reset() { - for (int index = 0; index < mt_number_of_types; index ++) { - _virtual_memory[index].reset(); - } - } - void copy_to(VirtualMemorySnapshot* s) { for (int index = 0; index < mt_number_of_types; index ++) { s->_virtual_memory[index] = _virtual_memory[index]; @@ -174,10 +163,6 @@ as_snapshot()->copy_to(s); } - static inline void reset() { - as_snapshot()->reset(); - } - static VirtualMemorySnapshot* as_snapshot() { return (VirtualMemorySnapshot*)_snapshot; } diff -r 8538a606a105 -r 8b9ec2da541a src/share/vm/utilities/vmError.cpp --- a/src/share/vm/utilities/vmError.cpp Wed Oct 22 11:18:17 2014 -0700 +++ b/src/share/vm/utilities/vmError.cpp Thu Oct 23 15:32:07 2014 -0700 @@ -774,7 +774,7 @@ STEP(228, "(Native Memory Tracking)" ) if (_verbose) { - MemTracker::final_report(st); + MemTracker::error_report(st); } STEP(230, "" ) diff -r 8538a606a105 -r 8b9ec2da541a test/Makefile --- a/test/Makefile Wed Oct 22 11:18:17 2014 -0700 +++ b/test/Makefile Thu Oct 23 15:32:07 2014 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1995, 2014, 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 @@ -23,14 +23,36 @@ # # -# Makefile to run various jdk tests +# Makefile to run various hotspot tests # GETMIXEDPATH=echo -# Get OS/ARCH specifics -OSNAME = $(shell uname -s) -ifeq ($(OSNAME), SunOS) +# Utilities used +AWK = awk +CAT = cat +CD = cd +CHMOD = chmod +CP = cp +CUT = cut +DIRNAME = dirname +ECHO = echo +EGREP = egrep +EXPAND = expand +FIND = find +MKDIR = mkdir +PWD = pwd +SED = sed +SORT = sort +TEE = tee +UNAME = uname +UNIQ = uniq +WC = wc +ZIP = zip + +# Get OS name from uname (Cygwin inexplicably adds _NT-5.1) +UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_) +ifeq ($(UNAME_S), SunOS) PLATFORM = solaris SLASH_JAVA = /java ARCH = $(shell uname -p) @@ -38,7 +60,7 @@ ARCH=i586 endif endif -ifeq ($(OSNAME), Linux) +ifeq ($(UNAME_S), Linux) PLATFORM = linux SLASH_JAVA = /java ARCH = $(shell uname -m) @@ -46,7 +68,7 @@ ARCH = i586 endif endif -ifeq ($(OSNAME), Darwin) +ifeq ($(UNAME_S), Darwin) PLATFORM = bsd SLASH_JAVA = /java ARCH = $(shell uname -m) @@ -54,7 +76,7 @@ ARCH = i586 endif endif -ifeq ($(findstring BSD,$(OSNAME)), BSD) +ifeq ($(findstring BSD,$(UNAME_S)), BSD) PLATFORM = bsd SLASH_JAVA = /java ARCH = $(shell uname -m) @@ -63,12 +85,12 @@ endif endif ifeq ($(PLATFORM),) - # detect wether we're running in MKS or cygwin - ifeq ($(OSNAME), Windows_NT) # MKS + # detect whether we're running in MKS or cygwin + ifeq ($(UNAME_S), Windows_NT) # MKS GETMIXEDPATH=dosname -s endif - ifeq ($(findstring CYGWIN,$(OSNAME)), CYGWIN) - GETMIXEDPATH=cygpath -m -s + ifeq ($(findstring CYGWIN,$(UNAME_S)), CYGWIN) + GETMIXEDPATH=cygpath -m endif PLATFORM = windows SLASH_JAVA = J: @@ -92,13 +114,6 @@ SLASH_JAVA = $(ALT_SLASH_JAVA) endif -# Utilities used -CD = cd -CP = cp -ECHO = echo -MKDIR = mkdir -ZIP = zip - # Root of this test area (important to use full paths in some places) TEST_ROOT := $(shell pwd) @@ -136,21 +151,82 @@ endif # How to create the test bundle (pass or fail, we want to create this) -BUNDLE_UP = ( $(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)` \ - && $(CD) $(ABS_TEST_OUTPUT_DIR) \ - && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . ) -BUNDLE_UP_FAILED = ( exitCode=$$? && $(BUNDLE_UP) && exit $${exitCode} ) +# Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed. +ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \ + && $(CD) $(ABS_TEST_OUTPUT_DIR) \ + && $(CHMOD) -R a+r . \ + && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . ) + +# important results files +SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt") +STATS_TXT_NAME = Stats.txt +STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)") +RUNLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt") +PASSLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt") +FAILLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt") +EXITCODE = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt") + +TESTEXIT = \ + if [ ! -s $(EXITCODE) ] ; then \ + $(ECHO) "ERROR: EXITCODE file not filled in."; \ + $(ECHO) "1" > $(EXITCODE); \ + fi ; \ + testExitCode=`$(CAT) $(EXITCODE)`; \ + $(ECHO) "EXIT CODE: $${testExitCode}"; \ + exit $${testExitCode} + +BUNDLE_UP_AND_EXIT = \ +( \ + jtregExitCode=$$? && \ + _summary="$(SUMMARY_TXT)"; \ + $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \ + $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \ + if [ -r "$${_summary}" ] ; then \ + $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \ + $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \ + $(EGREP) ' Passed\.' $(RUNLIST) \ + | $(EGREP) -v ' Error\.' \ + | $(EGREP) -v ' Failed\.' > $(PASSLIST); \ + ( $(EGREP) ' Failed\.' $(RUNLIST); \ + $(EGREP) ' Error\.' $(RUNLIST); \ + $(EGREP) -v ' Passed\.' $(RUNLIST) ) \ + | $(SORT) | $(UNIQ) > $(FAILLIST); \ + if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \ + $(EXPAND) $(FAILLIST) \ + | $(CUT) -d' ' -f1 \ + | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \ + if [ $${jtregExitCode} = 0 ] ; then \ + jtregExitCode=1; \ + fi; \ + fi; \ + runc="`$(CAT) $(RUNLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ + passc="`$(CAT) $(PASSLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ + failc="`$(CAT) $(FAILLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ + exclc="FIXME CODETOOLS-7900176"; \ + $(ECHO) "TEST STATS: name=$(UNIQUE_DIR) run=$${runc} pass=$${passc} fail=$${failc}" \ + >> $(STATS_TXT); \ + else \ + $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \ + fi; \ + if [ -f $(STATS_TXT) ] ; then \ + $(CAT) $(STATS_TXT); \ + fi; \ + $(ZIP_UP_RESULTS) ; \ + $(TESTEXIT) \ +) ################################################################ # Default make rule (runs jtreg_tests) -all: jtreg_tests +all: hotspot_all @$(ECHO) "Testing completed successfully" -# Support "hotspot_" prefixed test make targets too -# The hotspot_% targets are for example invoked by the top level Makefile +# Support "hotspot_" prefixed test make targets (too) +# The hotspot_% targets are used by the top level Makefile +# Unless explicitly defined below, hotspot_ is interpreted as a jtreg test group name hotspot_%: - $(MAKE) $* + $(ECHO) "Running tests: $@" + $(MAKE) -j 1 TEST_SELECTION=":$@" UNIQUE_DIR=$@ jtreg_tests; # Prep for output prep: clean @@ -168,41 +244,64 @@ # Expect JT_HOME to be set for jtreg tests. (home for jtreg) ifndef JT_HOME - JT_HOME = $(SLASH_JAVA)/re/jtreg/4.0/promoted/latest/binaries/jtreg -endif -ifdef JPRT_JTREG_HOME - JT_HOME = $(JPRT_JTREG_HOME) + JT_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg + ifdef JPRT_JTREG_HOME + JT_HOME = $(JPRT_JTREG_HOME) + endif endif -# Expect JPRT to set TESTDIRS to the jtreg test dirs -JTREG_TESTDIRS = demo/jvmti/gctest demo/jvmti/hprof +# When called from JPRT the TESTDIRS variable is set to the jtreg tests to run ifdef TESTDIRS - JTREG_TESTDIRS = $(TESTDIRS) + TEST_SELECTION = $(TESTDIRS) +endif + +ifdef CONCURRENCY + EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY) endif # Default JTREG to run JTREG = $(JT_HOME)/bin/jtreg +# Only run automatic tests +JTREG_BASIC_OPTIONS += -a +# Report details on all failed or error tests, times too +JTREG_BASIC_OPTIONS += -v:fail,error,time +# Retain all files for failing tests +JTREG_BASIC_OPTIONS += -retain:fail,error +# Ignore tests are not run and completely silent about it +JTREG_IGNORE_OPTION = -ignore:quiet +JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION) +# Add any extra options +JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS) +# Set other vm and test options +JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_OPTIONS:%=-vmoption:%) $(JAVA_VM_ARGS:%=-vmoption:%) + # Option to tell jtreg to not run tests marked with "ignore" ifeq ($(PLATFORM), windows) JTREG_KEY_OPTION = -k:!ignore else JTREG_KEY_OPTION = -k:\!ignore endif - -#EXTRA_JTREG_OPTIONS = +JTREG_BASIC_OPTIONS += $(JTREG_KEY_OPTION) + +# Make sure jtreg exists +$(JTREG): $(JT_HOME) -jtreg_tests: prep $(JT_HOME) $(PRODUCT_HOME) $(JTREG) - $(JTREG) -a -v:fail,error \ - $(JTREG_KEY_OPTION) \ - $(EXTRA_JTREG_OPTIONS) \ - -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport \ - -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork \ - -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ - $(JAVA_OPTIONS:%=-vmoption:%) \ - $(JTREG_TESTDIRS) \ - || $(BUNDLE_UP_FAILED) - $(BUNDLE_UP) +jtreg_tests: prep $(PRODUCT_HOME) $(JTREG) + ( \ + ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)"); \ + export JT_HOME; \ + $(shell $(GETMIXEDPATH) "$(JTREG)") \ + $(JTREG_BASIC_OPTIONS) \ + -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport") \ + -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork") \ + -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ + $(JTREG_EXCLUSIONS) \ + $(JTREG_TEST_OPTIONS) \ + $(TEST_SELECTION) \ + ) ; \ + $(BUNDLE_UP_AND_EXIT) \ + ) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT) PHONY_LIST += jtreg_tests @@ -210,7 +309,7 @@ # clienttest (make sure various basic java client options work) -clienttest: prep $(PRODUCT_HOME) +hotspot_clienttest clienttest: prep $(PRODUCT_HOME) $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X @@ -218,73 +317,38 @@ $(RM) $(PRODUCT_HOME)/jre/bin/client/classes.jsa $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -Xshare:dump -PHONY_LIST += clienttest +PHONY_LIST += hotspot_clienttest clienttest + +################################################################ + +# minimaltest (make sure various basic java minimal options work) + +hotspot_minimaltest minimaltest: prep $(PRODUCT_HOME) + $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version + $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help + $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X + +PHONY_LIST += hotspot_minimaltest minimaltest ################################################################ # servertest (make sure various basic java server options work) -servertest: prep $(PRODUCT_HOME) +hotspot_servertest servertest: prep $(PRODUCT_HOME) $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X -PHONY_LIST += servertest +PHONY_LIST += hotspot_servertest servertest ################################################################ # internalvmtests (run internal unit tests inside the VM) -internalvmtests: prep $(PRODUCT_HOME) +hotspot_internalvmtests internalvmtests: prep $(PRODUCT_HOME) $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -XX:+ExecuteInternalVMTests -version -PHONY_LIST += internalvmtests - -################################################################ - -# wbapitest (make sure the whitebox testing api classes work - -wbapitest: prep $(JT_HOME) $(PRODUCT_HOME) $(JTREG) - $(JTREG) -a -v:fail,error \ - $(JTREG_KEY_OPTION) \ - $(EXTRA_JTREG_OPTIONS) \ - -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport \ - -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork \ - -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ - $(JAVA_OPTIONS:%=-vmoption:%) \ - $(shell $(GETMIXEDPATH) "$(TEST_ROOT)")/sanity \ - || $(BUNDLE_UP_FAILED) - $(BUNDLE_UP) - -PHONY_LIST += wbapitest - -################################################################ - -# packtest - -# Expect JPRT to set JPRT_PACKTEST_HOME. -PACKTEST_HOME = /net/jprt-web.sfbay.sun.com/jprt/allproducts/packtest -ifdef JPRT_PACKTEST_HOME - PACKTEST_HOME = $(JPRT_PACKTEST_HOME) -endif - -#EXTRA_PACKTEST_OPTIONS = - -packtest: prep $(PACKTEST_HOME)/ptest $(PRODUCT_HOME) - ( $(CD) $(PACKTEST_HOME) && \ - $(PACKTEST_HOME)/ptest \ - -t "$(PRODUCT_HOME)" \ - $(PACKTEST_STRESS_OPTION) \ - $(EXTRA_PACKTEST_OPTIONS) \ - -W $(ABS_TEST_OUTPUT_DIR) \ - $(JAVA_OPTIONS:%=-J %) \ - ) || $(BUNDLE_UP_FAILED) - $(BUNDLE_UP) - -packtest_stress: PACKTEST_STRESS_OPTION=-s -packtest_stress: packtest - -PHONY_LIST += packtest packtest_stress +PHONY_LIST += hotspot_internalvmtests internalvmtests ################################################################ @@ -292,4 +356,3 @@ .PHONY: all clean prep $(PHONY_LIST) ################################################################ - diff -r 8538a606a105 -r 8b9ec2da541a test/TEST.groups --- a/test/TEST.groups Wed Oct 22 11:18:17 2014 -0700 +++ b/test/TEST.groups Thu Oct 23 15:32:07 2014 -0700 @@ -125,6 +125,27 @@ -:needs_jdk +# When called from top level the test suites use the hotspot_ prefix +hotspot_wbapitest = \ + sanity/ + +hotspot_compiler = \ + sanity/ExecuteInternalVMTests.java + +hotspot_gc = \ + sanity/ExecuteInternalVMTests.java + +hotspot_runtime = \ + sanity/ExecuteInternalVMTests.java + +hotspot_serviceability = \ + sanity/ExecuteInternalVMTests.java + +hotspot_all = \ + :hotspot_compiler \ + :hotspot_gc \ + :hotspot_runtime \ + :hotspot_serviceability # Tests that require compact3 API's # needs_compact3 = \ diff -r 8538a606a105 -r 8b9ec2da541a test/compiler/exceptions/CatchInlineExceptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/exceptions/CatchInlineExceptions.java Thu Oct 23 15:32:07 2014 -0700 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2014, 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 + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8059299 + * @summary assert(adr_type != NULL) failed: expecting TypeKlassPtr + * @run main/othervm -Xbatch CatchInlineExceptions + */ + +class Exception1 extends Exception {}; +class Exception2 extends Exception {}; + +public class CatchInlineExceptions { + private static int counter0; + private static int counter1; + private static int counter2; + private static int counter; + + static void foo(int i) throws Exception { + if ((i & 1023) == 2) { + counter0++; + throw new Exception2(); + } + } + + static void test(int i) throws Exception { + try { + foo(i); + } + catch (Exception e) { + if (e instanceof Exception1) { + counter1++; + } else if (e instanceof Exception2) { + counter2++; + } + counter++; + throw e; + } + } + + public static void main(String[] args) throws Throwable { + for (int i = 0; i < 15000; i++) { + try { + test(i); + } catch (Exception e) { + // expected + } + } + if (counter1 != 0) { + throw new RuntimeException("Failed: counter1(" + counter1 + ") != 0"); + } + if (counter2 != counter0) { + throw new RuntimeException("Failed: counter2(" + counter2 + ") != counter0(" + counter0 + ")"); + } + if (counter2 != counter) { + throw new RuntimeException("Failed: counter2(" + counter2 + ") != counter(" + counter + ")"); + } + System.out.println("TEST PASSED"); + } +} diff -r 8538a606a105 -r 8b9ec2da541a test/runtime/NMT/ChangeTrackingLevel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/NMT/ChangeTrackingLevel.java Thu Oct 23 15:32:07 2014 -0700 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013, 2014, 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 + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8059100 + * @summary Test that you can decrease NMT tracking level but not increase it. + * @key nmt + * @library /testlibrary /testlibrary/whitebox + * @build ChangeTrackingLevel + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ChangeTrackingLevel + */ + +import com.oracle.java.testlibrary.*; +import sun.hotspot.WhiteBox; + +public class ChangeTrackingLevel { + + public static WhiteBox wb = WhiteBox.getWhiteBox(); + public static void main(String args[]) throws Exception { + boolean testChangeLevel = wb.NMTChangeTrackingLevel(); + if (testChangeLevel) { + System.out.println("NMT level change test passed."); + } else { + // it also fails if the VM asserts. + throw new RuntimeException("NMT level change test failed"); + } + } +}; diff -r 8538a606a105 -r 8b9ec2da541a test/testlibrary/whitebox/sun/hotspot/WhiteBox.java --- a/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java Wed Oct 22 11:18:17 2014 -0700 +++ b/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java Thu Oct 23 15:32:07 2014 -0700 @@ -101,6 +101,7 @@ public native void NMTOverflowHashBucket(long num); public native long NMTMallocWithPseudoStack(long size, int index); public native boolean NMTIsDetailSupported(); + public native boolean NMTChangeTrackingLevel(); // Compiler public native void deoptimizeAll();