Wed, 09 Oct 2013 05:03:34 -0700
Merge
test/testlibrary/AssertsTest.java | file | annotate | diff | comparison | revisions | |
test/testlibrary/OutputAnalyzerReportingTest.java | file | annotate | diff | comparison | revisions | |
test/testlibrary/OutputAnalyzerTest.java | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Wed Oct 09 13:00:20 2013 +0200 1.2 +++ b/.hgtags Wed Oct 09 05:03:34 2013 -0700 1.3 @@ -379,3 +379,7 @@ 1.4 a09fe9d1e016c285307507a5793bc4fa6215e9c9 hs25-b50 1.5 85072013aad46050a362d10ab78e963121c8014c jdk8-b108 1.6 566db1b0e6efca31f181456e54c8911d0192410d hs25-b51 1.7 +c81dd5393a5e333df7cb1f6621f5897ada6522b5 jdk8-b109 1.8 +58043478c26d4e8bf48700acea5f97aba8b417d4 hs25-b52 1.9 +6209b0ed51c086d4127bac0e086c8f326d1764d7 jdk8-b110 1.10 +562a3d356de67670b4172b82aca2d30743449e04 hs25-b53
2.1 --- a/make/bsd/makefiles/fastdebug.make Wed Oct 09 13:00:20 2013 +0200 2.2 +++ b/make/bsd/makefiles/fastdebug.make Wed Oct 09 05:03:34 2013 -0700 2.3 @@ -1,5 +1,5 @@ 2.4 # 2.5 -# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 2.6 +# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 2.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 # 2.9 # This code is free software; you can redistribute it and/or modify it 2.10 @@ -59,5 +59,5 @@ 2.11 MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug 2.12 2.13 VERSION = fastdebug 2.14 -SYSDEFS += -DASSERT 2.15 +SYSDEFS += -DASSERT -DCHECK_UNHANDLED_OOPS 2.16 PICFLAGS = DEFAULT
3.1 --- a/make/excludeSrc.make Wed Oct 09 13:00:20 2013 +0200 3.2 +++ b/make/excludeSrc.make Wed Oct 09 05:03:34 2013 -0700 3.3 @@ -88,7 +88,7 @@ 3.4 g1ErgoVerbose.cpp g1GCPhaseTimes.cpp g1HRPrinter.cpp g1HotCardCache.cpp g1Log.cpp \ 3.5 g1MMUTracker.cpp g1MarkSweep.cpp g1MemoryPool.cpp g1MonitoringSupport.cpp \ 3.6 g1RemSet.cpp g1RemSetSummary.cpp g1SATBCardTableModRefBS.cpp g1_globals.cpp heapRegion.cpp \ 3.7 - heapRegionRemSet.cpp heapRegionSeq.cpp heapRegionSet.cpp heapRegionSets.cpp \ 3.8 + g1BiasedArray.cpp heapRegionRemSet.cpp heapRegionSeq.cpp heapRegionSet.cpp heapRegionSets.cpp \ 3.9 ptrQueue.cpp satbQueue.cpp sparsePRT.cpp survRateGroup.cpp vm_operations_g1.cpp \ 3.10 adjoiningGenerations.cpp adjoiningVirtualSpaces.cpp asPSOldGen.cpp asPSYoungGen.cpp \ 3.11 cardTableExtension.cpp gcTaskManager.cpp gcTaskThread.cpp objectStartArray.cpp \
4.1 --- a/make/hotspot_version Wed Oct 09 13:00:20 2013 +0200 4.2 +++ b/make/hotspot_version Wed Oct 09 05:03:34 2013 -0700 4.3 @@ -35,7 +35,7 @@ 4.4 4.5 HS_MAJOR_VER=25 4.6 HS_MINOR_VER=0 4.7 -HS_BUILD_NUMBER=52 4.8 +HS_BUILD_NUMBER=54 4.9 4.10 JDK_MAJOR_VER=1 4.11 JDK_MINOR_VER=8
5.1 --- a/make/jprt.properties Wed Oct 09 13:00:20 2013 +0200 5.2 +++ b/make/jprt.properties Wed Oct 09 05:03:34 2013 -0700 5.3 @@ -120,13 +120,13 @@ 5.4 jprt.my.macosx.x64.jdk7u8=${jprt.my.macosx.x64.jdk7} 5.5 jprt.my.macosx.x64=${jprt.my.macosx.x64.${jprt.tools.default.release}} 5.6 5.7 -jprt.my.windows.i586.jdk8=windows_i586_5.1 5.8 -jprt.my.windows.i586.jdk7=windows_i586_5.1 5.9 +jprt.my.windows.i586.jdk8=windows_i586_6.1 5.10 +jprt.my.windows.i586.jdk7=windows_i586_6.1 5.11 jprt.my.windows.i586.jdk7u8=${jprt.my.windows.i586.jdk7} 5.12 jprt.my.windows.i586=${jprt.my.windows.i586.${jprt.tools.default.release}} 5.13 5.14 -jprt.my.windows.x64.jdk8=windows_x64_5.2 5.15 -jprt.my.windows.x64.jdk7=windows_x64_5.2 5.16 +jprt.my.windows.x64.jdk8=windows_x64_6.1 5.17 +jprt.my.windows.x64.jdk7=windows_x64_6.1 5.18 jprt.my.windows.x64.jdk7u8=${jprt.my.windows.x64.jdk7} 5.19 jprt.my.windows.x64=${jprt.my.windows.x64.${jprt.tools.default.release}} 5.20
6.1 --- a/make/linux/makefiles/fastdebug.make Wed Oct 09 13:00:20 2013 +0200 6.2 +++ b/make/linux/makefiles/fastdebug.make Wed Oct 09 05:03:34 2013 -0700 6.3 @@ -59,5 +59,5 @@ 6.4 MAPFILE = $(GAMMADIR)/make/linux/makefiles/mapfile-vers-debug 6.5 6.6 VERSION = optimized 6.7 -SYSDEFS += -DASSERT 6.8 +SYSDEFS += -DASSERT -DCHECK_UNHANDLED_OOPS 6.9 PICFLAGS = DEFAULT
7.1 --- a/make/windows/makefiles/fastdebug.make Wed Oct 09 13:00:20 2013 +0200 7.2 +++ b/make/windows/makefiles/fastdebug.make Wed Oct 09 05:03:34 2013 -0700 7.3 @@ -1,5 +1,5 @@ 7.4 # 7.5 -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 7.6 +# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 7.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 # 7.9 # This code is free software; you can redistribute it and/or modify it 7.10 @@ -38,7 +38,7 @@ 7.11 !include ../local.make 7.12 !include compile.make 7.13 7.14 -CXX_FLAGS=$(CXX_FLAGS) $(FASTDEBUG_OPT_OPTION) 7.15 +CXX_FLAGS=$(CXX_FLAGS) $(FASTDEBUG_OPT_OPTION) /D "CHECK_UNHANDLED_OOPS" 7.16 7.17 !include $(WorkSpace)/make/windows/makefiles/vm.make 7.18 !include local.make
8.1 --- a/src/cpu/sparc/vm/frame_sparc.cpp Wed Oct 09 13:00:20 2013 +0200 8.2 +++ b/src/cpu/sparc/vm/frame_sparc.cpp Wed Oct 09 05:03:34 2013 -0700 8.3 @@ -764,7 +764,7 @@ 8.4 #ifdef CC_INTERP 8.5 *oop_result = istate->_oop_temp; 8.6 #else 8.7 - oop obj = (oop) at(interpreter_frame_oop_temp_offset); 8.8 + oop obj = cast_to_oop(at(interpreter_frame_oop_temp_offset)); 8.9 assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check"); 8.10 *oop_result = obj; 8.11 #endif // CC_INTERP 8.12 @@ -788,7 +788,7 @@ 8.13 switch(type) { 8.14 case T_OBJECT: 8.15 case T_ARRAY: { 8.16 - oop obj = (oop)*tos_addr; 8.17 + oop obj = cast_to_oop(*tos_addr); 8.18 assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check"); 8.19 *oop_result = obj; 8.20 break;
9.1 --- a/src/cpu/sparc/vm/nativeInst_sparc.cpp Wed Oct 09 13:00:20 2013 +0200 9.2 +++ b/src/cpu/sparc/vm/nativeInst_sparc.cpp Wed Oct 09 05:03:34 2013 -0700 9.3 @@ -1,5 +1,5 @@ 9.4 /* 9.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 9.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 9.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.8 * 9.9 * This code is free software; you can redistribute it and/or modify it 9.10 @@ -358,7 +358,7 @@ 9.11 oop_Relocation *r = iter.oop_reloc(); 9.12 if (oop_addr == NULL) { 9.13 oop_addr = r->oop_addr(); 9.14 - *oop_addr = (oop)x; 9.15 + *oop_addr = cast_to_oop(x); 9.16 } else { 9.17 assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); 9.18 } 9.19 @@ -478,7 +478,7 @@ 9.20 oop_Relocation *r = iter.oop_reloc(); 9.21 if (oop_addr == NULL) { 9.22 oop_addr = r->oop_addr(); 9.23 - *oop_addr = (oop)x; 9.24 + *oop_addr = cast_to_oop(x); 9.25 } else { 9.26 assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); 9.27 }
10.1 --- a/src/cpu/x86/vm/frame_x86.cpp Wed Oct 09 13:00:20 2013 +0200 10.2 +++ b/src/cpu/x86/vm/frame_x86.cpp Wed Oct 09 05:03:34 2013 -0700 10.3 @@ -639,7 +639,7 @@ 10.4 #ifdef CC_INTERP 10.5 obj = istate->_oop_temp; 10.6 #else 10.7 - obj = (oop) at(interpreter_frame_oop_temp_offset); 10.8 + obj = cast_to_oop(at(interpreter_frame_oop_temp_offset)); 10.9 #endif // CC_INTERP 10.10 } else { 10.11 oop* obj_p = (oop*)tos_addr;
11.1 --- a/src/cpu/x86/vm/methodHandles_x86.cpp Wed Oct 09 13:00:20 2013 +0200 11.2 +++ b/src/cpu/x86/vm/methodHandles_x86.cpp Wed Oct 09 05:03:34 2013 -0700 11.3 @@ -483,7 +483,7 @@ 11.4 const char* mh_reg_name = has_mh ? "rcx_mh" : "rcx"; 11.5 tty->print_cr("MH %s %s="PTR_FORMAT" sp="PTR_FORMAT, 11.6 adaptername, mh_reg_name, 11.7 - mh, entry_sp); 11.8 + (void *)mh, entry_sp); 11.9 11.10 if (Verbose) { 11.11 tty->print_cr("Registers:");
12.1 --- a/src/cpu/x86/vm/x86_32.ad Wed Oct 09 13:00:20 2013 +0200 12.2 +++ b/src/cpu/x86/vm/x86_32.ad Wed Oct 09 05:03:34 2013 -0700 12.3 @@ -351,7 +351,7 @@ 12.4 int format) { 12.5 #ifdef ASSERT 12.6 if (rspec.reloc()->type() == relocInfo::oop_type && d32 != 0 && d32 != (int)Universe::non_oop_word()) { 12.7 - assert(oop(d32)->is_oop() && (ScavengeRootsInCode || !oop(d32)->is_scavengable()), "cannot embed scavengable oops in code"); 12.8 + assert(cast_to_oop(d32)->is_oop() && (ScavengeRootsInCode || !cast_to_oop(d32)->is_scavengable()), "cannot embed scavengable oops in code"); 12.9 } 12.10 #endif 12.11 cbuf.relocate(cbuf.insts_mark(), rspec, format);
13.1 --- a/src/cpu/x86/vm/x86_64.ad Wed Oct 09 13:00:20 2013 +0200 13.2 +++ b/src/cpu/x86/vm/x86_64.ad Wed Oct 09 05:03:34 2013 -0700 13.3 @@ -529,7 +529,7 @@ 13.4 if (rspec.reloc()->type() == relocInfo::oop_type && 13.5 d32 != 0 && d32 != (intptr_t) Universe::non_oop_word()) { 13.6 assert(Universe::heap()->is_in_reserved((address)(intptr_t)d32), "should be real oop"); 13.7 - assert(oop((intptr_t)d32)->is_oop() && (ScavengeRootsInCode || !oop((intptr_t)d32)->is_scavengable()), "cannot embed scavengable oops in code"); 13.8 + assert(cast_to_oop((intptr_t)d32)->is_oop() && (ScavengeRootsInCode || !cast_to_oop((intptr_t)d32)->is_scavengable()), "cannot embed scavengable oops in code"); 13.9 } 13.10 #endif 13.11 cbuf.relocate(cbuf.insts_mark(), rspec, format); 13.12 @@ -556,7 +556,7 @@ 13.13 if (rspec.reloc()->type() == relocInfo::oop_type && 13.14 d64 != 0 && d64 != (int64_t) Universe::non_oop_word()) { 13.15 assert(Universe::heap()->is_in_reserved((address)d64), "should be real oop"); 13.16 - assert(oop(d64)->is_oop() && (ScavengeRootsInCode || !oop(d64)->is_scavengable()), 13.17 + assert(cast_to_oop(d64)->is_oop() && (ScavengeRootsInCode || !cast_to_oop(d64)->is_scavengable()), 13.18 "cannot embed scavengable oops in code"); 13.19 } 13.20 #endif
14.1 --- a/src/os/linux/vm/os_linux.cpp Wed Oct 09 13:00:20 2013 +0200 14.2 +++ b/src/os/linux/vm/os_linux.cpp Wed Oct 09 05:03:34 2013 -0700 14.3 @@ -4839,6 +4839,10 @@ 14.4 14.5 Linux::capture_initial_stack(JavaThread::stack_size_at_create()); 14.6 14.7 +#if defined(IA32) 14.8 + workaround_expand_exec_shield_cs_limit(); 14.9 +#endif 14.10 + 14.11 Linux::libpthread_init(); 14.12 if (PrintMiscellaneous && (Verbose || WizardMode)) { 14.13 tty->print_cr("[HotSpot is running with %s, %s(%s)]\n",
15.1 --- a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Wed Oct 09 13:00:20 2013 +0200 15.2 +++ b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp Wed Oct 09 05:03:34 2013 -0700 15.3 @@ -876,3 +876,46 @@ 15.4 #endif 15.5 } 15.6 #endif 15.7 + 15.8 + 15.9 +/* 15.10 + * IA32 only: execute code at a high address in case buggy NX emulation is present. I.e. avoid CS limit 15.11 + * updates (JDK-8023956). 15.12 + */ 15.13 +void os::workaround_expand_exec_shield_cs_limit() { 15.14 +#if defined(IA32) 15.15 + size_t page_size = os::vm_page_size(); 15.16 + /* 15.17 + * Take the highest VA the OS will give us and exec 15.18 + * 15.19 + * Although using -(pagesz) as mmap hint works on newer kernel as you would 15.20 + * think, older variants affected by this work-around don't (search forward only). 15.21 + * 15.22 + * On the affected distributions, we understand the memory layout to be: 15.23 + * 15.24 + * TASK_LIMIT= 3G, main stack base close to TASK_LIMT. 15.25 + * 15.26 + * A few pages south main stack will do it. 15.27 + * 15.28 + * If we are embedded in an app other than launcher (initial != main stack), 15.29 + * we don't have much control or understanding of the address space, just let it slide. 15.30 + */ 15.31 + char* hint = (char*) (Linux::initial_thread_stack_bottom() - 15.32 + ((StackYellowPages + StackRedPages + 1) * page_size)); 15.33 + char* codebuf = os::reserve_memory(page_size, hint); 15.34 + if ( (codebuf == NULL) || (!os::commit_memory(codebuf, page_size, true)) ) { 15.35 + return; // No matter, we tried, best effort. 15.36 + } 15.37 + if (PrintMiscellaneous && (Verbose || WizardMode)) { 15.38 + tty->print_cr("[CS limit NX emulation work-around, exec code at: %p]", codebuf); 15.39 + } 15.40 + 15.41 + // Some code to exec: the 'ret' instruction 15.42 + codebuf[0] = 0xC3; 15.43 + 15.44 + // Call the code in the codebuf 15.45 + __asm__ volatile("call *%0" : : "r"(codebuf)); 15.46 + 15.47 + // keep the page mapped so CS limit isn't reduced. 15.48 +#endif 15.49 +}
16.1 --- a/src/os_cpu/linux_x86/vm/os_linux_x86.hpp Wed Oct 09 13:00:20 2013 +0200 16.2 +++ b/src/os_cpu/linux_x86/vm/os_linux_x86.hpp Wed Oct 09 05:03:34 2013 -0700 16.3 @@ -36,4 +36,17 @@ 16.4 // Note: Currently only used in 64 bit Windows implementations 16.5 static bool register_code_area(char *low, char *high) { return true; } 16.6 16.7 + /* 16.8 + * Work-around for broken NX emulation using CS limit, Red Hat patch "Exec-Shield" 16.9 + * (IA32 only). 16.10 + * 16.11 + * Map and execute at a high VA to prevent CS lazy updates race with SMP MM 16.12 + * invalidation.Further code generation by the JVM will no longer cause CS limit 16.13 + * updates. 16.14 + * 16.15 + * Affects IA32: RHEL 5 & 6, Ubuntu 10.04 (LTS), 10.10, 11.04, 11.10, 12.04. 16.16 + * @see JDK-8023956 16.17 + */ 16.18 + static void workaround_expand_exec_shield_cs_limit(); 16.19 + 16.20 #endif // OS_CPU_LINUX_X86_VM_OS_LINUX_X86_HPP
17.1 --- a/src/share/vm/c1/c1_LIRGenerator.cpp Wed Oct 09 13:00:20 2013 +0200 17.2 +++ b/src/share/vm/c1/c1_LIRGenerator.cpp Wed Oct 09 05:03:34 2013 -0700 17.3 @@ -3053,7 +3053,11 @@ 17.4 int offset = -1; 17.5 LIR_Opr counter_holder; 17.6 if (level == CompLevel_limited_profile) { 17.7 - address counters_adr = method->ensure_method_counters(); 17.8 + MethodCounters* counters_adr = method->ensure_method_counters(); 17.9 + if (counters_adr == NULL) { 17.10 + bailout("method counters allocation failed"); 17.11 + return; 17.12 + } 17.13 counter_holder = new_pointer_register(); 17.14 __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder); 17.15 offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() :
18.1 --- a/src/share/vm/c1/c1_Runtime1.cpp Wed Oct 09 13:00:20 2013 +0200 18.2 +++ b/src/share/vm/c1/c1_Runtime1.cpp Wed Oct 09 05:03:34 2013 -0700 18.3 @@ -1019,7 +1019,7 @@ 18.4 n_copy->set_data((intx) (load_klass())); 18.5 } else { 18.6 assert(mirror() != NULL, "klass not set"); 18.7 - n_copy->set_data((intx) (mirror())); 18.8 + n_copy->set_data(cast_from_oop<intx>(mirror())); 18.9 } 18.10 18.11 if (TracePatching) { 18.12 @@ -1031,7 +1031,7 @@ 18.13 assert(n_copy->data() == 0 || 18.14 n_copy->data() == (intptr_t)Universe::non_oop_word(), 18.15 "illegal init value"); 18.16 - n_copy->set_data((intx) (appendix())); 18.17 + n_copy->set_data(cast_from_oop<intx>(appendix())); 18.18 18.19 if (TracePatching) { 18.20 Disassembler::decode(copy_buff, copy_buff + *byte_count, tty); 18.21 @@ -1078,14 +1078,17 @@ 18.22 // replace instructions 18.23 // first replace the tail, then the call 18.24 #ifdef ARM 18.25 - if(load_klass_or_mirror_patch_id && !VM_Version::supports_movw()) { 18.26 + if((load_klass_or_mirror_patch_id || 18.27 + stub_id == Runtime1::load_appendix_patching_id) && 18.28 + !VM_Version::supports_movw()) { 18.29 nmethod* nm = CodeCache::find_nmethod(instr_pc); 18.30 address addr = NULL; 18.31 assert(nm != NULL, "invalid nmethod_pc"); 18.32 RelocIterator mds(nm, copy_buff, copy_buff + 1); 18.33 while (mds.next()) { 18.34 if (mds.type() == relocInfo::oop_type) { 18.35 - assert(stub_id == Runtime1::load_mirror_patching_id, "wrong stub id"); 18.36 + assert(stub_id == Runtime1::load_mirror_patching_id || 18.37 + stub_id == Runtime1::load_appendix_patching_id, "wrong stub id"); 18.38 oop_Relocation* r = mds.oop_reloc(); 18.39 addr = (address)r->oop_addr(); 18.40 break;
19.1 --- a/src/share/vm/ci/ciKlass.cpp Wed Oct 09 13:00:20 2013 +0200 19.2 +++ b/src/share/vm/ci/ciKlass.cpp Wed Oct 09 05:03:34 2013 -0700 19.3 @@ -66,7 +66,9 @@ 19.4 // ------------------------------------------------------------------ 19.5 // ciKlass::is_subtype_of 19.6 bool ciKlass::is_subtype_of(ciKlass* that) { 19.7 - assert(is_loaded() && that->is_loaded(), "must be loaded"); 19.8 + assert(this->is_loaded(), err_msg("must be loaded: %s", this->name()->as_quoted_ascii())); 19.9 + assert(that->is_loaded(), err_msg("must be loaded: %s", that->name()->as_quoted_ascii())); 19.10 + 19.11 // Check to see if the klasses are identical. 19.12 if (this == that) { 19.13 return true; 19.14 @@ -83,8 +85,8 @@ 19.15 // ------------------------------------------------------------------ 19.16 // ciKlass::is_subclass_of 19.17 bool ciKlass::is_subclass_of(ciKlass* that) { 19.18 - assert(is_loaded() && that->is_loaded(), "must be loaded"); 19.19 - // Check to see if the klasses are identical. 19.20 + assert(this->is_loaded(), err_msg("must be loaded: %s", this->name()->as_quoted_ascii())); 19.21 + assert(that->is_loaded(), err_msg("must be loaded: %s", that->name()->as_quoted_ascii())); 19.22 19.23 VM_ENTRY_MARK; 19.24 Klass* this_klass = get_Klass();
20.1 --- a/src/share/vm/ci/ciMethod.cpp Wed Oct 09 13:00:20 2013 +0200 20.2 +++ b/src/share/vm/ci/ciMethod.cpp Wed Oct 09 05:03:34 2013 -0700 20.3 @@ -846,7 +846,9 @@ 20.4 // Return true if allocation was successful or no MDO is required. 20.5 bool ciMethod::ensure_method_data(methodHandle h_m) { 20.6 EXCEPTION_CONTEXT; 20.7 - if (is_native() || is_abstract() || h_m()->is_accessor()) return true; 20.8 + if (is_native() || is_abstract() || h_m()->is_accessor()) { 20.9 + return true; 20.10 + } 20.11 if (h_m()->method_data() == NULL) { 20.12 Method::build_interpreter_method_data(h_m, THREAD); 20.13 if (HAS_PENDING_EXCEPTION) { 20.14 @@ -903,22 +905,21 @@ 20.15 // NULL otherwise. 20.16 ciMethodData* ciMethod::method_data_or_null() { 20.17 ciMethodData *md = method_data(); 20.18 - if (md->is_empty()) return NULL; 20.19 + if (md->is_empty()) { 20.20 + return NULL; 20.21 + } 20.22 return md; 20.23 } 20.24 20.25 // ------------------------------------------------------------------ 20.26 // ciMethod::ensure_method_counters 20.27 // 20.28 -address ciMethod::ensure_method_counters() { 20.29 +MethodCounters* ciMethod::ensure_method_counters() { 20.30 check_is_loaded(); 20.31 VM_ENTRY_MARK; 20.32 methodHandle mh(THREAD, get_Method()); 20.33 - MethodCounters *counter = mh->method_counters(); 20.34 - if (counter == NULL) { 20.35 - counter = Method::build_method_counters(mh(), CHECK_AND_CLEAR_NULL); 20.36 - } 20.37 - return (address)counter; 20.38 + MethodCounters* method_counters = mh->get_method_counters(CHECK_NULL); 20.39 + return method_counters; 20.40 } 20.41 20.42 // ------------------------------------------------------------------
21.1 --- a/src/share/vm/ci/ciMethod.hpp Wed Oct 09 13:00:20 2013 +0200 21.2 +++ b/src/share/vm/ci/ciMethod.hpp Wed Oct 09 05:03:34 2013 -0700 21.3 @@ -265,7 +265,7 @@ 21.4 bool is_klass_loaded(int refinfo_index, bool must_be_resolved) const; 21.5 bool check_call(int refinfo_index, bool is_static) const; 21.6 bool ensure_method_data(); // make sure it exists in the VM also 21.7 - address ensure_method_counters(); 21.8 + MethodCounters* ensure_method_counters(); 21.9 int instructions_size(); 21.10 int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC 21.11
22.1 --- a/src/share/vm/ci/ciMethodData.cpp Wed Oct 09 13:00:20 2013 +0200 22.2 +++ b/src/share/vm/ci/ciMethodData.cpp Wed Oct 09 05:03:34 2013 -0700 22.3 @@ -78,7 +78,9 @@ 22.4 22.5 void ciMethodData::load_data() { 22.6 MethodData* mdo = get_MethodData(); 22.7 - if (mdo == NULL) return; 22.8 + if (mdo == NULL) { 22.9 + return; 22.10 + } 22.11 22.12 // To do: don't copy the data if it is not "ripe" -- require a minimum # 22.13 // of invocations.
23.1 --- a/src/share/vm/ci/ciMethodData.hpp Wed Oct 09 13:00:20 2013 +0200 23.2 +++ b/src/share/vm/ci/ciMethodData.hpp Wed Oct 09 05:03:34 2013 -0700 23.3 @@ -232,8 +232,6 @@ 23.4 public: 23.5 bool is_method_data() const { return true; } 23.6 23.7 - void set_mature() { _state = mature_state; } 23.8 - 23.9 bool is_empty() { return _state == empty_state; } 23.10 bool is_mature() { return _state == mature_state; } 23.11
24.1 --- a/src/share/vm/ci/ciReplay.cpp Wed Oct 09 13:00:20 2013 +0200 24.2 +++ b/src/share/vm/ci/ciReplay.cpp Wed Oct 09 05:03:34 2013 -0700 24.3 @@ -965,14 +965,12 @@ 24.4 tty->cr(); 24.5 } else { 24.6 EXCEPTION_CONTEXT; 24.7 - MethodCounters* mcs = method->method_counters(); 24.8 // m->_instructions_size = rec->instructions_size; 24.9 m->_instructions_size = -1; 24.10 m->_interpreter_invocation_count = rec->interpreter_invocation_count; 24.11 m->_interpreter_throwout_count = rec->interpreter_throwout_count; 24.12 - if (mcs == NULL) { 24.13 - mcs = Method::build_method_counters(method, CHECK_AND_CLEAR); 24.14 - } 24.15 + MethodCounters* mcs = method->get_method_counters(CHECK_AND_CLEAR); 24.16 + guarantee(mcs != NULL, "method counters allocation failed"); 24.17 mcs->invocation_counter()->_counter = rec->invocation_counter; 24.18 mcs->backedge_counter()->_counter = rec->backedge_counter; 24.19 }
25.1 --- a/src/share/vm/classfile/classFileParser.cpp Wed Oct 09 13:00:20 2013 +0200 25.2 +++ b/src/share/vm/classfile/classFileParser.cpp Wed Oct 09 05:03:34 2013 -0700 25.3 @@ -2545,7 +2545,9 @@ 25.4 if (method->is_final()) { 25.5 *has_final_method = true; 25.6 } 25.7 - if (is_interface && !method->is_abstract() && !method->is_static()) { 25.8 + if (is_interface && !(*has_default_methods) 25.9 + && !method->is_abstract() && !method->is_static() 25.10 + && !method->is_private()) { 25.11 // default method 25.12 *has_default_methods = true; 25.13 }
26.1 --- a/src/share/vm/classfile/classLoaderData.cpp Wed Oct 09 13:00:20 2013 +0200 26.2 +++ b/src/share/vm/classfile/classLoaderData.cpp Wed Oct 09 05:03:34 2013 -0700 26.3 @@ -261,7 +261,7 @@ 26.4 k, 26.5 k->external_name(), 26.6 k->class_loader_data(), 26.7 - k->class_loader(), 26.8 + (void *)k->class_loader(), 26.9 loader_name()); 26.10 } 26.11 } 26.12 @@ -297,7 +297,7 @@ 26.13 if (TraceClassLoaderData) { 26.14 ResourceMark rm; 26.15 tty->print("[ClassLoaderData: unload loader data "PTR_FORMAT, this); 26.16 - tty->print(" for instance "PTR_FORMAT" of %s", class_loader(), 26.17 + tty->print(" for instance "PTR_FORMAT" of %s", (void *)class_loader(), 26.18 loader_name()); 26.19 if (is_anonymous()) { 26.20 tty->print(" for anonymous class "PTR_FORMAT " ", _klasses); 26.21 @@ -458,7 +458,7 @@ 26.22 void ClassLoaderData::dump(outputStream * const out) { 26.23 ResourceMark rm; 26.24 out->print("ClassLoaderData CLD: "PTR_FORMAT", loader: "PTR_FORMAT", loader_klass: "PTR_FORMAT" %s {", 26.25 - this, class_loader(), 26.26 + this, (void *)class_loader(), 26.27 class_loader() != NULL ? class_loader()->klass() : NULL, loader_name()); 26.28 if (claimed()) out->print(" claimed "); 26.29 if (is_unloading()) out->print(" unloading "); 26.30 @@ -553,7 +553,7 @@ 26.31 ResourceMark rm; 26.32 tty->print("[ClassLoaderData: "); 26.33 tty->print("create class loader data "PTR_FORMAT, cld); 26.34 - tty->print(" for instance "PTR_FORMAT" of %s", cld->class_loader(), 26.35 + tty->print(" for instance "PTR_FORMAT" of %s", (void *)cld->class_loader(), 26.36 cld->loader_name()); 26.37 tty->print_cr("]"); 26.38 }
27.1 --- a/src/share/vm/classfile/defaultMethods.cpp Wed Oct 09 13:00:20 2013 +0200 27.2 +++ b/src/share/vm/classfile/defaultMethods.cpp Wed Oct 09 05:03:34 2013 -0700 27.3 @@ -325,6 +325,7 @@ 27.4 27.5 Method* _selected_target; // Filled in later, if a unique target exists 27.6 Symbol* _exception_message; // If no unique target is found 27.7 + Symbol* _exception_name; // If no unique target is found 27.8 27.9 bool contains_method(Method* method) { 27.10 int* lookup = _member_index.get(method); 27.11 @@ -350,7 +351,7 @@ 27.12 public: 27.13 27.14 MethodFamily() 27.15 - : _selected_target(NULL), _exception_message(NULL) {} 27.16 + : _selected_target(NULL), _exception_message(NULL), _exception_name(NULL) {} 27.17 27.18 void set_target_if_empty(Method* m) { 27.19 if (_selected_target == NULL && !m->is_overpass()) { 27.20 @@ -383,6 +384,7 @@ 27.21 27.22 Method* get_selected_target() { return _selected_target; } 27.23 Symbol* get_exception_message() { return _exception_message; } 27.24 + Symbol* get_exception_name() { return _exception_name; } 27.25 27.26 // Either sets the target or the exception error message 27.27 void determine_target(InstanceKlass* root, TRAPS) { 27.28 @@ -400,15 +402,18 @@ 27.29 27.30 if (qualified_methods.length() == 0) { 27.31 _exception_message = generate_no_defaults_message(CHECK); 27.32 + _exception_name = vmSymbols::java_lang_AbstractMethodError(); 27.33 } else if (qualified_methods.length() == 1) { 27.34 Method* method = qualified_methods.at(0); 27.35 if (method->is_abstract()) { 27.36 _exception_message = generate_abstract_method_message(method, CHECK); 27.37 + _exception_name = vmSymbols::java_lang_AbstractMethodError(); 27.38 } else { 27.39 _selected_target = qualified_methods.at(0); 27.40 } 27.41 } else { 27.42 _exception_message = generate_conflicts_message(&qualified_methods,CHECK); 27.43 + _exception_name = vmSymbols::java_lang_IncompatibleClassChangeError(); 27.44 } 27.45 27.46 assert((has_target() ^ throws_exception()) == 1, 27.47 @@ -459,8 +464,9 @@ 27.48 27.49 void print_exception(outputStream* str, int indent) { 27.50 assert(throws_exception(), "Should be called otherwise"); 27.51 + assert(_exception_name != NULL, "exception_name should be set"); 27.52 streamIndentor si(str, indent * 2); 27.53 - str->indent().print_cr("%s", _exception_message->as_C_string()); 27.54 + str->indent().print_cr("%s: %s", _exception_name->as_C_string(), _exception_message->as_C_string()); 27.55 } 27.56 #endif // ndef PRODUCT 27.57 }; 27.58 @@ -670,7 +676,10 @@ 27.59 InstanceKlass* iklass = current_class(); 27.60 27.61 Method* m = iklass->find_method(_method_name, _method_signature); 27.62 - if (m != NULL) { 27.63 + // private interface methods are not candidates for default methods 27.64 + // invokespecial to private interface methods doesn't use default method logic 27.65 + // future: take access controls into account for superclass methods 27.66 + if (m != NULL && (!iklass->is_interface() || m->is_public())) { 27.67 if (_family == NULL) { 27.68 _family = new StatefulMethodFamily(); 27.69 } 27.70 @@ -782,200 +791,7 @@ 27.71 #endif // ndef PRODUCT 27.72 } 27.73 27.74 -/** 27.75 - * Interface inheritance rules were used to find a unique default method 27.76 - * candidate for the resolved class. This 27.77 - * method is only viable if it would also be in the set of default method 27.78 - * candidates if we ran a full analysis on the current class. 27.79 - * 27.80 - * The only reason that the method would not be in the set of candidates for 27.81 - * the current class is if that there's another matching method 27.82 - * which is "more specific" than the found method -- i.e., one could find a 27.83 - * path in the interface hierarchy in which the matching method appears 27.84 - * before we get to '_target'. 27.85 - * 27.86 - * In order to determine this, we examine all of the implemented 27.87 - * interfaces. If we find path that leads to the '_target' interface, then 27.88 - * we examine that path to see if there are any methods that would shadow 27.89 - * the selected method along that path. 27.90 - */ 27.91 -class ShadowChecker : public HierarchyVisitor<ShadowChecker> { 27.92 - protected: 27.93 - Thread* THREAD; 27.94 27.95 - InstanceKlass* _target; 27.96 - 27.97 - Symbol* _method_name; 27.98 - InstanceKlass* _method_holder; 27.99 - bool _found_shadow; 27.100 - 27.101 - 27.102 - public: 27.103 - 27.104 - ShadowChecker(Thread* thread, Symbol* name, InstanceKlass* holder, 27.105 - InstanceKlass* target) 27.106 - : THREAD(thread), _method_name(name), _method_holder(holder), 27.107 - _target(target), _found_shadow(false) {} 27.108 - 27.109 - void* new_node_data(InstanceKlass* cls) { return NULL; } 27.110 - void free_node_data(void* data) { return; } 27.111 - 27.112 - bool visit() { 27.113 - InstanceKlass* ik = current_class(); 27.114 - if (ik == _target && current_depth() == 1) { 27.115 - return false; // This was the specified super -- no need to search it 27.116 - } 27.117 - if (ik == _method_holder || ik == _target) { 27.118 - // We found a path that should be examined to see if it shadows _method 27.119 - if (path_has_shadow()) { 27.120 - _found_shadow = true; 27.121 - cancel_iteration(); 27.122 - } 27.123 - return false; // no need to continue up hierarchy 27.124 - } 27.125 - return true; 27.126 - } 27.127 - 27.128 - virtual bool path_has_shadow() = 0; 27.129 - bool found_shadow() { return _found_shadow; } 27.130 -}; 27.131 - 27.132 -// Used for Invokespecial. 27.133 -// Invokespecial is allowed to invoke a concrete interface method 27.134 -// and can be used to disambuiguate among qualified candidates, 27.135 -// which are methods in immediate superinterfaces, 27.136 -// but may not be used to invoke a candidate that would be shadowed 27.137 -// from the perspective of the caller. 27.138 -// Invokespecial is also used in the overpass generation today 27.139 -// We re-run the shadowchecker because we can't distinguish this case, 27.140 -// but it should return the same answer, since the overpass target 27.141 -// is now the invokespecial caller. 27.142 -class ErasedShadowChecker : public ShadowChecker { 27.143 - private: 27.144 - bool path_has_shadow() { 27.145 - 27.146 - for (int i = current_depth() - 1; i > 0; --i) { 27.147 - InstanceKlass* ik = class_at_depth(i); 27.148 - 27.149 - if (ik->is_interface()) { 27.150 - int end; 27.151 - int start = ik->find_method_by_name(_method_name, &end); 27.152 - if (start != -1) { 27.153 - return true; 27.154 - } 27.155 - } 27.156 - } 27.157 - return false; 27.158 - } 27.159 - public: 27.160 - 27.161 - ErasedShadowChecker(Thread* thread, Symbol* name, InstanceKlass* holder, 27.162 - InstanceKlass* target) 27.163 - : ShadowChecker(thread, name, holder, target) {} 27.164 -}; 27.165 - 27.166 -// Find the unique qualified candidate from the perspective of the super_class 27.167 -// which is the resolved_klass, which must be an immediate superinterface 27.168 -// of klass 27.169 -Method* find_erased_super_default(InstanceKlass* current_class, InstanceKlass* super_class, Symbol* method_name, Symbol* sig, TRAPS) { 27.170 - 27.171 - FindMethodsByErasedSig visitor(method_name, sig); 27.172 - visitor.run(super_class); // find candidates from resolved_klass 27.173 - 27.174 - MethodFamily* family; 27.175 - visitor.get_discovered_family(&family); 27.176 - 27.177 - if (family != NULL) { 27.178 - family->determine_target(current_class, CHECK_NULL); // get target from current_class 27.179 - 27.180 - if (family->has_target()) { 27.181 - Method* target = family->get_selected_target(); 27.182 - InstanceKlass* holder = InstanceKlass::cast(target->method_holder()); 27.183 - 27.184 - // Verify that the identified method is valid from the context of 27.185 - // the current class, which is the caller class for invokespecial 27.186 - // link resolution, i.e. ensure there it is not shadowed. 27.187 - // You can use invokespecial to disambiguate interface methods, but 27.188 - // you can not use it to skip over an interface method that would shadow it. 27.189 - ErasedShadowChecker checker(THREAD, target->name(), holder, super_class); 27.190 - checker.run(current_class); 27.191 - 27.192 - if (checker.found_shadow()) { 27.193 -#ifndef PRODUCT 27.194 - if (TraceDefaultMethods) { 27.195 - tty->print_cr(" Only candidate found was shadowed."); 27.196 - } 27.197 -#endif // ndef PRODUCT 27.198 - THROW_MSG_(vmSymbols::java_lang_AbstractMethodError(), 27.199 - "Accessible default method not found", NULL); 27.200 - } else { 27.201 -#ifndef PRODUCT 27.202 - if (TraceDefaultMethods) { 27.203 - family->print_sig_on(tty, target->signature(), 1); 27.204 - } 27.205 -#endif // ndef PRODUCT 27.206 - return target; 27.207 - } 27.208 - } else { 27.209 - assert(family->throws_exception(), "must have target or throw"); 27.210 - THROW_MSG_(vmSymbols::java_lang_AbstractMethodError(), 27.211 - family->get_exception_message()->as_C_string(), NULL); 27.212 - } 27.213 - } else { 27.214 - // no method found 27.215 - ResourceMark rm(THREAD); 27.216 - THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), 27.217 - Method::name_and_sig_as_C_string(current_class, 27.218 - method_name, sig), NULL); 27.219 - } 27.220 -} 27.221 -// This is called during linktime when we find an invokespecial call that 27.222 -// refers to a direct superinterface. It indicates that we should find the 27.223 -// default method in the hierarchy of that superinterface, and if that method 27.224 -// would have been a candidate from the point of view of 'this' class, then we 27.225 -// return that method. 27.226 -// This logic assumes that the super is a direct superclass of the caller 27.227 -Method* DefaultMethods::find_super_default( 27.228 - Klass* cls, Klass* super, Symbol* method_name, Symbol* sig, TRAPS) { 27.229 - 27.230 - ResourceMark rm(THREAD); 27.231 - 27.232 - assert(cls != NULL && super != NULL, "Need real classes"); 27.233 - 27.234 - InstanceKlass* current_class = InstanceKlass::cast(cls); 27.235 - InstanceKlass* super_class = InstanceKlass::cast(super); 27.236 - 27.237 - // Keep entire hierarchy alive for the duration of the computation 27.238 - KeepAliveRegistrar keepAlive(THREAD); 27.239 - KeepAliveVisitor loadKeepAlive(&keepAlive); 27.240 - loadKeepAlive.run(current_class); // get hierarchy from current class 27.241 - 27.242 -#ifndef PRODUCT 27.243 - if (TraceDefaultMethods) { 27.244 - tty->print_cr("Finding super default method %s.%s%s from %s", 27.245 - super_class->name()->as_C_string(), 27.246 - method_name->as_C_string(), sig->as_C_string(), 27.247 - current_class->name()->as_C_string()); 27.248 - } 27.249 -#endif // ndef PRODUCT 27.250 - 27.251 - assert(super_class->is_interface(), "only call for default methods"); 27.252 - 27.253 - Method* target = NULL; 27.254 - target = find_erased_super_default(current_class, super_class, 27.255 - method_name, sig, CHECK_NULL); 27.256 - 27.257 -#ifndef PRODUCT 27.258 - if (target != NULL) { 27.259 - if (TraceDefaultMethods) { 27.260 - tty->print(" Returning "); 27.261 - print_method(tty, target, true); 27.262 - tty->print_cr(""); 27.263 - } 27.264 - } 27.265 -#endif // ndef PRODUCT 27.266 - return target; 27.267 -} 27.268 27.269 #ifdef ASSERT 27.270 // Return true is broad type is a covariant return of narrow type 27.271 @@ -1035,10 +851,9 @@ 27.272 return parameter_count; 27.273 } 27.274 27.275 -static int assemble_abstract_method_error( 27.276 - BytecodeConstantPool* cp, BytecodeBuffer* buffer, Symbol* message, TRAPS) { 27.277 +static int assemble_method_error( 27.278 + BytecodeConstantPool* cp, BytecodeBuffer* buffer, Symbol* errorName, Symbol* message, TRAPS) { 27.279 27.280 - Symbol* errorName = vmSymbols::java_lang_AbstractMethodError(); 27.281 Symbol* init = vmSymbols::object_initializer_name(); 27.282 Symbol* sig = vmSymbols::string_void_signature(); 27.283 27.284 @@ -1149,8 +964,7 @@ 27.285 &bpool, &buffer, slot->signature(), selected, CHECK); 27.286 } 27.287 } else if (method->throws_exception()) { 27.288 - max_stack = assemble_abstract_method_error( 27.289 - &bpool, &buffer, method->get_exception_message(), CHECK); 27.290 + max_stack = assemble_method_error(&bpool, &buffer, method->get_exception_name(), method->get_exception_message(), CHECK); 27.291 } 27.292 if (max_stack != 0) { 27.293 AccessFlags flags = accessFlags_from(
28.1 --- a/src/share/vm/classfile/defaultMethods.hpp Wed Oct 09 13:00:20 2013 +0200 28.2 +++ b/src/share/vm/classfile/defaultMethods.hpp Wed Oct 09 05:03:34 2013 -0700 28.3 @@ -1,5 +1,5 @@ 28.4 /* 28.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 28.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 28.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 28.8 * 28.9 * This code is free software; you can redistribute it and/or modify it 28.10 @@ -44,15 +44,5 @@ 28.11 // the class. 28.12 static void generate_default_methods( 28.13 InstanceKlass* klass, GrowableArray<Method*>* mirandas, TRAPS); 28.14 - 28.15 - 28.16 - // Called during linking when an invokespecial to an direct interface 28.17 - // method is found. Selects and returns a method if there is a unique 28.18 - // default method in the 'super_iface' part of the hierarchy which is 28.19 - // also a candidate default for 'this_klass'. Otherwise throws an AME. 28.20 - static Method* find_super_default( 28.21 - Klass* this_klass, Klass* super_iface, 28.22 - Symbol* method_name, Symbol* method_sig, TRAPS); 28.23 }; 28.24 - 28.25 #endif // SHARE_VM_CLASSFILE_DEFAULTMETHODS_HPP
29.1 --- a/src/share/vm/classfile/dictionary.hpp Wed Oct 09 13:00:20 2013 +0200 29.2 +++ b/src/share/vm/classfile/dictionary.hpp Wed Oct 09 05:03:34 2013 -0700 29.3 @@ -1,5 +1,5 @@ 29.4 /* 29.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 29.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 29.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.8 * 29.9 * This code is free software; you can redistribute it and/or modify it 29.10 @@ -264,7 +264,7 @@ 29.11 } 29.12 if (method_type() != NULL) { 29.13 if (printed) st->print(" and "); 29.14 - st->print(INTPTR_FORMAT, method_type()); 29.15 + st->print(INTPTR_FORMAT, (void *)method_type()); 29.16 printed = true; 29.17 } 29.18 st->print_cr(printed ? "" : "(empty)");
30.1 --- a/src/share/vm/classfile/symbolTable.cpp Wed Oct 09 13:00:20 2013 +0200 30.2 +++ b/src/share/vm/classfile/symbolTable.cpp Wed Oct 09 05:03:34 2013 -0700 30.3 @@ -341,7 +341,7 @@ 30.4 30.5 Symbol* SymbolTable::basic_add(int index_arg, u1 *name, int len, 30.6 unsigned int hashValue_arg, bool c_heap, TRAPS) { 30.7 - assert(!Universe::heap()->is_in_reserved(name) || GC_locker::is_active(), 30.8 + assert(!Universe::heap()->is_in_reserved(name), 30.9 "proposed name of symbol must be stable"); 30.10 30.11 // Don't allow symbols to be created which cannot fit in a Symbol*. 30.12 @@ -685,7 +685,7 @@ 30.13 if (found_string != NULL) return found_string; 30.14 30.15 debug_only(StableMemoryChecker smc(name, len * sizeof(name[0]))); 30.16 - assert(!Universe::heap()->is_in_reserved(name) || GC_locker::is_active(), 30.17 + assert(!Universe::heap()->is_in_reserved(name), 30.18 "proposed name of symbol must be stable"); 30.19 30.20 Handle string; 30.21 @@ -840,7 +840,7 @@ 30.22 if (str1 == str2) { 30.23 tty->print_cr("ERROR: identical oop values (0x" PTR_FORMAT ") " 30.24 "in entry @ bucket[%d][%d] and entry @ bucket[%d][%d]", 30.25 - str1, bkt1, e_cnt1, bkt2, e_cnt2); 30.26 + (void *)str1, bkt1, e_cnt1, bkt2, e_cnt2); 30.27 return _verify_fail_continue; 30.28 } 30.29
31.1 --- a/src/share/vm/code/nmethod.cpp Wed Oct 09 13:00:20 2013 +0200 31.2 +++ b/src/share/vm/code/nmethod.cpp Wed Oct 09 05:03:34 2013 -0700 31.3 @@ -1966,7 +1966,7 @@ 31.4 if (!_detected_scavenge_root) _print_nm->print_on(tty, "new scavenge root"); 31.5 tty->print_cr(""PTR_FORMAT"[offset=%d] detected scavengable oop "PTR_FORMAT" (found at "PTR_FORMAT")", 31.6 _print_nm, (int)((intptr_t)p - (intptr_t)_print_nm), 31.7 - (intptr_t)(*p), (intptr_t)p); 31.8 + (void *)(*p), (intptr_t)p); 31.9 (*p)->print(); 31.10 } 31.11 #endif //PRODUCT 31.12 @@ -2346,7 +2346,7 @@ 31.13 _ok = false; 31.14 } 31.15 tty->print_cr("*** non-oop "PTR_FORMAT" found at "PTR_FORMAT" (offset %d)", 31.16 - (intptr_t)(*p), (intptr_t)p, (int)((intptr_t)p - (intptr_t)_nm)); 31.17 + (void *)(*p), (intptr_t)p, (int)((intptr_t)p - (intptr_t)_nm)); 31.18 } 31.19 virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); } 31.20 }; 31.21 @@ -2467,7 +2467,7 @@ 31.22 _ok = false; 31.23 } 31.24 tty->print_cr("*** scavengable oop "PTR_FORMAT" found at "PTR_FORMAT" (offset %d)", 31.25 - (intptr_t)(*p), (intptr_t)p, (int)((intptr_t)p - (intptr_t)_nm)); 31.26 + (void *)(*p), (intptr_t)p, (int)((intptr_t)p - (intptr_t)_nm)); 31.27 (*p)->print(); 31.28 } 31.29 virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
32.1 --- a/src/share/vm/compiler/oopMap.cpp Wed Oct 09 13:00:20 2013 +0200 32.2 +++ b/src/share/vm/compiler/oopMap.cpp Wed Oct 09 05:03:34 2013 -0700 32.3 @@ -1,5 +1,5 @@ 32.4 /* 32.5 - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 32.6 + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. 32.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 32.8 * 32.9 * This code is free software; you can redistribute it and/or modify it 32.10 @@ -628,7 +628,7 @@ 32.11 32.12 32.13 // Returns value of location as an int 32.14 -intptr_t value_of_loc(oop *pointer) { return (intptr_t)(*pointer); } 32.15 +intptr_t value_of_loc(oop *pointer) { return cast_from_oop<intptr_t>((*pointer)); } 32.16 32.17 32.18 void DerivedPointerTable::add(oop *derived_loc, oop *base_loc) {
33.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Wed Oct 09 13:00:20 2013 +0200 33.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Wed Oct 09 05:03:34 2013 -0700 33.3 @@ -9065,7 +9065,7 @@ 33.4 return !stack->isEmpty(); 33.5 } 33.6 33.7 -#define BUSY (oop(0x1aff1aff)) 33.8 +#define BUSY (cast_to_oop<intptr_t>(0x1aff1aff)) 33.9 // (MT-safe) Get a prefix of at most "num" from the list. 33.10 // The overflow list is chained through the mark word of 33.11 // each object in the list. We fetch the entire list, 33.12 @@ -9098,7 +9098,7 @@ 33.13 return false; 33.14 } 33.15 // Grab the entire list; we'll put back a suffix 33.16 - oop prefix = (oop)Atomic::xchg_ptr(BUSY, &_overflow_list); 33.17 + oop prefix = cast_to_oop(Atomic::xchg_ptr(BUSY, &_overflow_list)); 33.18 Thread* tid = Thread::current(); 33.19 // Before "no_of_gc_threads" was introduced CMSOverflowSpinCount was 33.20 // set to ParallelGCThreads. 33.21 @@ -9113,7 +9113,7 @@ 33.22 return false; 33.23 } else if (_overflow_list != BUSY) { 33.24 // Try and grab the prefix 33.25 - prefix = (oop)Atomic::xchg_ptr(BUSY, &_overflow_list); 33.26 + prefix = cast_to_oop(Atomic::xchg_ptr(BUSY, &_overflow_list)); 33.27 } 33.28 } 33.29 // If the list was found to be empty, or we spun long
34.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp Wed Oct 09 13:00:20 2013 +0200 34.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp Wed Oct 09 05:03:34 2013 -0700 34.3 @@ -2694,7 +2694,7 @@ 34.4 34.5 if (print_it) { 34.6 _out->print_cr(" "PTR_FORMAT"%s", 34.7 - o, (over_tams) ? " >" : (marked) ? " M" : ""); 34.8 + (void *)o, (over_tams) ? " >" : (marked) ? " M" : ""); 34.9 PrintReachableOopClosure oopCl(_out, _vo, _all); 34.10 o->oop_iterate_no_header(&oopCl); 34.11 }
35.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp Wed Oct 09 13:00:20 2013 +0200 35.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp Wed Oct 09 05:03:34 2013 -0700 35.3 @@ -81,7 +81,7 @@ 35.4 size_t* marked_bytes_array, 35.5 BitMap* task_card_bm) { 35.6 G1CollectedHeap* g1h = _g1h; 35.7 - CardTableModRefBS* ct_bs = (CardTableModRefBS*) (g1h->barrier_set()); 35.8 + CardTableModRefBS* ct_bs = g1h->g1_barrier_set(); 35.9 35.10 HeapWord* start = mr.start(); 35.11 HeapWord* end = mr.end();
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 36.2 +++ b/src/share/vm/gc_implementation/g1/g1BiasedArray.cpp Wed Oct 09 05:03:34 2013 -0700 36.3 @@ -0,0 +1,141 @@ 36.4 +/* 36.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 36.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 36.7 + * 36.8 + * This code is free software; you can redistribute it and/or modify it 36.9 + * under the terms of the GNU General Public License version 2 only, as 36.10 + * published by the Free Software Foundation. 36.11 + * 36.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 36.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 36.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 36.15 + * version 2 for more details (a copy is included in the LICENSE file that 36.16 + * accompanied this code). 36.17 + * 36.18 + * You should have received a copy of the GNU General Public License version 36.19 + * 2 along with this work; if not, write to the Free Software Foundation, 36.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 36.21 + * 36.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 36.23 + * or visit www.oracle.com if you need additional information or have any 36.24 + * questions. 36.25 + * 36.26 + */ 36.27 + 36.28 +#include "precompiled.hpp" 36.29 +#include "gc_implementation/g1/g1BiasedArray.hpp" 36.30 + 36.31 +#ifndef PRODUCT 36.32 +void G1BiasedMappedArrayBase::verify_index(idx_t index) const { 36.33 + guarantee(_base != NULL, "Array not initialized"); 36.34 + guarantee(index < length(), err_msg("Index out of bounds index: "SIZE_FORMAT" length: "SIZE_FORMAT, index, length())); 36.35 +} 36.36 + 36.37 +void G1BiasedMappedArrayBase::verify_biased_index(idx_t biased_index) const { 36.38 + guarantee(_biased_base != NULL, "Array not initialized"); 36.39 + guarantee(biased_index >= bias() && biased_index < (bias() + length()), 36.40 + err_msg("Biased index out of bounds, index: "SIZE_FORMAT" bias: "SIZE_FORMAT" length: "SIZE_FORMAT, biased_index, bias(), length())); 36.41 +} 36.42 + 36.43 +void G1BiasedMappedArrayBase::verify_biased_index_inclusive_end(idx_t biased_index) const { 36.44 + guarantee(_biased_base != NULL, "Array not initialized"); 36.45 + guarantee(biased_index >= bias() && biased_index <= (bias() + length()), 36.46 + err_msg("Biased index out of inclusive bounds, index: "SIZE_FORMAT" bias: "SIZE_FORMAT" length: "SIZE_FORMAT, biased_index, bias(), length())); 36.47 +} 36.48 + 36.49 +class TestMappedArray : public G1BiasedMappedArray<int> { 36.50 +protected: 36.51 + virtual int default_value() const { return 0xBAADBABE; } 36.52 +public: 36.53 + static void test_biasedarray() { 36.54 + const size_t REGION_SIZE_IN_WORDS = 512; 36.55 + const size_t NUM_REGIONS = 20; 36.56 + HeapWord* fake_heap = (HeapWord*)LP64_ONLY(0xBAAA00000) NOT_LP64(0xBA000000); // Any value that is non-zero 36.57 + 36.58 + TestMappedArray array; 36.59 + array.initialize(fake_heap, fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS, 36.60 + REGION_SIZE_IN_WORDS * HeapWordSize); 36.61 + // Check address calculation (bounds) 36.62 + assert(array.bottom_address_mapped() == fake_heap, 36.63 + err_msg("bottom mapped address should be "PTR_FORMAT", but is "PTR_FORMAT, fake_heap, array.bottom_address_mapped())); 36.64 + assert(array.end_address_mapped() == (fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS), "must be"); 36.65 + 36.66 + int* bottom = array.address_mapped_to(fake_heap); 36.67 + assert((void*)bottom == (void*) array.base(), "must be"); 36.68 + int* end = array.address_mapped_to(fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS); 36.69 + assert((void*)end == (void*)(array.base() + array.length()), "must be"); 36.70 + // The entire array should contain default value elements 36.71 + for (int* current = bottom; current < end; current++) { 36.72 + assert(*current == array.default_value(), "must be"); 36.73 + } 36.74 + 36.75 + // Test setting values in the table 36.76 + 36.77 + HeapWord* region_start_address = fake_heap + REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2); 36.78 + HeapWord* region_end_address = fake_heap + (REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2) + REGION_SIZE_IN_WORDS - 1); 36.79 + 36.80 + // Set/get by address tests: invert some value; first retrieve one 36.81 + int actual_value = array.get_by_index(NUM_REGIONS / 2); 36.82 + array.set_by_index(NUM_REGIONS / 2, ~actual_value); 36.83 + // Get the same value by address, should correspond to the start of the "region" 36.84 + int value = array.get_by_address(region_start_address); 36.85 + assert(value == ~actual_value, "must be"); 36.86 + // Get the same value by address, at one HeapWord before the start 36.87 + value = array.get_by_address(region_start_address - 1); 36.88 + assert(value == array.default_value(), "must be"); 36.89 + // Get the same value by address, at the end of the "region" 36.90 + value = array.get_by_address(region_end_address); 36.91 + assert(value == ~actual_value, "must be"); 36.92 + // Make sure the next value maps to another index 36.93 + value = array.get_by_address(region_end_address + 1); 36.94 + assert(value == array.default_value(), "must be"); 36.95 + 36.96 + // Reset the value in the array 36.97 + array.set_by_address(region_start_address + (region_end_address - region_start_address) / 2, actual_value); 36.98 + 36.99 + // The entire array should have the default value again 36.100 + for (int* current = bottom; current < end; current++) { 36.101 + assert(*current == array.default_value(), "must be"); 36.102 + } 36.103 + 36.104 + // Set/get by index tests: invert some value 36.105 + idx_t index = NUM_REGIONS / 2; 36.106 + actual_value = array.get_by_index(index); 36.107 + array.set_by_index(index, ~actual_value); 36.108 + 36.109 + value = array.get_by_index(index); 36.110 + assert(value == ~actual_value, "must be"); 36.111 + 36.112 + value = array.get_by_index(index - 1); 36.113 + assert(value == array.default_value(), "must be"); 36.114 + 36.115 + value = array.get_by_index(index + 1); 36.116 + assert(value == array.default_value(), "must be"); 36.117 + 36.118 + array.set_by_index(0, 0); 36.119 + value = array.get_by_index(0); 36.120 + assert(value == 0, "must be"); 36.121 + 36.122 + array.set_by_index(array.length() - 1, 0); 36.123 + value = array.get_by_index(array.length() - 1); 36.124 + assert(value == 0, "must be"); 36.125 + 36.126 + array.set_by_index(index, 0); 36.127 + 36.128 + // The array should have three zeros, and default values otherwise 36.129 + size_t num_zeros = 0; 36.130 + for (int* current = bottom; current < end; current++) { 36.131 + assert(*current == array.default_value() || *current == 0, "must be"); 36.132 + if (*current == 0) { 36.133 + num_zeros++; 36.134 + } 36.135 + } 36.136 + assert(num_zeros == 3, "must be"); 36.137 + } 36.138 +}; 36.139 + 36.140 +void TestG1BiasedArray_test() { 36.141 + TestMappedArray::test_biasedarray(); 36.142 +} 36.143 + 36.144 +#endif
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 37.2 +++ b/src/share/vm/gc_implementation/g1/g1BiasedArray.hpp Wed Oct 09 05:03:34 2013 -0700 37.3 @@ -0,0 +1,181 @@ 37.4 +/* 37.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 37.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 37.7 + * 37.8 + * This code is free software; you can redistribute it and/or modify it 37.9 + * under the terms of the GNU General Public License version 2 only, as 37.10 + * published by the Free Software Foundation. 37.11 + * 37.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 37.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 37.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 37.15 + * version 2 for more details (a copy is included in the LICENSE file that 37.16 + * accompanied this code). 37.17 + * 37.18 + * You should have received a copy of the GNU General Public License version 37.19 + * 2 along with this work; if not, write to the Free Software Foundation, 37.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 37.21 + * 37.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 37.23 + * or visit www.oracle.com if you need additional information or have any 37.24 + * questions. 37.25 + * 37.26 + */ 37.27 + 37.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1BIASEDARRAY_HPP 37.29 +#define SHARE_VM_GC_IMPLEMENTATION_G1_G1BIASEDARRAY_HPP 37.30 + 37.31 +#include "utilities/debug.hpp" 37.32 +#include "memory/allocation.inline.hpp" 37.33 + 37.34 +// Implements the common base functionality for arrays that contain provisions 37.35 +// for accessing its elements using a biased index. 37.36 +// The element type is defined by the instantiating the template. 37.37 +class G1BiasedMappedArrayBase VALUE_OBJ_CLASS_SPEC { 37.38 + friend class VMStructs; 37.39 +public: 37.40 + typedef size_t idx_t; 37.41 +protected: 37.42 + address _base; // the real base address 37.43 + size_t _length; // the length of the array 37.44 + address _biased_base; // base address biased by "bias" elements 37.45 + size_t _bias; // the bias, i.e. the offset biased_base is located to the right in elements 37.46 + uint _shift_by; // the amount of bits to shift right when mapping to an index of the array. 37.47 + 37.48 +protected: 37.49 + 37.50 + G1BiasedMappedArrayBase() : _base(NULL), _length(0), _biased_base(NULL), 37.51 + _bias(0), _shift_by(0) { } 37.52 + 37.53 + // Allocate a new array, generic version. 37.54 + static address create_new_base_array(size_t length, size_t elem_size) { 37.55 + assert(length > 0, "just checking"); 37.56 + assert(elem_size > 0, "just checking"); 37.57 + return NEW_C_HEAP_ARRAY(u_char, length * elem_size, mtGC); 37.58 + } 37.59 + 37.60 + // Initialize the members of this class. The biased start address of this array 37.61 + // is the bias (in elements) multiplied by the element size. 37.62 + void initialize_base(address base, size_t length, size_t bias, size_t elem_size, uint shift_by) { 37.63 + assert(base != NULL, "just checking"); 37.64 + assert(length > 0, "just checking"); 37.65 + assert(shift_by < sizeof(uintptr_t) * 8, err_msg("Shifting by %zd, larger than word size?", shift_by)); 37.66 + _base = base; 37.67 + _length = length; 37.68 + _biased_base = base - (bias * elem_size); 37.69 + _bias = bias; 37.70 + _shift_by = shift_by; 37.71 + } 37.72 + 37.73 + // Allocate and initialize this array to cover the heap addresses in the range 37.74 + // of [bottom, end). 37.75 + void initialize(HeapWord* bottom, HeapWord* end, size_t target_elem_size_in_bytes, size_t mapping_granularity_in_bytes) { 37.76 + assert(mapping_granularity_in_bytes > 0, "just checking"); 37.77 + assert(is_power_of_2(mapping_granularity_in_bytes), 37.78 + err_msg("mapping granularity must be power of 2, is %zd", mapping_granularity_in_bytes)); 37.79 + assert((uintptr_t)bottom % mapping_granularity_in_bytes == 0, 37.80 + err_msg("bottom mapping area address must be a multiple of mapping granularity %zd, is "PTR_FORMAT, 37.81 + mapping_granularity_in_bytes, bottom)); 37.82 + assert((uintptr_t)end % mapping_granularity_in_bytes == 0, 37.83 + err_msg("end mapping area address must be a multiple of mapping granularity %zd, is "PTR_FORMAT, 37.84 + mapping_granularity_in_bytes, end)); 37.85 + size_t num_target_elems = (end - bottom) / (mapping_granularity_in_bytes / HeapWordSize); 37.86 + idx_t bias = (uintptr_t)bottom / mapping_granularity_in_bytes; 37.87 + address base = create_new_base_array(num_target_elems, target_elem_size_in_bytes); 37.88 + initialize_base(base, num_target_elems, bias, target_elem_size_in_bytes, log2_intptr(mapping_granularity_in_bytes)); 37.89 + } 37.90 + 37.91 + size_t bias() const { return _bias; } 37.92 + uint shift_by() const { return _shift_by; } 37.93 + 37.94 + void verify_index(idx_t index) const PRODUCT_RETURN; 37.95 + void verify_biased_index(idx_t biased_index) const PRODUCT_RETURN; 37.96 + void verify_biased_index_inclusive_end(idx_t biased_index) const PRODUCT_RETURN; 37.97 + 37.98 +public: 37.99 + // Return the length of the array in elements. 37.100 + size_t length() const { return _length; } 37.101 +}; 37.102 + 37.103 +// Array that provides biased access and mapping from (valid) addresses in the 37.104 +// heap into this array. 37.105 +template<class T> 37.106 +class G1BiasedMappedArray : public G1BiasedMappedArrayBase { 37.107 +public: 37.108 + typedef G1BiasedMappedArrayBase::idx_t idx_t; 37.109 + 37.110 + T* base() const { return (T*)G1BiasedMappedArrayBase::_base; } 37.111 + // Return the element of the given array at the given index. Assume 37.112 + // the index is valid. This is a convenience method that does sanity 37.113 + // checking on the index. 37.114 + T get_by_index(idx_t index) const { 37.115 + verify_index(index); 37.116 + return this->base()[index]; 37.117 + } 37.118 + 37.119 + // Set the element of the given array at the given index to the 37.120 + // given value. Assume the index is valid. This is a convenience 37.121 + // method that does sanity checking on the index. 37.122 + void set_by_index(idx_t index, T value) { 37.123 + verify_index(index); 37.124 + this->base()[index] = value; 37.125 + } 37.126 + 37.127 + // The raw biased base pointer. 37.128 + T* biased_base() const { return (T*)G1BiasedMappedArrayBase::_biased_base; } 37.129 + 37.130 + // Return the element of the given array that covers the given word in the 37.131 + // heap. Assumes the index is valid. 37.132 + T get_by_address(HeapWord* value) const { 37.133 + idx_t biased_index = ((uintptr_t)value) >> this->shift_by(); 37.134 + this->verify_biased_index(biased_index); 37.135 + return biased_base()[biased_index]; 37.136 + } 37.137 + 37.138 + // Set the value of the array entry that corresponds to the given array. 37.139 + void set_by_address(HeapWord * address, T value) { 37.140 + idx_t biased_index = ((uintptr_t)address) >> this->shift_by(); 37.141 + this->verify_biased_index(biased_index); 37.142 + biased_base()[biased_index] = value; 37.143 + } 37.144 + 37.145 +protected: 37.146 + // Returns the address of the element the given address maps to 37.147 + T* address_mapped_to(HeapWord* address) { 37.148 + idx_t biased_index = ((uintptr_t)address) >> this->shift_by(); 37.149 + this->verify_biased_index_inclusive_end(biased_index); 37.150 + return biased_base() + biased_index; 37.151 + } 37.152 + 37.153 +public: 37.154 + // Return the smallest address (inclusive) in the heap that this array covers. 37.155 + HeapWord* bottom_address_mapped() const { 37.156 + return (HeapWord*) ((uintptr_t)this->bias() << this->shift_by()); 37.157 + } 37.158 + 37.159 + // Return the highest address (exclusive) in the heap that this array covers. 37.160 + HeapWord* end_address_mapped() const { 37.161 + return (HeapWord*) ((uintptr_t)(this->bias() + this->length()) << this->shift_by()); 37.162 + } 37.163 + 37.164 +protected: 37.165 + virtual T default_value() const = 0; 37.166 + // Set all elements of the given array to the given value. 37.167 + void clear() { 37.168 + T value = default_value(); 37.169 + for (idx_t i = 0; i < length(); i++) { 37.170 + set_by_index(i, value); 37.171 + } 37.172 + } 37.173 +public: 37.174 + G1BiasedMappedArray() {} 37.175 + 37.176 + // Allocate and initialize this array to cover the heap addresses in the range 37.177 + // of [bottom, end). 37.178 + void initialize(HeapWord* bottom, HeapWord* end, size_t mapping_granularity) { 37.179 + G1BiasedMappedArrayBase::initialize(bottom, end, sizeof(T), mapping_granularity); 37.180 + this->clear(); 37.181 + } 37.182 +}; 37.183 + 37.184 +#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1BIASEDARRAY_HPP
38.1 --- a/src/share/vm/gc_implementation/g1/g1CardCounts.cpp Wed Oct 09 13:00:20 2013 +0200 38.2 +++ b/src/share/vm/gc_implementation/g1/g1CardCounts.cpp Wed Oct 09 05:03:34 2013 -0700 38.3 @@ -65,9 +65,7 @@ 38.4 // threshold limit is no more than this. 38.5 guarantee(G1ConcRSHotCardLimit <= max_jubyte, "sanity"); 38.6 38.7 - ModRefBarrierSet* bs = _g1h->mr_bs(); 38.8 - guarantee(bs->is_a(BarrierSet::CardTableModRef), "Precondition"); 38.9 - _ct_bs = (CardTableModRefBS*)bs; 38.10 + _ct_bs = _g1h->g1_barrier_set(); 38.11 _ct_bot = _ct_bs->byte_for_const(_g1h->reserved_region().start()); 38.12 38.13 // Allocate/Reserve the counts table
39.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Oct 09 13:00:20 2013 +0200 39.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Oct 09 05:03:34 2013 -0700 39.3 @@ -125,10 +125,8 @@ 39.4 int _histo[256]; 39.5 public: 39.6 ClearLoggedCardTableEntryClosure() : 39.7 - _calls(0) 39.8 + _calls(0), _g1h(G1CollectedHeap::heap()), _ctbs(_g1h->g1_barrier_set()) 39.9 { 39.10 - _g1h = G1CollectedHeap::heap(); 39.11 - _ctbs = (CardTableModRefBS*)_g1h->barrier_set(); 39.12 for (int i = 0; i < 256; i++) _histo[i] = 0; 39.13 } 39.14 bool do_card_ptr(jbyte* card_ptr, int worker_i) { 39.15 @@ -158,11 +156,8 @@ 39.16 CardTableModRefBS* _ctbs; 39.17 public: 39.18 RedirtyLoggedCardTableEntryClosure() : 39.19 - _calls(0) 39.20 - { 39.21 - _g1h = G1CollectedHeap::heap(); 39.22 - _ctbs = (CardTableModRefBS*)_g1h->barrier_set(); 39.23 - } 39.24 + _calls(0), _g1h(G1CollectedHeap::heap()), _ctbs(_g1h->g1_barrier_set()) {} 39.25 + 39.26 bool do_card_ptr(jbyte* card_ptr, int worker_i) { 39.27 if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) { 39.28 _calls++; 39.29 @@ -478,7 +473,7 @@ 39.30 39.31 void G1CollectedHeap::check_ct_logs_at_safepoint() { 39.32 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); 39.33 - CardTableModRefBS* ct_bs = (CardTableModRefBS*)barrier_set(); 39.34 + CardTableModRefBS* ct_bs = g1_barrier_set(); 39.35 39.36 // Count the dirty cards at the start. 39.37 CountNonCleanMemRegionClosure count1(this); 39.38 @@ -1205,7 +1200,7 @@ 39.39 }; 39.40 39.41 void G1CollectedHeap::clear_rsets_post_compaction() { 39.42 - PostMCRemSetClearClosure rs_clear(this, mr_bs()); 39.43 + PostMCRemSetClearClosure rs_clear(this, g1_barrier_set()); 39.44 heap_region_iterate(&rs_clear); 39.45 } 39.46 39.47 @@ -1777,7 +1772,6 @@ 39.48 } 39.49 39.50 bool G1CollectedHeap::expand(size_t expand_bytes) { 39.51 - size_t old_mem_size = _g1_storage.committed_size(); 39.52 size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes); 39.53 aligned_expand_bytes = align_size_up(aligned_expand_bytes, 39.54 HeapRegion::GrainBytes); 39.55 @@ -1787,6 +1781,13 @@ 39.56 ergo_format_byte("attempted expansion amount"), 39.57 expand_bytes, aligned_expand_bytes); 39.58 39.59 + if (_g1_storage.uncommitted_size() == 0) { 39.60 + ergo_verbose0(ErgoHeapSizing, 39.61 + "did not expand the heap", 39.62 + ergo_format_reason("heap already fully expanded")); 39.63 + return false; 39.64 + } 39.65 + 39.66 // First commit the memory. 39.67 HeapWord* old_end = (HeapWord*) _g1_storage.high(); 39.68 bool successful = _g1_storage.expand_by(aligned_expand_bytes); 39.69 @@ -1845,7 +1846,6 @@ 39.70 } 39.71 39.72 void G1CollectedHeap::shrink_helper(size_t shrink_bytes) { 39.73 - size_t old_mem_size = _g1_storage.committed_size(); 39.74 size_t aligned_shrink_bytes = 39.75 ReservedSpace::page_align_size_down(shrink_bytes); 39.76 aligned_shrink_bytes = align_size_down(aligned_shrink_bytes, 39.77 @@ -2045,20 +2045,13 @@ 39.78 // Create the gen rem set (and barrier set) for the entire reserved region. 39.79 _rem_set = collector_policy()->create_rem_set(_reserved, 2); 39.80 set_barrier_set(rem_set()->bs()); 39.81 - if (barrier_set()->is_a(BarrierSet::ModRef)) { 39.82 - _mr_bs = (ModRefBarrierSet*)_barrier_set; 39.83 - } else { 39.84 - vm_exit_during_initialization("G1 requires a mod ref bs."); 39.85 + if (!barrier_set()->is_a(BarrierSet::G1SATBCTLogging)) { 39.86 + vm_exit_during_initialization("G1 requires a G1SATBLoggingCardTableModRefBS"); 39.87 return JNI_ENOMEM; 39.88 } 39.89 39.90 // Also create a G1 rem set. 39.91 - if (mr_bs()->is_a(BarrierSet::CardTableModRef)) { 39.92 - _g1_rem_set = new G1RemSet(this, (CardTableModRefBS*)mr_bs()); 39.93 - } else { 39.94 - vm_exit_during_initialization("G1 requires a cardtable mod ref bs."); 39.95 - return JNI_ENOMEM; 39.96 - } 39.97 + _g1_rem_set = new G1RemSet(this, g1_barrier_set()); 39.98 39.99 // Carve out the G1 part of the heap. 39.100 39.101 @@ -2069,8 +2062,10 @@ 39.102 _g1_storage.initialize(g1_rs, 0); 39.103 _g1_committed = MemRegion((HeapWord*)_g1_storage.low(), (size_t) 0); 39.104 _hrs.initialize((HeapWord*) _g1_reserved.start(), 39.105 - (HeapWord*) _g1_reserved.end(), 39.106 - _expansion_regions); 39.107 + (HeapWord*) _g1_reserved.end()); 39.108 + assert(_hrs.max_length() == _expansion_regions, 39.109 + err_msg("max length: %u expansion regions: %u", 39.110 + _hrs.max_length(), _expansion_regions)); 39.111 39.112 // Do later initialization work for concurrent refinement. 39.113 _cg1r->init(); 39.114 @@ -3679,6 +3674,11 @@ 39.115 assert(InlineCacheBuffer::is_empty(), "should have cleaned up ICBuffer"); 39.116 // Fill TLAB's and such 39.117 ensure_parsability(true); 39.118 + 39.119 + if (G1SummarizeRSetStats && (G1SummarizeRSetStatsPeriod > 0) && 39.120 + (total_collections() % G1SummarizeRSetStatsPeriod == 0)) { 39.121 + g1_rem_set()->print_periodic_summary_info("Before GC RS summary"); 39.122 + } 39.123 } 39.124 39.125 void G1CollectedHeap::gc_epilogue(bool full /* Ignored */) { 39.126 @@ -3687,7 +3687,7 @@ 39.127 (G1SummarizeRSetStatsPeriod > 0) && 39.128 // we are at the end of the GC. Total collections has already been increased. 39.129 ((total_collections() - 1) % G1SummarizeRSetStatsPeriod == 0)) { 39.130 - g1_rem_set()->print_periodic_summary_info(); 39.131 + g1_rem_set()->print_periodic_summary_info("After GC RS summary"); 39.132 } 39.133 39.134 // FIXME: what is this about? 39.135 @@ -4548,7 +4548,7 @@ 39.136 : _g1h(g1h), 39.137 _refs(g1h->task_queue(queue_num)), 39.138 _dcq(&g1h->dirty_card_queue_set()), 39.139 - _ct_bs((CardTableModRefBS*)_g1h->barrier_set()), 39.140 + _ct_bs(g1h->g1_barrier_set()), 39.141 _g1_rem(g1h->g1_rem_set()), 39.142 _hash_seed(17), _queue_num(queue_num), 39.143 _term_attempts(0), 39.144 @@ -4615,7 +4615,7 @@ 39.145 assert(!has_partial_array_mask(ref), err_msg("ref=" PTR_FORMAT, ref)); 39.146 oop p = oopDesc::load_decode_heap_oop(ref); 39.147 assert(_g1h->is_in_g1_reserved(p), 39.148 - err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, ref, intptr_t(p))); 39.149 + err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, ref, (void *)p)); 39.150 return true; 39.151 } 39.152 39.153 @@ -4625,11 +4625,11 @@ 39.154 // Must be in the collection set--it's already been copied. 39.155 oop p = clear_partial_array_mask(ref); 39.156 assert(_g1h->obj_in_cs(p), 39.157 - err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, ref, intptr_t(p))); 39.158 + err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, ref, (void *)p)); 39.159 } else { 39.160 oop p = oopDesc::load_decode_heap_oop(ref); 39.161 assert(_g1h->is_in_g1_reserved(p), 39.162 - err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, ref, intptr_t(p))); 39.163 + err_msg("ref=" PTR_FORMAT " p=" PTR_FORMAT, ref, (void *)p)); 39.164 } 39.165 return true; 39.166 } 39.167 @@ -5977,11 +5977,11 @@ 39.168 } 39.169 39.170 class G1ParCleanupCTTask : public AbstractGangTask { 39.171 - CardTableModRefBS* _ct_bs; 39.172 + G1SATBCardTableModRefBS* _ct_bs; 39.173 G1CollectedHeap* _g1h; 39.174 HeapRegion* volatile _su_head; 39.175 public: 39.176 - G1ParCleanupCTTask(CardTableModRefBS* ct_bs, 39.177 + G1ParCleanupCTTask(G1SATBCardTableModRefBS* ct_bs, 39.178 G1CollectedHeap* g1h) : 39.179 AbstractGangTask("G1 Par Cleanup CT Task"), 39.180 _ct_bs(ct_bs), _g1h(g1h) { } 39.181 @@ -6004,9 +6004,9 @@ 39.182 #ifndef PRODUCT 39.183 class G1VerifyCardTableCleanup: public HeapRegionClosure { 39.184 G1CollectedHeap* _g1h; 39.185 - CardTableModRefBS* _ct_bs; 39.186 + G1SATBCardTableModRefBS* _ct_bs; 39.187 public: 39.188 - G1VerifyCardTableCleanup(G1CollectedHeap* g1h, CardTableModRefBS* ct_bs) 39.189 + G1VerifyCardTableCleanup(G1CollectedHeap* g1h, G1SATBCardTableModRefBS* ct_bs) 39.190 : _g1h(g1h), _ct_bs(ct_bs) { } 39.191 virtual bool doHeapRegion(HeapRegion* r) { 39.192 if (r->is_survivor()) { 39.193 @@ -6020,7 +6020,7 @@ 39.194 39.195 void G1CollectedHeap::verify_not_dirty_region(HeapRegion* hr) { 39.196 // All of the region should be clean. 39.197 - CardTableModRefBS* ct_bs = (CardTableModRefBS*)barrier_set(); 39.198 + G1SATBCardTableModRefBS* ct_bs = g1_barrier_set(); 39.199 MemRegion mr(hr->bottom(), hr->end()); 39.200 ct_bs->verify_not_dirty_region(mr); 39.201 } 39.202 @@ -6033,13 +6033,13 @@ 39.203 // not dirty that area (one less thing to have to do while holding 39.204 // a lock). So we can only verify that [bottom(),pre_dummy_top()] 39.205 // is dirty. 39.206 - CardTableModRefBS* ct_bs = (CardTableModRefBS*) barrier_set(); 39.207 + G1SATBCardTableModRefBS* ct_bs = g1_barrier_set(); 39.208 MemRegion mr(hr->bottom(), hr->pre_dummy_top()); 39.209 ct_bs->verify_dirty_region(mr); 39.210 } 39.211 39.212 void G1CollectedHeap::verify_dirty_young_list(HeapRegion* head) { 39.213 - CardTableModRefBS* ct_bs = (CardTableModRefBS*) barrier_set(); 39.214 + G1SATBCardTableModRefBS* ct_bs = g1_barrier_set(); 39.215 for (HeapRegion* hr = head; hr != NULL; hr = hr->get_next_young_region()) { 39.216 verify_dirty_region(hr); 39.217 } 39.218 @@ -6051,7 +6051,7 @@ 39.219 #endif 39.220 39.221 void G1CollectedHeap::cleanUpCardTable() { 39.222 - CardTableModRefBS* ct_bs = (CardTableModRefBS*) (barrier_set()); 39.223 + G1SATBCardTableModRefBS* ct_bs = g1_barrier_set(); 39.224 double start = os::elapsedTime(); 39.225 39.226 {
40.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Wed Oct 09 13:00:20 2013 +0200 40.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Wed Oct 09 05:03:34 2013 -0700 40.3 @@ -31,6 +31,7 @@ 40.4 #include "gc_implementation/g1/g1HRPrinter.hpp" 40.5 #include "gc_implementation/g1/g1MonitoringSupport.hpp" 40.6 #include "gc_implementation/g1/g1RemSet.hpp" 40.7 +#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" 40.8 #include "gc_implementation/g1/g1YCTypes.hpp" 40.9 #include "gc_implementation/g1/heapRegionSeq.hpp" 40.10 #include "gc_implementation/g1/heapRegionSets.hpp" 40.11 @@ -703,7 +704,7 @@ 40.12 if (_g1_committed.contains((HeapWord*) obj)) { 40.13 // no need to subtract the bottom of the heap from obj, 40.14 // _in_cset_fast_test is biased 40.15 - uintx index = (uintx) obj >> HeapRegion::LogOfHRGrainBytes; 40.16 + uintx index = cast_from_oop<uintx>(obj) >> HeapRegion::LogOfHRGrainBytes; 40.17 bool ret = _in_cset_fast_test[index]; 40.18 // let's make sure the result is consistent with what the slower 40.19 // test returns 40.20 @@ -791,8 +792,6 @@ 40.21 40.22 // The g1 remembered set of the heap. 40.23 G1RemSet* _g1_rem_set; 40.24 - // And it's mod ref barrier set, used to track updates for the above. 40.25 - ModRefBarrierSet* _mr_bs; 40.26 40.27 // A set of cards that cover the objects for which the Rsets should be updated 40.28 // concurrently after the collection. 40.29 @@ -1127,7 +1126,6 @@ 40.30 40.31 // The rem set and barrier set. 40.32 G1RemSet* g1_rem_set() const { return _g1_rem_set; } 40.33 - ModRefBarrierSet* mr_bs() const { return _mr_bs; } 40.34 40.35 unsigned get_gc_time_stamp() { 40.36 return _gc_time_stamp; 40.37 @@ -1346,6 +1344,10 @@ 40.38 40.39 virtual bool is_in_closed_subset(const void* p) const; 40.40 40.41 + G1SATBCardTableModRefBS* g1_barrier_set() { 40.42 + return (G1SATBCardTableModRefBS*) barrier_set(); 40.43 + } 40.44 + 40.45 // This resets the card table to all zeros. It is used after 40.46 // a collection pause which used the card table to claim cards. 40.47 void cleanUpCardTable(); 40.48 @@ -1875,7 +1877,7 @@ 40.49 G1CollectedHeap* _g1h; 40.50 RefToScanQueue* _refs; 40.51 DirtyCardQueue _dcq; 40.52 - CardTableModRefBS* _ct_bs; 40.53 + G1SATBCardTableModRefBS* _ct_bs; 40.54 G1RemSet* _g1_rem; 40.55 40.56 G1ParGCAllocBufferContainer _surviving_alloc_buffer; 40.57 @@ -1914,7 +1916,7 @@ 40.58 void add_to_undo_waste(size_t waste) { _undo_waste += waste; } 40.59 40.60 DirtyCardQueue& dirty_card_queue() { return _dcq; } 40.61 - CardTableModRefBS* ctbs() { return _ct_bs; } 40.62 + G1SATBCardTableModRefBS* ctbs() { return _ct_bs; } 40.63 40.64 template <class T> void immediate_rs_update(HeapRegion* from, T* p, int tid) { 40.65 if (!from->is_survivor()) {
41.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp Wed Oct 09 13:00:20 2013 +0200 41.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp Wed Oct 09 05:03:34 2013 -0700 41.3 @@ -134,7 +134,7 @@ 41.4 assert(containing_hr->is_in(end - 1), "it should also contain end - 1"); 41.5 41.6 MemRegion mr(start, end); 41.7 - ((CardTableModRefBS*)_g1h->barrier_set())->dirty(mr); 41.8 + g1_barrier_set()->dirty(mr); 41.9 } 41.10 41.11 inline RefToScanQueue* G1CollectedHeap::task_queue(int i) const {
42.1 --- a/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp Wed Oct 09 13:00:20 2013 +0200 42.2 +++ b/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp Wed Oct 09 05:03:34 2013 -0700 42.3 @@ -41,11 +41,11 @@ 42.4 private: 42.5 G1CollectedHeap* _g1; 42.6 DirtyCardQueue *_dcq; 42.7 - CardTableModRefBS* _ct_bs; 42.8 + G1SATBCardTableModRefBS* _ct_bs; 42.9 42.10 public: 42.11 UpdateRSetDeferred(G1CollectedHeap* g1, DirtyCardQueue* dcq) : 42.12 - _g1(g1), _ct_bs((CardTableModRefBS*)_g1->barrier_set()), _dcq(dcq) {} 42.13 + _g1(g1), _ct_bs(_g1->g1_barrier_set()), _dcq(dcq) {} 42.14 42.15 virtual void do_oop(narrowOop* p) { do_oop_work(p); } 42.16 virtual void do_oop( oop* p) { do_oop_work(p); }
43.1 --- a/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Wed Oct 09 13:00:20 2013 +0200 43.2 +++ b/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Wed Oct 09 05:03:34 2013 -0700 43.3 @@ -220,7 +220,7 @@ 43.4 public: 43.5 G1PrepareCompactClosure(CompactibleSpace* cs) 43.6 : _g1h(G1CollectedHeap::heap()), 43.7 - _mrbs(G1CollectedHeap::heap()->mr_bs()), 43.8 + _mrbs(_g1h->g1_barrier_set()), 43.9 _cp(NULL, cs, cs->initialize_threshold()), 43.10 _humongous_proxy_set("G1MarkSweep Humongous Proxy Set") { } 43.11
44.1 --- a/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Wed Oct 09 13:00:20 2013 +0200 44.2 +++ b/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Wed Oct 09 05:03:34 2013 -0700 44.3 @@ -1,5 +1,5 @@ 44.4 /* 44.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 44.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 44.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 44.8 * 44.9 * This code is free software; you can redistribute it and/or modify it 44.10 @@ -91,12 +91,12 @@ 44.11 } 44.12 44.13 template <class T> inline T* set_partial_array_mask(T obj) { 44.14 - assert(((uintptr_t)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); 44.15 - return (T*) ((uintptr_t)obj | G1_PARTIAL_ARRAY_MASK); 44.16 + assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); 44.17 + return (T*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); 44.18 } 44.19 44.20 template <class T> inline oop clear_partial_array_mask(T* ref) { 44.21 - return oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); 44.22 + return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); 44.23 } 44.24 44.25 class G1ParScanPartialArrayClosure : public G1ParClosureSuper {
45.1 --- a/src/share/vm/gc_implementation/g1/g1RemSet.cpp Wed Oct 09 13:00:20 2013 +0200 45.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSet.cpp Wed Oct 09 05:03:34 2013 -0700 45.3 @@ -83,7 +83,9 @@ 45.4 for (uint i = 0; i < n_workers(); i++) { 45.5 _cset_rs_update_cl[i] = NULL; 45.6 } 45.7 - _prev_period_summary.initialize(this, n_workers()); 45.8 + if (G1SummarizeRSetStats) { 45.9 + _prev_period_summary.initialize(this); 45.10 + } 45.11 } 45.12 45.13 G1RemSet::~G1RemSet() { 45.14 @@ -109,7 +111,7 @@ 45.15 CodeBlobToOopClosure* _code_root_cl; 45.16 45.17 G1BlockOffsetSharedArray* _bot_shared; 45.18 - CardTableModRefBS *_ct_bs; 45.19 + G1SATBCardTableModRefBS *_ct_bs; 45.20 45.21 double _strong_code_root_scan_time_sec; 45.22 int _worker_i; 45.23 @@ -130,7 +132,7 @@ 45.24 { 45.25 _g1h = G1CollectedHeap::heap(); 45.26 _bot_shared = _g1h->bot_shared(); 45.27 - _ct_bs = (CardTableModRefBS*) (_g1h->barrier_set()); 45.28 + _ct_bs = _g1h->g1_barrier_set(); 45.29 _block_size = MAX2<int>(G1RSetScanBlockSize, 1); 45.30 } 45.31 45.32 @@ -505,12 +507,7 @@ 45.33 ScrubRSClosure(BitMap* region_bm, BitMap* card_bm) : 45.34 _g1h(G1CollectedHeap::heap()), 45.35 _region_bm(region_bm), _card_bm(card_bm), 45.36 - _ctbs(NULL) 45.37 - { 45.38 - ModRefBarrierSet* bs = _g1h->mr_bs(); 45.39 - guarantee(bs->is_a(BarrierSet::CardTableModRef), "Precondition"); 45.40 - _ctbs = (CardTableModRefBS*)bs; 45.41 - } 45.42 + _ctbs(_g1h->g1_barrier_set()) {} 45.43 45.44 bool doHeapRegion(HeapRegion* r) { 45.45 if (!r->continuesHumongous()) { 45.46 @@ -731,19 +728,19 @@ 45.47 return has_refs_into_cset; 45.48 } 45.49 45.50 -void G1RemSet::print_periodic_summary_info() { 45.51 +void G1RemSet::print_periodic_summary_info(const char* header) { 45.52 G1RemSetSummary current; 45.53 - current.initialize(this, n_workers()); 45.54 + current.initialize(this); 45.55 45.56 _prev_period_summary.subtract_from(¤t); 45.57 - print_summary_info(&_prev_period_summary); 45.58 + print_summary_info(&_prev_period_summary, header); 45.59 45.60 _prev_period_summary.set(¤t); 45.61 } 45.62 45.63 void G1RemSet::print_summary_info() { 45.64 G1RemSetSummary current; 45.65 - current.initialize(this, n_workers()); 45.66 + current.initialize(this); 45.67 45.68 print_summary_info(¤t, " Cumulative RS summary"); 45.69 }
46.1 --- a/src/share/vm/gc_implementation/g1/g1RemSet.hpp Wed Oct 09 13:00:20 2013 +0200 46.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSet.hpp Wed Oct 09 05:03:34 2013 -0700 46.3 @@ -145,7 +145,7 @@ 46.4 virtual void print_summary_info(); 46.5 46.6 // Print accumulated summary info from the last time called. 46.7 - virtual void print_periodic_summary_info(); 46.8 + virtual void print_periodic_summary_info(const char* header); 46.9 46.10 // Prepare remembered set for verification. 46.11 virtual void prepare_for_verify();
47.1 --- a/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp Wed Oct 09 13:00:20 2013 +0200 47.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp Wed Oct 09 05:03:34 2013 -0700 47.3 @@ -77,12 +77,12 @@ 47.4 return _rs_threads_vtimes[thread]; 47.5 } 47.6 47.7 -void G1RemSetSummary::initialize(G1RemSet* remset, uint num_workers) { 47.8 +void G1RemSetSummary::initialize(G1RemSet* remset) { 47.9 assert(_rs_threads_vtimes == NULL, "just checking"); 47.10 assert(remset != NULL, "just checking"); 47.11 47.12 _remset = remset; 47.13 - _num_vtimes = num_workers; 47.14 + _num_vtimes = ConcurrentG1Refine::thread_num(); 47.15 _rs_threads_vtimes = NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC); 47.16 memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes); 47.17 47.18 @@ -125,25 +125,115 @@ 47.19 _sampling_thread_vtime = other->sampling_thread_vtime() - _sampling_thread_vtime; 47.20 } 47.21 47.22 +static double percent_of(size_t numerator, size_t denominator) { 47.23 + if (denominator != 0) { 47.24 + return (double)numerator / denominator * 100.0f; 47.25 + } else { 47.26 + return 0.0f; 47.27 + } 47.28 +} 47.29 + 47.30 +static size_t round_to_K(size_t value) { 47.31 + return value / K; 47.32 +} 47.33 + 47.34 +class RegionTypeCounter VALUE_OBJ_CLASS_SPEC { 47.35 +private: 47.36 + const char* _name; 47.37 + 47.38 + size_t _rs_mem_size; 47.39 + size_t _cards_occupied; 47.40 + size_t _amount; 47.41 + 47.42 + size_t _code_root_mem_size; 47.43 + size_t _code_root_elems; 47.44 + 47.45 + double rs_mem_size_percent_of(size_t total) { 47.46 + return percent_of(_rs_mem_size, total); 47.47 + } 47.48 + 47.49 + double cards_occupied_percent_of(size_t total) { 47.50 + return percent_of(_cards_occupied, total); 47.51 + } 47.52 + 47.53 + double code_root_mem_size_percent_of(size_t total) { 47.54 + return percent_of(_code_root_mem_size, total); 47.55 + } 47.56 + 47.57 + double code_root_elems_percent_of(size_t total) { 47.58 + return percent_of(_code_root_elems, total); 47.59 + } 47.60 + 47.61 + size_t amount() const { return _amount; } 47.62 + 47.63 +public: 47.64 + 47.65 + RegionTypeCounter(const char* name) : _name(name), _rs_mem_size(0), _cards_occupied(0), 47.66 + _amount(0), _code_root_mem_size(0), _code_root_elems(0) { } 47.67 + 47.68 + void add(size_t rs_mem_size, size_t cards_occupied, size_t code_root_mem_size, 47.69 + size_t code_root_elems) { 47.70 + _rs_mem_size += rs_mem_size; 47.71 + _cards_occupied += cards_occupied; 47.72 + _code_root_mem_size += code_root_mem_size; 47.73 + _code_root_elems += code_root_elems; 47.74 + _amount++; 47.75 + } 47.76 + 47.77 + size_t rs_mem_size() const { return _rs_mem_size; } 47.78 + size_t cards_occupied() const { return _cards_occupied; } 47.79 + 47.80 + size_t code_root_mem_size() const { return _code_root_mem_size; } 47.81 + size_t code_root_elems() const { return _code_root_elems; } 47.82 + 47.83 + void print_rs_mem_info_on(outputStream * out, size_t total) { 47.84 + out->print_cr(" %8dK (%5.1f%%) by %zd %s regions", round_to_K(rs_mem_size()), rs_mem_size_percent_of(total), amount(), _name); 47.85 + } 47.86 + 47.87 + void print_cards_occupied_info_on(outputStream * out, size_t total) { 47.88 + out->print_cr(" %8d (%5.1f%%) entries by %zd %s regions", cards_occupied(), cards_occupied_percent_of(total), amount(), _name); 47.89 + } 47.90 + 47.91 + void print_code_root_mem_info_on(outputStream * out, size_t total) { 47.92 + out->print_cr(" %8dK (%5.1f%%) by %zd %s regions", round_to_K(code_root_mem_size()), code_root_mem_size_percent_of(total), amount(), _name); 47.93 + } 47.94 + 47.95 + void print_code_root_elems_info_on(outputStream * out, size_t total) { 47.96 + out->print_cr(" %8d (%5.1f%%) elements by %zd %s regions", code_root_elems(), code_root_elems_percent_of(total), amount(), _name); 47.97 + } 47.98 +}; 47.99 + 47.100 + 47.101 class HRRSStatsIter: public HeapRegionClosure { 47.102 - size_t _occupied; 47.103 +private: 47.104 + RegionTypeCounter _young; 47.105 + RegionTypeCounter _humonguous; 47.106 + RegionTypeCounter _free; 47.107 + RegionTypeCounter _old; 47.108 + RegionTypeCounter _all; 47.109 47.110 - size_t _total_rs_mem_sz; 47.111 size_t _max_rs_mem_sz; 47.112 HeapRegion* _max_rs_mem_sz_region; 47.113 47.114 - size_t _total_code_root_mem_sz; 47.115 + size_t total_rs_mem_sz() const { return _all.rs_mem_size(); } 47.116 + size_t total_cards_occupied() const { return _all.cards_occupied(); } 47.117 + 47.118 + size_t max_rs_mem_sz() const { return _max_rs_mem_sz; } 47.119 + HeapRegion* max_rs_mem_sz_region() const { return _max_rs_mem_sz_region; } 47.120 + 47.121 size_t _max_code_root_mem_sz; 47.122 HeapRegion* _max_code_root_mem_sz_region; 47.123 + 47.124 + size_t total_code_root_mem_sz() const { return _all.code_root_mem_size(); } 47.125 + size_t total_code_root_elems() const { return _all.code_root_elems(); } 47.126 + 47.127 + size_t max_code_root_mem_sz() const { return _max_code_root_mem_sz; } 47.128 + HeapRegion* max_code_root_mem_sz_region() const { return _max_code_root_mem_sz_region; } 47.129 + 47.130 public: 47.131 - HRRSStatsIter() : 47.132 - _occupied(0), 47.133 - _total_rs_mem_sz(0), 47.134 - _max_rs_mem_sz(0), 47.135 - _max_rs_mem_sz_region(NULL), 47.136 - _total_code_root_mem_sz(0), 47.137 - _max_code_root_mem_sz(0), 47.138 - _max_code_root_mem_sz_region(NULL) 47.139 + HRRSStatsIter() : _all("All"), _young("Young"), _humonguous("Humonguous"), 47.140 + _free("Free"), _old("Old"), _max_code_root_mem_sz_region(NULL), _max_rs_mem_sz_region(NULL), 47.141 + _max_rs_mem_sz(0), _max_code_root_mem_sz(0) 47.142 {} 47.143 47.144 bool doHeapRegion(HeapRegion* r) { 47.145 @@ -156,46 +246,95 @@ 47.146 _max_rs_mem_sz = rs_mem_sz; 47.147 _max_rs_mem_sz_region = r; 47.148 } 47.149 - _total_rs_mem_sz += rs_mem_sz; 47.150 - 47.151 + size_t occupied_cards = hrrs->occupied(); 47.152 size_t code_root_mem_sz = hrrs->strong_code_roots_mem_size(); 47.153 - if (code_root_mem_sz > _max_code_root_mem_sz) { 47.154 - _max_code_root_mem_sz = code_root_mem_sz; 47.155 + if (code_root_mem_sz > max_code_root_mem_sz()) { 47.156 _max_code_root_mem_sz_region = r; 47.157 } 47.158 - _total_code_root_mem_sz += code_root_mem_sz; 47.159 + size_t code_root_elems = hrrs->strong_code_roots_list_length(); 47.160 47.161 - size_t occ = hrrs->occupied(); 47.162 - _occupied += occ; 47.163 + RegionTypeCounter* current = NULL; 47.164 + if (r->is_young()) { 47.165 + current = &_young; 47.166 + } else if (r->isHumongous()) { 47.167 + current = &_humonguous; 47.168 + } else if (r->is_empty()) { 47.169 + current = &_free; 47.170 + } else { 47.171 + current = &_old; 47.172 + } 47.173 + current->add(rs_mem_sz, occupied_cards, code_root_mem_sz, code_root_elems); 47.174 + _all.add(rs_mem_sz, occupied_cards, code_root_mem_sz, code_root_elems); 47.175 + 47.176 return false; 47.177 } 47.178 - size_t total_rs_mem_sz() { return _total_rs_mem_sz; } 47.179 - size_t max_rs_mem_sz() { return _max_rs_mem_sz; } 47.180 - HeapRegion* max_rs_mem_sz_region() { return _max_rs_mem_sz_region; } 47.181 - size_t total_code_root_mem_sz() { return _total_code_root_mem_sz; } 47.182 - size_t max_code_root_mem_sz() { return _max_code_root_mem_sz; } 47.183 - HeapRegion* max_code_root_mem_sz_region() { return _max_code_root_mem_sz_region; } 47.184 - size_t occupied() { return _occupied; } 47.185 + 47.186 + void print_summary_on(outputStream* out) { 47.187 + RegionTypeCounter* counters[] = { &_young, &_humonguous, &_free, &_old, NULL }; 47.188 + 47.189 + out->print_cr("\n Current rem set statistics"); 47.190 + out->print_cr(" Total per region rem sets sizes = "SIZE_FORMAT"K." 47.191 + " Max = "SIZE_FORMAT"K.", 47.192 + round_to_K(total_rs_mem_sz()), round_to_K(max_rs_mem_sz())); 47.193 + for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) { 47.194 + (*current)->print_rs_mem_info_on(out, total_rs_mem_sz()); 47.195 + } 47.196 + 47.197 + out->print_cr(" Static structures = "SIZE_FORMAT"K," 47.198 + " free_lists = "SIZE_FORMAT"K.", 47.199 + round_to_K(HeapRegionRemSet::static_mem_size()), 47.200 + round_to_K(HeapRegionRemSet::fl_mem_size())); 47.201 + 47.202 + out->print_cr(" "SIZE_FORMAT" occupied cards represented.", 47.203 + total_cards_occupied()); 47.204 + for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) { 47.205 + (*current)->print_cards_occupied_info_on(out, total_cards_occupied()); 47.206 + } 47.207 + 47.208 + // Largest sized rem set region statistics 47.209 + HeapRegionRemSet* rem_set = max_rs_mem_sz_region()->rem_set(); 47.210 + out->print_cr(" Region with largest rem set = "HR_FORMAT", " 47.211 + "size = "SIZE_FORMAT "K, occupied = "SIZE_FORMAT"K.", 47.212 + HR_FORMAT_PARAMS(max_rs_mem_sz_region()), 47.213 + round_to_K(rem_set->mem_size()), 47.214 + round_to_K(rem_set->occupied())); 47.215 + 47.216 + // Strong code root statistics 47.217 + HeapRegionRemSet* max_code_root_rem_set = max_code_root_mem_sz_region()->rem_set(); 47.218 + out->print_cr(" Total heap region code root sets sizes = "SIZE_FORMAT"K." 47.219 + " Max = "SIZE_FORMAT"K.", 47.220 + round_to_K(total_code_root_mem_sz()), 47.221 + round_to_K(max_code_root_rem_set->strong_code_roots_mem_size())); 47.222 + for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) { 47.223 + (*current)->print_code_root_mem_info_on(out, total_code_root_mem_sz()); 47.224 + } 47.225 + 47.226 + out->print_cr(" "SIZE_FORMAT" code roots represented.", 47.227 + total_code_root_elems()); 47.228 + for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) { 47.229 + (*current)->print_code_root_elems_info_on(out, total_code_root_elems()); 47.230 + } 47.231 + 47.232 + out->print_cr(" Region with largest amount of code roots = "HR_FORMAT", " 47.233 + "size = "SIZE_FORMAT "K, num_elems = "SIZE_FORMAT".", 47.234 + HR_FORMAT_PARAMS(max_code_root_mem_sz_region()), 47.235 + round_to_K(max_code_root_rem_set->strong_code_roots_mem_size()), 47.236 + round_to_K(max_code_root_rem_set->strong_code_roots_list_length())); 47.237 + } 47.238 }; 47.239 47.240 -double calc_percentage(size_t numerator, size_t denominator) { 47.241 - if (denominator != 0) { 47.242 - return (double)numerator / denominator * 100.0; 47.243 - } else { 47.244 - return 0.0f; 47.245 - } 47.246 -} 47.247 - 47.248 void G1RemSetSummary::print_on(outputStream* out) { 47.249 - out->print_cr("\n Concurrent RS processed "SIZE_FORMAT" cards", 47.250 + out->print_cr("\n Recent concurrent refinement statistics"); 47.251 + out->print_cr(" Processed "SIZE_FORMAT" cards", 47.252 num_concurrent_refined_cards()); 47.253 out->print_cr(" Of %d completed buffers:", num_processed_buf_total()); 47.254 out->print_cr(" %8d (%5.1f%%) by concurrent RS threads.", 47.255 num_processed_buf_total(), 47.256 - calc_percentage(num_processed_buf_rs_threads(), num_processed_buf_total())); 47.257 + percent_of(num_processed_buf_rs_threads(), num_processed_buf_total())); 47.258 out->print_cr(" %8d (%5.1f%%) by mutator threads.", 47.259 num_processed_buf_mutator(), 47.260 - calc_percentage(num_processed_buf_mutator(), num_processed_buf_total())); 47.261 + percent_of(num_processed_buf_mutator(), num_processed_buf_total())); 47.262 + out->print_cr(" Did %d coarsenings.", num_coarsenings()); 47.263 out->print_cr(" Concurrent RS threads times (s)"); 47.264 out->print(" "); 47.265 for (uint i = 0; i < _num_vtimes; i++) { 47.266 @@ -207,33 +346,5 @@ 47.267 47.268 HRRSStatsIter blk; 47.269 G1CollectedHeap::heap()->heap_region_iterate(&blk); 47.270 - // RemSet stats 47.271 - out->print_cr(" Total heap region rem set sizes = "SIZE_FORMAT"K." 47.272 - " Max = "SIZE_FORMAT"K.", 47.273 - blk.total_rs_mem_sz()/K, blk.max_rs_mem_sz()/K); 47.274 - out->print_cr(" Static structures = "SIZE_FORMAT"K," 47.275 - " free_lists = "SIZE_FORMAT"K.", 47.276 - HeapRegionRemSet::static_mem_size() / K, 47.277 - HeapRegionRemSet::fl_mem_size() / K); 47.278 - out->print_cr(" "SIZE_FORMAT" occupied cards represented.", 47.279 - blk.occupied()); 47.280 - HeapRegion* max_rs_mem_sz_region = blk.max_rs_mem_sz_region(); 47.281 - HeapRegionRemSet* max_rs_rem_set = max_rs_mem_sz_region->rem_set(); 47.282 - out->print_cr(" Max size region = "HR_FORMAT", " 47.283 - "size = "SIZE_FORMAT "K, occupied = "SIZE_FORMAT"K.", 47.284 - HR_FORMAT_PARAMS(max_rs_mem_sz_region), 47.285 - (max_rs_rem_set->mem_size() + K - 1)/K, 47.286 - (max_rs_rem_set->occupied() + K - 1)/K); 47.287 - out->print_cr(" Did %d coarsenings.", num_coarsenings()); 47.288 - // Strong code root stats 47.289 - out->print_cr(" Total heap region code-root set sizes = "SIZE_FORMAT"K." 47.290 - " Max = "SIZE_FORMAT"K.", 47.291 - blk.total_code_root_mem_sz()/K, blk.max_code_root_mem_sz()/K); 47.292 - HeapRegion* max_code_root_mem_sz_region = blk.max_code_root_mem_sz_region(); 47.293 - HeapRegionRemSet* max_code_root_rem_set = max_code_root_mem_sz_region->rem_set(); 47.294 - out->print_cr(" Max size region = "HR_FORMAT", " 47.295 - "size = "SIZE_FORMAT "K, num_elems = "SIZE_FORMAT".", 47.296 - HR_FORMAT_PARAMS(max_code_root_mem_sz_region), 47.297 - (max_code_root_rem_set->strong_code_roots_mem_size() + K - 1)/K, 47.298 - (max_code_root_rem_set->strong_code_roots_list_length())); 47.299 + blk.print_summary_on(out); 47.300 }
48.1 --- a/src/share/vm/gc_implementation/g1/g1RemSetSummary.hpp Wed Oct 09 13:00:20 2013 +0200 48.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSetSummary.hpp Wed Oct 09 05:03:34 2013 -0700 48.3 @@ -84,7 +84,7 @@ 48.4 void subtract_from(G1RemSetSummary* other); 48.5 48.6 // initialize and get the first sampling 48.7 - void initialize(G1RemSet* remset, uint num_workers); 48.8 + void initialize(G1RemSet* remset); 48.9 48.10 void print_on(outputStream* out); 48.11
49.1 --- a/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp Wed Oct 09 13:00:20 2013 +0200 49.2 +++ b/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp Wed Oct 09 05:03:34 2013 -0700 49.3 @@ -1,5 +1,5 @@ 49.4 /* 49.5 - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 49.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 49.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 49.8 * 49.9 * This code is free software; you can redistribute it and/or modify it 49.10 @@ -64,6 +64,27 @@ 49.11 } 49.12 } 49.13 49.14 +bool G1SATBCardTableModRefBS::mark_card_deferred(size_t card_index) { 49.15 + jbyte val = _byte_map[card_index]; 49.16 + // It's already processed 49.17 + if ((val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val()) { 49.18 + return false; 49.19 + } 49.20 + // Cached bit can be installed either on a clean card or on a claimed card. 49.21 + jbyte new_val = val; 49.22 + if (val == clean_card_val()) { 49.23 + new_val = (jbyte)deferred_card_val(); 49.24 + } else { 49.25 + if (val & claimed_card_val()) { 49.26 + new_val = val | (jbyte)deferred_card_val(); 49.27 + } 49.28 + } 49.29 + if (new_val != val) { 49.30 + Atomic::cmpxchg(new_val, &_byte_map[card_index], val); 49.31 + } 49.32 + return true; 49.33 +} 49.34 + 49.35 G1SATBCardTableLoggingModRefBS:: 49.36 G1SATBCardTableLoggingModRefBS(MemRegion whole_heap, 49.37 int max_covered_regions) : 49.38 @@ -95,7 +116,7 @@ 49.39 G1SATBCardTableLoggingModRefBS::write_ref_field_static(void* field, 49.40 oop new_val) { 49.41 uintptr_t field_uint = (uintptr_t)field; 49.42 - uintptr_t new_val_uint = (uintptr_t)new_val; 49.43 + uintptr_t new_val_uint = cast_from_oop<uintptr_t>(new_val); 49.44 uintptr_t comb = field_uint ^ new_val_uint; 49.45 comb = comb >> HeapRegion::LogOfHRGrainBytes; 49.46 if (comb == 0) return;
50.1 --- a/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp Wed Oct 09 13:00:20 2013 +0200 50.2 +++ b/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp Wed Oct 09 05:03:34 2013 -0700 50.3 @@ -89,6 +89,42 @@ 50.4 write_ref_array_pre_work(dst, count); 50.5 } 50.6 } 50.7 + 50.8 +/* 50.9 + Claimed and deferred bits are used together in G1 during the evacuation 50.10 + pause. These bits can have the following state transitions: 50.11 + 1. The claimed bit can be put over any other card state. Except that 50.12 + the "dirty -> dirty and claimed" transition is checked for in 50.13 + G1 code and is not used. 50.14 + 2. Deferred bit can be set only if the previous state of the card 50.15 + was either clean or claimed. mark_card_deferred() is wait-free. 50.16 + We do not care if the operation is be successful because if 50.17 + it does not it will only result in duplicate entry in the update 50.18 + buffer because of the "cache-miss". So it's not worth spinning. 50.19 + */ 50.20 + 50.21 + bool is_card_claimed(size_t card_index) { 50.22 + jbyte val = _byte_map[card_index]; 50.23 + return (val & (clean_card_mask_val() | claimed_card_val())) == claimed_card_val(); 50.24 + } 50.25 + 50.26 + void set_card_claimed(size_t card_index) { 50.27 + jbyte val = _byte_map[card_index]; 50.28 + if (val == clean_card_val()) { 50.29 + val = (jbyte)claimed_card_val(); 50.30 + } else { 50.31 + val |= (jbyte)claimed_card_val(); 50.32 + } 50.33 + _byte_map[card_index] = val; 50.34 + } 50.35 + 50.36 + bool mark_card_deferred(size_t card_index); 50.37 + 50.38 + bool is_card_deferred(size_t card_index) { 50.39 + jbyte val = _byte_map[card_index]; 50.40 + return (val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val(); 50.41 + } 50.42 + 50.43 }; 50.44 50.45 // Adds card-table logging to the post-barrier.
51.1 --- a/src/share/vm/gc_implementation/g1/heapRegion.cpp Wed Oct 09 13:00:20 2013 +0200 51.2 +++ b/src/share/vm/gc_implementation/g1/heapRegion.cpp Wed Oct 09 05:03:34 2013 -0700 51.3 @@ -637,7 +637,7 @@ 51.4 gclog_or_tty->print_cr("Object "PTR_FORMAT" in region " 51.5 "["PTR_FORMAT", "PTR_FORMAT") is above " 51.6 "top "PTR_FORMAT, 51.7 - obj, _hr->bottom(), _hr->end(), _hr->top()); 51.8 + (void *)obj, _hr->bottom(), _hr->end(), _hr->top()); 51.9 _failures = true; 51.10 return; 51.11 } 51.12 @@ -951,12 +951,12 @@ 51.13 Klass* klass = obj->klass(); 51.14 if (!klass->is_metaspace_object()) { 51.15 gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " 51.16 - "not metadata", klass, obj); 51.17 + "not metadata", klass, (void *)obj); 51.18 *failures = true; 51.19 return; 51.20 } else if (!klass->is_klass()) { 51.21 gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " 51.22 - "not a klass", klass, obj); 51.23 + "not a klass", klass, (void *)obj); 51.24 *failures = true; 51.25 return; 51.26 } else { 51.27 @@ -971,7 +971,7 @@ 51.28 } 51.29 } 51.30 } else { 51.31 - gclog_or_tty->print_cr(PTR_FORMAT" no an oop", obj); 51.32 + gclog_or_tty->print_cr(PTR_FORMAT" no an oop", (void *)obj); 51.33 *failures = true; 51.34 return; 51.35 }
52.1 --- a/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Wed Oct 09 13:00:20 2013 +0200 52.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Wed Oct 09 05:03:34 2013 -0700 52.3 @@ -91,8 +91,8 @@ 52.4 gclog_or_tty->print_cr(" PRT::Add_reference_work(" PTR_FORMAT "->" PTR_FORMAT").", 52.5 from, 52.6 UseCompressedOops 52.7 - ? oopDesc::load_decode_heap_oop((narrowOop*)from) 52.8 - : oopDesc::load_decode_heap_oop((oop*)from)); 52.9 + ? (void *)oopDesc::load_decode_heap_oop((narrowOop*)from) 52.10 + : (void *)oopDesc::load_decode_heap_oop((oop*)from)); 52.11 } 52.12 52.13 HeapRegion* loc_hr = hr(); 52.14 @@ -403,8 +403,8 @@ 52.15 gclog_or_tty->print_cr("ORT::add_reference_work(" PTR_FORMAT "->" PTR_FORMAT ").", 52.16 from, 52.17 UseCompressedOops 52.18 - ? oopDesc::load_decode_heap_oop((narrowOop*)from) 52.19 - : oopDesc::load_decode_heap_oop((oop*)from)); 52.20 + ? (void *)oopDesc::load_decode_heap_oop((narrowOop*)from) 52.21 + : (void *)oopDesc::load_decode_heap_oop((oop*)from)); 52.22 } 52.23 52.24 int from_card = (int)(uintptr_t(from) >> CardTableModRefBS::card_shift);
53.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp Wed Oct 09 13:00:20 2013 +0200 53.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp Wed Oct 09 05:03:34 2013 -0700 53.3 @@ -71,27 +71,16 @@ 53.4 53.5 // Public 53.6 53.7 -void HeapRegionSeq::initialize(HeapWord* bottom, HeapWord* end, 53.8 - uint max_length) { 53.9 +void HeapRegionSeq::initialize(HeapWord* bottom, HeapWord* end) { 53.10 assert((uintptr_t) bottom % HeapRegion::GrainBytes == 0, 53.11 "bottom should be heap region aligned"); 53.12 assert((uintptr_t) end % HeapRegion::GrainBytes == 0, 53.13 "end should be heap region aligned"); 53.14 53.15 - _length = 0; 53.16 - _heap_bottom = bottom; 53.17 - _heap_end = end; 53.18 - _region_shift = HeapRegion::LogOfHRGrainBytes; 53.19 _next_search_index = 0; 53.20 _allocated_length = 0; 53.21 - _max_length = max_length; 53.22 53.23 - _regions = NEW_C_HEAP_ARRAY(HeapRegion*, max_length, mtGC); 53.24 - memset(_regions, 0, (size_t) max_length * sizeof(HeapRegion*)); 53.25 - _regions_biased = _regions - ((uintx) bottom >> _region_shift); 53.26 - 53.27 - assert(&_regions[0] == &_regions_biased[addr_to_index_biased(bottom)], 53.28 - "bottom should be included in the region with index 0"); 53.29 + _regions.initialize(bottom, end, HeapRegion::GrainBytes); 53.30 } 53.31 53.32 MemRegion HeapRegionSeq::expand_by(HeapWord* old_end, 53.33 @@ -101,15 +90,15 @@ 53.34 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 53.35 53.36 HeapWord* next_bottom = old_end; 53.37 - assert(_heap_bottom <= next_bottom, "invariant"); 53.38 + assert(heap_bottom() <= next_bottom, "invariant"); 53.39 while (next_bottom < new_end) { 53.40 - assert(next_bottom < _heap_end, "invariant"); 53.41 + assert(next_bottom < heap_end(), "invariant"); 53.42 uint index = length(); 53.43 53.44 - assert(index < _max_length, "otherwise we cannot expand further"); 53.45 + assert(index < max_length(), "otherwise we cannot expand further"); 53.46 if (index == 0) { 53.47 // We have not allocated any regions so far 53.48 - assert(next_bottom == _heap_bottom, "invariant"); 53.49 + assert(next_bottom == heap_bottom(), "invariant"); 53.50 } else { 53.51 // next_bottom should match the end of the last/previous region 53.52 assert(next_bottom == at(index - 1)->end(), "invariant"); 53.53 @@ -122,8 +111,8 @@ 53.54 // allocation failed, we bail out and return what we have done so far 53.55 return MemRegion(old_end, next_bottom); 53.56 } 53.57 - assert(_regions[index] == NULL, "invariant"); 53.58 - _regions[index] = new_hr; 53.59 + assert(_regions.get_by_index(index) == NULL, "invariant"); 53.60 + _regions.set_by_index(index, new_hr); 53.61 increment_allocated_length(); 53.62 } 53.63 // Have to increment the length first, otherwise we will get an 53.64 @@ -228,26 +217,26 @@ 53.65 53.66 #ifndef PRODUCT 53.67 void HeapRegionSeq::verify_optional() { 53.68 - guarantee(_length <= _allocated_length, 53.69 + guarantee(length() <= _allocated_length, 53.70 err_msg("invariant: _length: %u _allocated_length: %u", 53.71 - _length, _allocated_length)); 53.72 - guarantee(_allocated_length <= _max_length, 53.73 + length(), _allocated_length)); 53.74 + guarantee(_allocated_length <= max_length(), 53.75 err_msg("invariant: _allocated_length: %u _max_length: %u", 53.76 - _allocated_length, _max_length)); 53.77 - guarantee(_next_search_index <= _length, 53.78 + _allocated_length, max_length())); 53.79 + guarantee(_next_search_index <= length(), 53.80 err_msg("invariant: _next_search_index: %u _length: %u", 53.81 - _next_search_index, _length)); 53.82 + _next_search_index, length())); 53.83 53.84 - HeapWord* prev_end = _heap_bottom; 53.85 + HeapWord* prev_end = heap_bottom(); 53.86 for (uint i = 0; i < _allocated_length; i += 1) { 53.87 - HeapRegion* hr = _regions[i]; 53.88 + HeapRegion* hr = _regions.get_by_index(i); 53.89 guarantee(hr != NULL, err_msg("invariant: i: %u", i)); 53.90 guarantee(hr->bottom() == prev_end, 53.91 err_msg("invariant i: %u "HR_FORMAT" prev_end: "PTR_FORMAT, 53.92 i, HR_FORMAT_PARAMS(hr), prev_end)); 53.93 guarantee(hr->hrs_index() == i, 53.94 err_msg("invariant: i: %u hrs_index(): %u", i, hr->hrs_index())); 53.95 - if (i < _length) { 53.96 + if (i < length()) { 53.97 // Asserts will fire if i is >= _length 53.98 HeapWord* addr = hr->bottom(); 53.99 guarantee(addr_to_region(addr) == hr, "sanity"); 53.100 @@ -265,8 +254,8 @@ 53.101 prev_end = hr->end(); 53.102 } 53.103 } 53.104 - for (uint i = _allocated_length; i < _max_length; i += 1) { 53.105 - guarantee(_regions[i] == NULL, err_msg("invariant i: %u", i)); 53.106 + for (uint i = _allocated_length; i < max_length(); i += 1) { 53.107 + guarantee(_regions.get_by_index(i) == NULL, err_msg("invariant i: %u", i)); 53.108 } 53.109 } 53.110 #endif // PRODUCT
54.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp Wed Oct 09 13:00:20 2013 +0200 54.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp Wed Oct 09 05:03:34 2013 -0700 54.3 @@ -25,10 +25,17 @@ 54.4 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_HPP 54.5 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_HPP 54.6 54.7 +#include "gc_implementation/g1/g1BiasedArray.hpp" 54.8 + 54.9 class HeapRegion; 54.10 class HeapRegionClosure; 54.11 class FreeRegionList; 54.12 54.13 +class G1HeapRegionTable : public G1BiasedMappedArray<HeapRegion*> { 54.14 + protected: 54.15 + virtual HeapRegion* default_value() const { return NULL; } 54.16 +}; 54.17 + 54.18 // This class keeps track of the region metadata (i.e., HeapRegion 54.19 // instances). They are kept in the _regions array in address 54.20 // order. A region's index in the array corresponds to its index in 54.21 @@ -44,35 +51,21 @@ 54.22 // 54.23 // We keep track of three lengths: 54.24 // 54.25 -// * _length (returned by length()) is the number of currently 54.26 +// * _committed_length (returned by length()) is the number of currently 54.27 // committed regions. 54.28 // * _allocated_length (not exposed outside this class) is the 54.29 // number of regions for which we have HeapRegions. 54.30 -// * _max_length (returned by max_length()) is the maximum number of 54.31 -// regions the heap can have. 54.32 +// * max_length() returns the maximum number of regions the heap can have. 54.33 // 54.34 -// and maintain that: _length <= _allocated_length <= _max_length 54.35 +// and maintain that: _committed_length <= _allocated_length <= max_length() 54.36 54.37 class HeapRegionSeq: public CHeapObj<mtGC> { 54.38 friend class VMStructs; 54.39 54.40 - // The array that holds the HeapRegions. 54.41 - HeapRegion** _regions; 54.42 - 54.43 - // Version of _regions biased to address 0 54.44 - HeapRegion** _regions_biased; 54.45 + G1HeapRegionTable _regions; 54.46 54.47 // The number of regions committed in the heap. 54.48 - uint _length; 54.49 - 54.50 - // The address of the first reserved word in the heap. 54.51 - HeapWord* _heap_bottom; 54.52 - 54.53 - // The address of the last reserved word in the heap - 1. 54.54 - HeapWord* _heap_end; 54.55 - 54.56 - // The log of the region byte size. 54.57 - uint _region_shift; 54.58 + uint _committed_length; 54.59 54.60 // A hint for which index to start searching from for humongous 54.61 // allocations. 54.62 @@ -81,37 +74,33 @@ 54.63 // The number of regions for which we have allocated HeapRegions for. 54.64 uint _allocated_length; 54.65 54.66 - // The maximum number of regions in the heap. 54.67 - uint _max_length; 54.68 - 54.69 // Find a contiguous set of empty regions of length num, starting 54.70 // from the given index. 54.71 uint find_contiguous_from(uint from, uint num); 54.72 54.73 - // Map a heap address to a biased region index. Assume that the 54.74 - // address is valid. 54.75 - inline uintx addr_to_index_biased(HeapWord* addr) const; 54.76 - 54.77 void increment_allocated_length() { 54.78 - assert(_allocated_length < _max_length, "pre-condition"); 54.79 + assert(_allocated_length < max_length(), "pre-condition"); 54.80 _allocated_length++; 54.81 } 54.82 54.83 void increment_length() { 54.84 - assert(_length < _max_length, "pre-condition"); 54.85 - _length++; 54.86 + assert(length() < max_length(), "pre-condition"); 54.87 + _committed_length++; 54.88 } 54.89 54.90 void decrement_length() { 54.91 - assert(_length > 0, "pre-condition"); 54.92 - _length--; 54.93 + assert(length() > 0, "pre-condition"); 54.94 + _committed_length--; 54.95 } 54.96 54.97 + HeapWord* heap_bottom() const { return _regions.bottom_address_mapped(); } 54.98 + HeapWord* heap_end() const {return _regions.end_address_mapped(); } 54.99 + 54.100 public: 54.101 // Empty contructor, we'll initialize it with the initialize() method. 54.102 - HeapRegionSeq() { } 54.103 + HeapRegionSeq() : _regions(), _committed_length(0), _next_search_index(0), _allocated_length(0) { } 54.104 54.105 - void initialize(HeapWord* bottom, HeapWord* end, uint max_length); 54.106 + void initialize(HeapWord* bottom, HeapWord* end); 54.107 54.108 // Return the HeapRegion at the given index. Assume that the index 54.109 // is valid. 54.110 @@ -126,10 +115,10 @@ 54.111 inline HeapRegion* addr_to_region_unsafe(HeapWord* addr) const; 54.112 54.113 // Return the number of regions that have been committed in the heap. 54.114 - uint length() const { return _length; } 54.115 + uint length() const { return _committed_length; } 54.116 54.117 // Return the maximum number of regions in the heap. 54.118 - uint max_length() const { return _max_length; } 54.119 + uint max_length() const { return (uint)_regions.length(); } 54.120 54.121 // Expand the sequence to reflect that the heap has grown from 54.122 // old_end to new_end. Either create new HeapRegions, or re-use
55.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp Wed Oct 09 13:00:20 2013 +0200 55.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSeq.inline.hpp Wed Oct 09 05:03:34 2013 -0700 55.3 @@ -28,28 +28,16 @@ 55.4 #include "gc_implementation/g1/heapRegion.hpp" 55.5 #include "gc_implementation/g1/heapRegionSeq.hpp" 55.6 55.7 -inline uintx HeapRegionSeq::addr_to_index_biased(HeapWord* addr) const { 55.8 - assert(_heap_bottom <= addr && addr < _heap_end, 55.9 - err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT" end: "PTR_FORMAT, 55.10 - addr, _heap_bottom, _heap_end)); 55.11 - uintx index = (uintx) addr >> _region_shift; 55.12 - return index; 55.13 -} 55.14 - 55.15 inline HeapRegion* HeapRegionSeq::addr_to_region_unsafe(HeapWord* addr) const { 55.16 - assert(_heap_bottom <= addr && addr < _heap_end, 55.17 - err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT" end: "PTR_FORMAT, 55.18 - addr, _heap_bottom, _heap_end)); 55.19 - uintx index_biased = addr_to_index_biased(addr); 55.20 - HeapRegion* hr = _regions_biased[index_biased]; 55.21 + HeapRegion* hr = _regions.get_by_address(addr); 55.22 assert(hr != NULL, "invariant"); 55.23 return hr; 55.24 } 55.25 55.26 inline HeapRegion* HeapRegionSeq::addr_to_region(HeapWord* addr) const { 55.27 - if (addr != NULL && addr < _heap_end) { 55.28 - assert(addr >= _heap_bottom, 55.29 - err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT, addr, _heap_bottom)); 55.30 + if (addr != NULL && addr < heap_end()) { 55.31 + assert(addr >= heap_bottom(), 55.32 + err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT, addr, heap_bottom())); 55.33 return addr_to_region_unsafe(addr); 55.34 } 55.35 return NULL; 55.36 @@ -57,7 +45,7 @@ 55.37 55.38 inline HeapRegion* HeapRegionSeq::at(uint index) const { 55.39 assert(index < length(), "pre-condition"); 55.40 - HeapRegion* hr = _regions[index]; 55.41 + HeapRegion* hr = _regions.get_by_index(index); 55.42 assert(hr != NULL, "sanity"); 55.43 assert(hr->hrs_index() == index, "sanity"); 55.44 return hr;
56.1 --- a/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp Wed Oct 09 13:00:20 2013 +0200 56.2 +++ b/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp Wed Oct 09 05:03:34 2013 -0700 56.3 @@ -34,8 +34,14 @@ 56.4 static_field(HeapRegion, GrainBytes, size_t) \ 56.5 static_field(HeapRegion, LogOfHRGrainBytes, int) \ 56.6 \ 56.7 - nonstatic_field(HeapRegionSeq, _regions, HeapRegion**) \ 56.8 - nonstatic_field(HeapRegionSeq, _length, uint) \ 56.9 + nonstatic_field(G1HeapRegionTable, _base, address) \ 56.10 + nonstatic_field(G1HeapRegionTable, _length, size_t) \ 56.11 + nonstatic_field(G1HeapRegionTable, _biased_base, address) \ 56.12 + nonstatic_field(G1HeapRegionTable, _bias, size_t) \ 56.13 + nonstatic_field(G1HeapRegionTable, _shift_by, uint) \ 56.14 + \ 56.15 + nonstatic_field(HeapRegionSeq, _regions, G1HeapRegionTable) \ 56.16 + nonstatic_field(HeapRegionSeq, _committed_length, uint) \ 56.17 \ 56.18 nonstatic_field(G1CollectedHeap, _hrs, HeapRegionSeq) \ 56.19 nonstatic_field(G1CollectedHeap, _g1_committed, MemRegion) \ 56.20 @@ -58,6 +64,8 @@ 56.21 56.22 #define VM_TYPES_G1(declare_type, declare_toplevel_type) \ 56.23 \ 56.24 + declare_toplevel_type(G1HeapRegionTable) \ 56.25 + \ 56.26 declare_type(G1CollectedHeap, SharedHeap) \ 56.27 \ 56.28 declare_type(HeapRegion, ContiguousSpace) \
57.1 --- a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Wed Oct 09 13:00:20 2013 +0200 57.2 +++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Wed Oct 09 05:03:34 2013 -0700 57.3 @@ -1103,7 +1103,7 @@ 57.4 } 57.5 } 57.6 57.7 -static const oop ClaimedForwardPtr = oop(0x4); 57.8 +static const oop ClaimedForwardPtr = cast_to_oop<intptr_t>(0x4); 57.9 57.10 // Because of concurrency, there are times where an object for which 57.11 // "is_forwarded()" is true contains an "interim" forwarding pointer 57.12 @@ -1226,7 +1226,7 @@ 57.13 if (TraceScavenge) { 57.14 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", 57.15 is_in_reserved(new_obj) ? "copying" : "tenuring", 57.16 - new_obj->klass()->internal_name(), old, new_obj, new_obj->size()); 57.17 + new_obj->klass()->internal_name(), (void *)old, (void *)new_obj, new_obj->size()); 57.18 } 57.19 #endif 57.20 57.21 @@ -1347,7 +1347,7 @@ 57.22 if (TraceScavenge) { 57.23 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", 57.24 is_in_reserved(new_obj) ? "copying" : "tenuring", 57.25 - new_obj->klass()->internal_name(), old, new_obj, new_obj->size()); 57.26 + new_obj->klass()->internal_name(), (void *)old, (void *)new_obj, new_obj->size()); 57.27 } 57.28 #endif 57.29 57.30 @@ -1436,7 +1436,7 @@ 57.31 // (although some performance comparisons would be useful since 57.32 // single global lists have their own performance disadvantages 57.33 // as we were made painfully aware not long ago, see 6786503). 57.34 -#define BUSY (oop(0x1aff1aff)) 57.35 +#define BUSY (cast_to_oop<intptr_t>(0x1aff1aff)) 57.36 void ParNewGeneration::push_on_overflow_list(oop from_space_obj, ParScanThreadState* par_scan_state) { 57.37 assert(is_in_reserved(from_space_obj), "Should be from this generation"); 57.38 if (ParGCUseLocalOverflow) { 57.39 @@ -1512,7 +1512,7 @@ 57.40 if (_overflow_list == NULL) return false; 57.41 57.42 // Otherwise, there was something there; try claiming the list. 57.43 - oop prefix = (oop)Atomic::xchg_ptr(BUSY, &_overflow_list); 57.44 + oop prefix = cast_to_oop(Atomic::xchg_ptr(BUSY, &_overflow_list)); 57.45 // Trim off a prefix of at most objsFromOverflow items 57.46 Thread* tid = Thread::current(); 57.47 size_t spin_count = (size_t)ParallelGCThreads; 57.48 @@ -1526,7 +1526,7 @@ 57.49 return false; 57.50 } else if (_overflow_list != BUSY) { 57.51 // try and grab the prefix 57.52 - prefix = (oop)Atomic::xchg_ptr(BUSY, &_overflow_list); 57.53 + prefix = cast_to_oop(Atomic::xchg_ptr(BUSY, &_overflow_list)); 57.54 } 57.55 } 57.56 if (prefix == NULL || prefix == BUSY) {
58.1 --- a/src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp Wed Oct 09 13:00:20 2013 +0200 58.2 +++ b/src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp Wed Oct 09 05:03:34 2013 -0700 58.3 @@ -1,5 +1,5 @@ 58.4 /* 58.5 - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. 58.6 + * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. 58.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 58.8 * 58.9 * This code is free software; you can redistribute it and/or modify it 58.10 @@ -84,7 +84,7 @@ 58.11 Space* sp = gch->space_containing(p); 58.12 oop obj = oop(sp->block_start(p)); 58.13 assert((HeapWord*)obj < (HeapWord*)p, "Error"); 58.14 - tty->print_cr("Object: " PTR_FORMAT, obj); 58.15 + tty->print_cr("Object: " PTR_FORMAT, (void *)obj); 58.16 tty->print_cr("-------"); 58.17 obj->print(); 58.18 tty->print_cr("-----"); 58.19 @@ -110,7 +110,7 @@ 58.20 if (TraceScavenge) { 58.21 gclog_or_tty->print_cr("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", 58.22 "forwarded ", 58.23 - new_obj->klass()->internal_name(), p, obj, new_obj, new_obj->size()); 58.24 + new_obj->klass()->internal_name(), p, (void *)obj, (void *)new_obj, new_obj->size()); 58.25 } 58.26 #endif 58.27
59.1 --- a/src/share/vm/gc_implementation/parallelScavenge/generationSizer.hpp Wed Oct 09 13:00:20 2013 +0200 59.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/generationSizer.hpp Wed Oct 09 05:03:34 2013 -0700 59.3 @@ -40,10 +40,8 @@ 59.4 59.5 void initialize_flags() { 59.6 // Do basic sizing work 59.7 - this->TwoGenerationCollectorPolicy::initialize_flags(); 59.8 + TwoGenerationCollectorPolicy::initialize_flags(); 59.9 59.10 - // If the user hasn't explicitly set the number of worker 59.11 - // threads, set the count. 59.12 assert(UseSerialGC || 59.13 !FLAG_IS_DEFAULT(ParallelGCThreads) || 59.14 (ParallelGCThreads > 0),
60.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp Wed Oct 09 13:00:20 2013 +0200 60.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp Wed Oct 09 05:03:34 2013 -0700 60.3 @@ -23,7 +23,6 @@ 60.4 */ 60.5 60.6 #include "precompiled.hpp" 60.7 -#include "gc_implementation/parallelScavenge/generationSizer.hpp" 60.8 #include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp" 60.9 #include "gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp" 60.10 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
61.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp Wed Oct 09 13:00:20 2013 +0200 61.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp Wed Oct 09 05:03:34 2013 -0700 61.3 @@ -53,7 +53,6 @@ 61.4 61.5 // Forward decls 61.6 class elapsedTimer; 61.7 -class GenerationSizer; 61.8 61.9 class PSAdaptiveSizePolicy : public AdaptiveSizePolicy { 61.10 friend class PSGCAdaptivePolicyCounters;
62.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Wed Oct 09 13:00:20 2013 +0200 62.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Wed Oct 09 05:03:34 2013 -0700 62.3 @@ -26,7 +26,6 @@ 62.4 #include "classfile/symbolTable.hpp" 62.5 #include "classfile/systemDictionary.hpp" 62.6 #include "code/codeCache.hpp" 62.7 -#include "gc_implementation/parallelScavenge/generationSizer.hpp" 62.8 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" 62.9 #include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp" 62.10 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
63.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Wed Oct 09 13:00:20 2013 +0200 63.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Wed Oct 09 05:03:34 2013 -0700 63.3 @@ -27,7 +27,6 @@ 63.4 #include "classfile/systemDictionary.hpp" 63.5 #include "code/codeCache.hpp" 63.6 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp" 63.7 -#include "gc_implementation/parallelScavenge/generationSizer.hpp" 63.8 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp" 63.9 #include "gc_implementation/parallelScavenge/pcTasks.hpp" 63.10 #include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp"
64.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp Wed Oct 09 13:00:20 2013 +0200 64.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp Wed Oct 09 05:03:34 2013 -0700 64.3 @@ -333,7 +333,7 @@ 64.4 gclog_or_tty->print_cr("{%s %s 0x%x (%d)}", 64.5 "promotion-failure", 64.6 obj->klass()->internal_name(), 64.7 - obj, obj->size()); 64.8 + (void *)obj, obj->size()); 64.9 64.10 } 64.11 #endif
65.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp Wed Oct 09 13:00:20 2013 +0200 65.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp Wed Oct 09 05:03:34 2013 -0700 65.3 @@ -126,7 +126,7 @@ 65.4 65.5 oop* mask_chunked_array_oop(oop obj) { 65.6 assert(!is_oop_masked((oop*) obj), "invariant"); 65.7 - oop* ret = (oop*) ((uintptr_t)obj | PS_CHUNKED_ARRAY_OOP_MASK); 65.8 + oop* ret = (oop*) (cast_from_oop<uintptr_t>(obj) | PS_CHUNKED_ARRAY_OOP_MASK); 65.9 assert(is_oop_masked(ret), "invariant"); 65.10 return ret; 65.11 }
66.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp Wed Oct 09 13:00:20 2013 +0200 66.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp Wed Oct 09 05:03:34 2013 -0700 66.3 @@ -225,7 +225,7 @@ 66.4 if (TraceScavenge) { 66.5 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", 66.6 PSScavenge::should_scavenge(&new_obj) ? "copying" : "tenuring", 66.7 - new_obj->klass()->internal_name(), o, new_obj, new_obj->size()); 66.8 + new_obj->klass()->internal_name(), (void *)o, (void *)new_obj, new_obj->size()); 66.9 } 66.10 #endif 66.11
67.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Wed Oct 09 13:00:20 2013 +0200 67.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Wed Oct 09 05:03:34 2013 -0700 67.3 @@ -27,7 +27,6 @@ 67.4 #include "code/codeCache.hpp" 67.5 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp" 67.6 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp" 67.7 -#include "gc_implementation/parallelScavenge/generationSizer.hpp" 67.8 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" 67.9 #include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp" 67.10 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
68.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp Wed Oct 09 13:00:20 2013 +0200 68.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp Wed Oct 09 05:03:34 2013 -0700 68.3 @@ -1,5 +1,5 @@ 68.4 /* 68.5 - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 68.6 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. 68.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 68.8 * 68.9 * This code is free software; you can redistribute it and/or modify it 68.10 @@ -81,7 +81,7 @@ 68.11 if (TraceScavenge && o->is_forwarded()) { 68.12 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", 68.13 "forwarding", 68.14 - new_obj->klass()->internal_name(), o, new_obj, new_obj->size()); 68.15 + new_obj->klass()->internal_name(), (void *)o, (void *)new_obj, new_obj->size()); 68.16 } 68.17 #endif 68.18
69.1 --- a/src/share/vm/interpreter/bytecodeTracer.cpp Wed Oct 09 13:00:20 2013 +0200 69.2 +++ b/src/share/vm/interpreter/bytecodeTracer.cpp Wed Oct 09 05:03:34 2013 -0700 69.3 @@ -215,7 +215,7 @@ 69.4 st->print_cr(" %s", buf); 69.5 } 69.6 } else { 69.7 - st->print_cr(" " PTR_FORMAT, (intptr_t) value); 69.8 + st->print_cr(" " PTR_FORMAT, (void *)value); 69.9 } 69.10 } 69.11
70.1 --- a/src/share/vm/interpreter/linkResolver.cpp Wed Oct 09 13:00:20 2013 +0200 70.2 +++ b/src/share/vm/interpreter/linkResolver.cpp Wed Oct 09 05:03:34 2013 -0700 70.3 @@ -1,5 +1,4 @@ 70.4 /* 70.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 70.6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 70.7 * 70.8 * This code is free software; you can redistribute it and/or modify it 70.9 @@ -573,6 +572,16 @@ 70.10 } 70.11 70.12 if (check_access) { 70.13 + // JDK8 adds non-public interface methods, and accessability check requirement 70.14 + assert(current_klass.not_null() , "current_klass should not be null"); 70.15 + 70.16 + // check if method can be accessed by the referring class 70.17 + check_method_accessability(current_klass, 70.18 + resolved_klass, 70.19 + KlassHandle(THREAD, resolved_method->method_holder()), 70.20 + resolved_method, 70.21 + CHECK); 70.22 + 70.23 HandleMark hm(THREAD); 70.24 Handle loader (THREAD, InstanceKlass::cast(current_klass())->class_loader()); 70.25 Handle class_loader (THREAD, resolved_method->method_holder()->class_loader()); 70.26 @@ -604,6 +613,20 @@ 70.27 } 70.28 } 70.29 } 70.30 + 70.31 + if (TraceItables && Verbose) { 70.32 + ResourceMark rm(THREAD); 70.33 + tty->print("invokeinterface resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", 70.34 + (current_klass.is_null() ? "<NULL>" : current_klass->internal_name()), 70.35 + (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), 70.36 + Method::name_and_sig_as_C_string(resolved_klass(), 70.37 + resolved_method->name(), 70.38 + resolved_method->signature()), 70.39 + resolved_method->method_holder()->internal_name() 70.40 + ); 70.41 + resolved_method->access_flags().print_on(tty); 70.42 + tty->cr(); 70.43 + } 70.44 } 70.45 70.46 //------------------------------------------------------------------------------------------------------------------------ 70.47 @@ -795,26 +818,12 @@ 70.48 Symbol* method_name, Symbol* method_signature, 70.49 KlassHandle current_klass, bool check_access, TRAPS) { 70.50 70.51 - if (resolved_klass->is_interface() && current_klass() != NULL) { 70.52 - // If the target class is a direct interface, treat this as a "super" 70.53 - // default call. 70.54 - // 70.55 - // If the current method is an overpass that happens to call a direct 70.56 - // super-interface's method, then we'll end up rerunning the default method 70.57 - // analysis even though we don't need to, but that's ok since it will end 70.58 - // up with the same answer. 70.59 - InstanceKlass* ik = InstanceKlass::cast(current_klass()); 70.60 - Array<Klass*>* interfaces = ik->local_interfaces(); 70.61 - int num_interfaces = interfaces->length(); 70.62 - for (int index = 0; index < num_interfaces; index++) { 70.63 - if (interfaces->at(index) == resolved_klass()) { 70.64 - Method* method = DefaultMethods::find_super_default(current_klass(), 70.65 - resolved_klass(), method_name, method_signature, CHECK); 70.66 - resolved_method = methodHandle(THREAD, method); 70.67 - return; 70.68 - } 70.69 - } 70.70 - } 70.71 + // Invokespecial is called for multiple special reasons: 70.72 + // <init> 70.73 + // local private method invocation, for classes and interfaces 70.74 + // superclass.method, which can also resolve to a default method 70.75 + // and the selected method is recalculated relative to the direct superclass 70.76 + // superinterface.method, which explicitly does not check shadowing 70.77 70.78 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); 70.79 70.80 @@ -844,6 +853,26 @@ 70.81 resolved_method->signature())); 70.82 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 70.83 } 70.84 + if (TraceItables && Verbose) { 70.85 + ResourceMark rm(THREAD); 70.86 + tty->print("invokespecial resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", 70.87 + (current_klass.is_null() ? "<NULL>" : current_klass->internal_name()), 70.88 + (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), 70.89 + Method::name_and_sig_as_C_string(resolved_klass(), 70.90 + resolved_method->name(), 70.91 + resolved_method->signature()), 70.92 + resolved_method->method_holder()->internal_name() 70.93 + ); 70.94 + resolved_method->access_flags().print_on(tty); 70.95 + if (resolved_method->method_holder()->is_interface() && 70.96 + !resolved_method->is_abstract()) { 70.97 + tty->print("default"); 70.98 + } 70.99 + if (resolved_method->is_overpass()) { 70.100 + tty->print("overpass"); 70.101 + } 70.102 + tty->cr(); 70.103 + } 70.104 } 70.105 70.106 // throws runtime exceptions 70.107 @@ -851,23 +880,24 @@ 70.108 KlassHandle current_klass, bool check_access, TRAPS) { 70.109 70.110 // resolved method is selected method unless we have an old-style lookup 70.111 + // for a superclass method 70.112 + // Invokespecial for a superinterface, resolved method is selected method, 70.113 + // no checks for shadowing 70.114 methodHandle sel_method(THREAD, resolved_method()); 70.115 70.116 // check if this is an old-style super call and do a new lookup if so 70.117 { KlassHandle method_klass = KlassHandle(THREAD, 70.118 resolved_method->method_holder()); 70.119 70.120 - const bool direct_calling_default_method = 70.121 - resolved_klass() != NULL && resolved_method() != NULL && 70.122 - resolved_klass->is_interface() && !resolved_method->is_abstract(); 70.123 - 70.124 - if (!direct_calling_default_method && 70.125 - check_access && 70.126 + if (check_access && 70.127 // a) check if ACC_SUPER flag is set for the current class 70.128 (current_klass->is_super() || !AllowNonVirtualCalls) && 70.129 - // b) check if the method class is a superclass of the current class (superclass relation is not reflexive!) 70.130 - current_klass->is_subtype_of(method_klass()) && 70.131 - current_klass() != method_klass() && 70.132 + // b) check if the class of the resolved_klass is a superclass 70.133 + // (not supertype in order to exclude interface classes) of the current class. 70.134 + // This check is not performed for super.invoke for interface methods 70.135 + // in super interfaces. 70.136 + current_klass->is_subclass_of(resolved_klass()) && 70.137 + current_klass() != resolved_klass() && 70.138 // c) check if the method is not <init> 70.139 resolved_method->name() != vmSymbols::object_initializer_name()) { 70.140 // Lookup super method 70.141 @@ -905,6 +935,23 @@ 70.142 sel_method->signature())); 70.143 } 70.144 70.145 + if (TraceItables && Verbose) { 70.146 + ResourceMark rm(THREAD); 70.147 + tty->print("invokespecial selected method: resolved-class:%s, method:%s, method_holder:%s, access_flags: ", 70.148 + (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), 70.149 + Method::name_and_sig_as_C_string(resolved_klass(), 70.150 + sel_method->name(), 70.151 + sel_method->signature()), 70.152 + sel_method->method_holder()->internal_name() 70.153 + ); 70.154 + sel_method->access_flags().print_on(tty); 70.155 + if (sel_method->method_holder()->is_interface() && 70.156 + !sel_method->is_abstract()) { 70.157 + tty->print("default"); 70.158 + } 70.159 + tty->cr(); 70.160 + } 70.161 + 70.162 // setup result 70.163 result.set_static(resolved_klass, sel_method, CHECK); 70.164 } 70.165 @@ -927,6 +974,18 @@ 70.166 assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); 70.167 assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); 70.168 70.169 + // check if private interface method 70.170 + if (resolved_klass->is_interface() && resolved_method->is_private()) { 70.171 + ResourceMark rm(THREAD); 70.172 + char buf[200]; 70.173 + jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokevirtual: method %s, caller-class:%s", 70.174 + Method::name_and_sig_as_C_string(resolved_klass(), 70.175 + resolved_method->name(), 70.176 + resolved_method->signature()), 70.177 + (current_klass.is_null() ? "<NULL>" : current_klass->internal_name())); 70.178 + THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 70.179 + } 70.180 + 70.181 // check if not static 70.182 if (resolved_method->is_static()) { 70.183 ResourceMark rm(THREAD); 70.184 @@ -936,6 +995,27 @@ 70.185 resolved_method->signature())); 70.186 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 70.187 } 70.188 + 70.189 + if (PrintVtables && Verbose) { 70.190 + ResourceMark rm(THREAD); 70.191 + tty->print("invokevirtual resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", 70.192 + (current_klass.is_null() ? "<NULL>" : current_klass->internal_name()), 70.193 + (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), 70.194 + Method::name_and_sig_as_C_string(resolved_klass(), 70.195 + resolved_method->name(), 70.196 + resolved_method->signature()), 70.197 + resolved_method->method_holder()->internal_name() 70.198 + ); 70.199 + resolved_method->access_flags().print_on(tty); 70.200 + if (resolved_method->method_holder()->is_interface() && 70.201 + !resolved_method->is_abstract()) { 70.202 + tty->print("default"); 70.203 + } 70.204 + if (resolved_method->is_overpass()) { 70.205 + tty->print("overpass"); 70.206 + } 70.207 + tty->cr(); 70.208 + } 70.209 } 70.210 70.211 // throws runtime exceptions 70.212 @@ -1012,6 +1092,27 @@ 70.213 selected_method->signature())); 70.214 } 70.215 70.216 + if (PrintVtables && Verbose) { 70.217 + ResourceMark rm(THREAD); 70.218 + tty->print("invokevirtual selected method: receiver-class:%s, resolved-class:%s, method:%s, method_holder:%s, vtable_index:%d, access_flags: ", 70.219 + (recv_klass.is_null() ? "<NULL>" : recv_klass->internal_name()), 70.220 + (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), 70.221 + Method::name_and_sig_as_C_string(resolved_klass(), 70.222 + resolved_method->name(), 70.223 + resolved_method->signature()), 70.224 + selected_method->method_holder()->internal_name(), 70.225 + vtable_index 70.226 + ); 70.227 + selected_method->access_flags().print_on(tty); 70.228 + if (selected_method->method_holder()->is_interface() && 70.229 + !selected_method->is_abstract()) { 70.230 + tty->print("default"); 70.231 + } 70.232 + if (resolved_method->is_overpass()) { 70.233 + tty->print("overpass"); 70.234 + } 70.235 + tty->cr(); 70.236 + } 70.237 // setup result 70.238 result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK); 70.239 } 70.240 @@ -1042,6 +1143,17 @@ 70.241 THROW(vmSymbols::java_lang_NullPointerException()); 70.242 } 70.243 70.244 + // check if private interface method 70.245 + if (resolved_klass->is_interface() && resolved_method->is_private()) { 70.246 + ResourceMark rm(THREAD); 70.247 + char buf[200]; 70.248 + jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s", 70.249 + Method::name_and_sig_as_C_string(resolved_klass(), 70.250 + resolved_method->name(), 70.251 + resolved_method->signature())); 70.252 + THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); 70.253 + } 70.254 + 70.255 // check if receiver klass implements the resolved interface 70.256 if (!recv_klass->is_subtype_of(resolved_klass())) { 70.257 ResourceMark rm(THREAD); 70.258 @@ -1071,28 +1183,15 @@ 70.259 resolved_method->signature())); 70.260 } 70.261 // check access 70.262 - if (sel_method->method_holder()->is_interface()) { 70.263 - // Method holder is an interface. Throw Illegal Access Error if sel_method 70.264 - // is neither public nor private. 70.265 - if (!(sel_method->is_public() || sel_method->is_private())) { 70.266 - ResourceMark rm(THREAD); 70.267 - THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), 70.268 - Method::name_and_sig_as_C_string(recv_klass(), 70.269 - sel_method->name(), 70.270 - sel_method->signature())); 70.271 - } 70.272 + // Throw Illegal Access Error if sel_method is not public. 70.273 + if (!sel_method->is_public()) { 70.274 + ResourceMark rm(THREAD); 70.275 + THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), 70.276 + Method::name_and_sig_as_C_string(recv_klass(), 70.277 + sel_method->name(), 70.278 + sel_method->signature())); 70.279 } 70.280 - else { 70.281 - // Method holder is a class. Throw Illegal Access Error if sel_method 70.282 - // is not public. 70.283 - if (!sel_method->is_public()) { 70.284 - ResourceMark rm(THREAD); 70.285 - THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), 70.286 - Method::name_and_sig_as_C_string(recv_klass(), 70.287 - sel_method->name(), 70.288 - sel_method->signature())); 70.289 - } 70.290 - } 70.291 + 70.292 // check if abstract 70.293 if (check_null_and_abstract && sel_method->is_abstract()) { 70.294 ResourceMark rm(THREAD); 70.295 @@ -1109,6 +1208,27 @@ 70.296 return; 70.297 } 70.298 int itable_index = resolved_method()->itable_index(); 70.299 + 70.300 + if (TraceItables && Verbose) { 70.301 + ResourceMark rm(THREAD); 70.302 + tty->print("invokeinterface selected method: receiver-class:%s, resolved-class:%s, method:%s, method_holder:%s, access_flags: ", 70.303 + (recv_klass.is_null() ? "<NULL>" : recv_klass->internal_name()), 70.304 + (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), 70.305 + Method::name_and_sig_as_C_string(resolved_klass(), 70.306 + resolved_method->name(), 70.307 + resolved_method->signature()), 70.308 + sel_method->method_holder()->internal_name() 70.309 + ); 70.310 + sel_method->access_flags().print_on(tty); 70.311 + if (sel_method->method_holder()->is_interface() && 70.312 + !sel_method->is_abstract()) { 70.313 + tty->print("default"); 70.314 + } 70.315 + if (resolved_method->is_overpass()) { 70.316 + tty->print("overpass"); 70.317 + } 70.318 + tty->cr(); 70.319 + } 70.320 result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, itable_index, CHECK); 70.321 } 70.322 70.323 @@ -1384,7 +1504,7 @@ 70.324 THREAD); 70.325 if (HAS_PENDING_EXCEPTION) { 70.326 if (TraceMethodHandles) { 70.327 - tty->print_cr("invokedynamic throws BSME for "INTPTR_FORMAT, PENDING_EXCEPTION); 70.328 + tty->print_cr("invokedynamic throws BSME for "INTPTR_FORMAT, (void *)PENDING_EXCEPTION); 70.329 PENDING_EXCEPTION->print(); 70.330 } 70.331 if (PENDING_EXCEPTION->is_a(SystemDictionary::BootstrapMethodError_klass())) {
71.1 --- a/src/share/vm/memory/cardTableModRefBS.cpp Wed Oct 09 13:00:20 2013 +0200 71.2 +++ b/src/share/vm/memory/cardTableModRefBS.cpp Wed Oct 09 05:03:34 2013 -0700 71.3 @@ -423,60 +423,6 @@ 71.4 inline_write_ref_field(field, newVal); 71.5 } 71.6 71.7 -/* 71.8 - Claimed and deferred bits are used together in G1 during the evacuation 71.9 - pause. These bits can have the following state transitions: 71.10 - 1. The claimed bit can be put over any other card state. Except that 71.11 - the "dirty -> dirty and claimed" transition is checked for in 71.12 - G1 code and is not used. 71.13 - 2. Deferred bit can be set only if the previous state of the card 71.14 - was either clean or claimed. mark_card_deferred() is wait-free. 71.15 - We do not care if the operation is be successful because if 71.16 - it does not it will only result in duplicate entry in the update 71.17 - buffer because of the "cache-miss". So it's not worth spinning. 71.18 - */ 71.19 - 71.20 - 71.21 -bool CardTableModRefBS::claim_card(size_t card_index) { 71.22 - jbyte val = _byte_map[card_index]; 71.23 - assert(val != dirty_card_val(), "Shouldn't claim a dirty card"); 71.24 - while (val == clean_card_val() || 71.25 - (val & (clean_card_mask_val() | claimed_card_val())) != claimed_card_val()) { 71.26 - jbyte new_val = val; 71.27 - if (val == clean_card_val()) { 71.28 - new_val = (jbyte)claimed_card_val(); 71.29 - } else { 71.30 - new_val = val | (jbyte)claimed_card_val(); 71.31 - } 71.32 - jbyte res = Atomic::cmpxchg(new_val, &_byte_map[card_index], val); 71.33 - if (res == val) { 71.34 - return true; 71.35 - } 71.36 - val = res; 71.37 - } 71.38 - return false; 71.39 -} 71.40 - 71.41 -bool CardTableModRefBS::mark_card_deferred(size_t card_index) { 71.42 - jbyte val = _byte_map[card_index]; 71.43 - // It's already processed 71.44 - if ((val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val()) { 71.45 - return false; 71.46 - } 71.47 - // Cached bit can be installed either on a clean card or on a claimed card. 71.48 - jbyte new_val = val; 71.49 - if (val == clean_card_val()) { 71.50 - new_val = (jbyte)deferred_card_val(); 71.51 - } else { 71.52 - if (val & claimed_card_val()) { 71.53 - new_val = val | (jbyte)deferred_card_val(); 71.54 - } 71.55 - } 71.56 - if (new_val != val) { 71.57 - Atomic::cmpxchg(new_val, &_byte_map[card_index], val); 71.58 - } 71.59 - return true; 71.60 -} 71.61 71.62 void CardTableModRefBS::non_clean_card_iterate_possibly_parallel(Space* sp, 71.63 MemRegion mr,
72.1 --- a/src/share/vm/memory/cardTableModRefBS.hpp Wed Oct 09 13:00:20 2013 +0200 72.2 +++ b/src/share/vm/memory/cardTableModRefBS.hpp Wed Oct 09 05:03:34 2013 -0700 72.3 @@ -339,34 +339,10 @@ 72.4 _byte_map[card_index] = dirty_card_val(); 72.5 } 72.6 72.7 - bool is_card_claimed(size_t card_index) { 72.8 - jbyte val = _byte_map[card_index]; 72.9 - return (val & (clean_card_mask_val() | claimed_card_val())) == claimed_card_val(); 72.10 - } 72.11 - 72.12 - void set_card_claimed(size_t card_index) { 72.13 - jbyte val = _byte_map[card_index]; 72.14 - if (val == clean_card_val()) { 72.15 - val = (jbyte)claimed_card_val(); 72.16 - } else { 72.17 - val |= (jbyte)claimed_card_val(); 72.18 - } 72.19 - _byte_map[card_index] = val; 72.20 - } 72.21 - 72.22 - bool claim_card(size_t card_index); 72.23 - 72.24 bool is_card_clean(size_t card_index) { 72.25 return _byte_map[card_index] == clean_card_val(); 72.26 } 72.27 72.28 - bool is_card_deferred(size_t card_index) { 72.29 - jbyte val = _byte_map[card_index]; 72.30 - return (val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val(); 72.31 - } 72.32 - 72.33 - bool mark_card_deferred(size_t card_index); 72.34 - 72.35 // Card marking array base (adjusted for heap low boundary) 72.36 // This would be the 0th element of _byte_map, if the heap started at 0x0. 72.37 // But since the heap starts at some higher address, this points to somewhere
73.1 --- a/src/share/vm/memory/collectorPolicy.cpp Wed Oct 09 13:00:20 2013 +0200 73.2 +++ b/src/share/vm/memory/collectorPolicy.cpp Wed Oct 09 05:03:34 2013 -0700 73.3 @@ -64,19 +64,21 @@ 73.4 vm_exit_during_initialization("Incompatible initial and maximum heap sizes specified"); 73.5 } 73.6 73.7 - if (!is_size_aligned(MaxMetaspaceSize, max_alignment())) { 73.8 - FLAG_SET_ERGO(uintx, MaxMetaspaceSize, 73.9 - restricted_align_down(MaxMetaspaceSize, max_alignment())); 73.10 + // Do not use FLAG_SET_ERGO to update MaxMetaspaceSize, since this will 73.11 + // override if MaxMetaspaceSize was set on the command line or not. 73.12 + // This information is needed later to conform to the specification of the 73.13 + // java.lang.management.MemoryUsage API. 73.14 + // 73.15 + // Ideally, we would be able to set the default value of MaxMetaspaceSize in 73.16 + // globals.hpp to the aligned value, but this is not possible, since the 73.17 + // alignment depends on other flags being parsed. 73.18 + MaxMetaspaceSize = restricted_align_down(MaxMetaspaceSize, max_alignment()); 73.19 + 73.20 + if (MetaspaceSize > MaxMetaspaceSize) { 73.21 + MetaspaceSize = MaxMetaspaceSize; 73.22 } 73.23 73.24 - if (MetaspaceSize > MaxMetaspaceSize) { 73.25 - FLAG_SET_ERGO(uintx, MetaspaceSize, MaxMetaspaceSize); 73.26 - } 73.27 - 73.28 - if (!is_size_aligned(MetaspaceSize, min_alignment())) { 73.29 - FLAG_SET_ERGO(uintx, MetaspaceSize, 73.30 - restricted_align_down(MetaspaceSize, min_alignment())); 73.31 - } 73.32 + MetaspaceSize = restricted_align_down(MetaspaceSize, min_alignment()); 73.33 73.34 assert(MetaspaceSize <= MaxMetaspaceSize, "Must be"); 73.35 73.36 @@ -135,15 +137,8 @@ 73.37 73.38 GenRemSet* CollectorPolicy::create_rem_set(MemRegion whole_heap, 73.39 int max_covered_regions) { 73.40 - switch (rem_set_name()) { 73.41 - case GenRemSet::CardTable: { 73.42 - CardTableRS* res = new CardTableRS(whole_heap, max_covered_regions); 73.43 - return res; 73.44 - } 73.45 - default: 73.46 - guarantee(false, "unrecognized GenRemSet::Name"); 73.47 - return NULL; 73.48 - } 73.49 + assert(rem_set_name() == GenRemSet::CardTable, "unrecognized GenRemSet::Name"); 73.50 + return new CardTableRS(whole_heap, max_covered_regions); 73.51 } 73.52 73.53 void CollectorPolicy::cleared_all_soft_refs() {
74.1 --- a/src/share/vm/memory/gcLocker.cpp Wed Oct 09 13:00:20 2013 +0200 74.2 +++ b/src/share/vm/memory/gcLocker.cpp Wed Oct 09 05:03:34 2013 -0700 74.3 @@ -122,7 +122,7 @@ 74.4 // strictly needed. It's added here to make it clear that 74.5 // the GC will NOT be performed if any other caller 74.6 // of GC_locker::lock() still needs GC locked. 74.7 - if (!is_active()) { 74.8 + if (!is_active_internal()) { 74.9 _doing_gc = true; 74.10 { 74.11 // Must give up the lock while at a safepoint
75.1 --- a/src/share/vm/memory/gcLocker.hpp Wed Oct 09 13:00:20 2013 +0200 75.2 +++ b/src/share/vm/memory/gcLocker.hpp Wed Oct 09 05:03:34 2013 -0700 75.3 @@ -88,7 +88,7 @@ 75.4 public: 75.5 // Accessors 75.6 static bool is_active() { 75.7 - assert(_needs_gc || SafepointSynchronize::is_at_safepoint(), "only read at safepoint"); 75.8 + assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint"); 75.9 return is_active_internal(); 75.10 } 75.11 static bool needs_gc() { return _needs_gc; }
76.1 --- a/src/share/vm/memory/genRemSet.cpp Wed Oct 09 13:00:20 2013 +0200 76.2 +++ b/src/share/vm/memory/genRemSet.cpp Wed Oct 09 05:03:34 2013 -0700 76.3 @@ -32,13 +32,8 @@ 76.4 // enumeration.) 76.5 76.6 uintx GenRemSet::max_alignment_constraint(Name nm) { 76.7 - switch (nm) { 76.8 - case GenRemSet::CardTable: 76.9 - return CardTableRS::ct_max_alignment_constraint(); 76.10 - default: 76.11 - guarantee(false, "Unrecognized GenRemSet type."); 76.12 - return (0); // Make Windows compiler happy 76.13 - } 76.14 + assert(nm == GenRemSet::CardTable, "Unrecognized GenRemSet type."); 76.15 + return CardTableRS::ct_max_alignment_constraint(); 76.16 } 76.17 76.18 class HasAccumulatedModifiedOopsClosure : public KlassClosure {
77.1 --- a/src/share/vm/memory/heapInspection.hpp Wed Oct 09 13:00:20 2013 +0200 77.2 +++ b/src/share/vm/memory/heapInspection.hpp Wed Oct 09 05:03:34 2013 -0700 77.3 @@ -150,11 +150,11 @@ 77.4 HEAP_INSPECTION_COLUMNS_DO(DECLARE_KLASS_SIZE_STATS_FIELD) 77.5 77.6 static int count(oop x) { 77.7 - return (HeapWordSize * ((x) ? (x)->size() : 0)); 77.8 + return (HeapWordSize * (((x) != NULL) ? (x)->size() : 0)); 77.9 } 77.10 77.11 static int count_array(objArrayOop x) { 77.12 - return (HeapWordSize * ((x) ? (x)->size() : 0)); 77.13 + return (HeapWordSize * (((x) != NULL) ? (x)->size() : 0)); 77.14 } 77.15 77.16 template <class T> static int count(T* x) {
78.1 --- a/src/share/vm/memory/metaspace.cpp Wed Oct 09 13:00:20 2013 +0200 78.2 +++ b/src/share/vm/memory/metaspace.cpp Wed Oct 09 05:03:34 2013 -0700 78.3 @@ -23,6 +23,7 @@ 78.4 */ 78.5 #include "precompiled.hpp" 78.6 #include "gc_interface/collectedHeap.hpp" 78.7 +#include "memory/allocation.hpp" 78.8 #include "memory/binaryTreeDictionary.hpp" 78.9 #include "memory/freeList.hpp" 78.10 #include "memory/collectorPolicy.hpp" 78.11 @@ -111,7 +112,7 @@ 78.12 // Has three lists of free chunks, and a total size and 78.13 // count that includes all three 78.14 78.15 -class ChunkManager VALUE_OBJ_CLASS_SPEC { 78.16 +class ChunkManager : public CHeapObj<mtInternal> { 78.17 78.18 // Free list of chunks of different sizes. 78.19 // SpecializedChunk 78.20 @@ -158,7 +159,12 @@ 78.21 78.22 public: 78.23 78.24 - ChunkManager() : _free_chunks_total(0), _free_chunks_count(0) {} 78.25 + ChunkManager(size_t specialized_size, size_t small_size, size_t medium_size) 78.26 + : _free_chunks_total(0), _free_chunks_count(0) { 78.27 + _free_chunks[SpecializedIndex].set_size(specialized_size); 78.28 + _free_chunks[SmallIndex].set_size(small_size); 78.29 + _free_chunks[MediumIndex].set_size(medium_size); 78.30 + } 78.31 78.32 // add or delete (return) a chunk to the global freelist. 78.33 Metachunk* chunk_freelist_allocate(size_t word_size); 78.34 @@ -219,7 +225,7 @@ 78.35 void locked_print_free_chunks(outputStream* st); 78.36 void locked_print_sum_free_chunks(outputStream* st); 78.37 78.38 - void print_on(outputStream* st); 78.39 + void print_on(outputStream* st) const; 78.40 }; 78.41 78.42 // Used to manage the free list of Metablocks (a block corresponds 78.43 @@ -276,11 +282,6 @@ 78.44 // VirtualSpace 78.45 Metachunk* first_chunk() { return (Metachunk*) bottom(); } 78.46 78.47 - void inc_container_count(); 78.48 -#ifdef ASSERT 78.49 - uint container_count_slow(); 78.50 -#endif 78.51 - 78.52 public: 78.53 78.54 VirtualSpaceNode(size_t byte_size); 78.55 @@ -314,8 +315,10 @@ 78.56 void inc_top(size_t word_size) { _top += word_size; } 78.57 78.58 uintx container_count() { return _container_count; } 78.59 + void inc_container_count(); 78.60 void dec_container_count(); 78.61 #ifdef ASSERT 78.62 + uint container_count_slow(); 78.63 void verify_container_count(); 78.64 #endif 78.65 78.66 @@ -421,8 +424,6 @@ 78.67 VirtualSpaceNode* _virtual_space_list; 78.68 // virtual space currently being used for allocations 78.69 VirtualSpaceNode* _current_virtual_space; 78.70 - // Free chunk list for all other metadata 78.71 - ChunkManager _chunk_manager; 78.72 78.73 // Can this virtual list allocate >1 spaces? Also, used to determine 78.74 // whether to allocate unlimited small chunks in this virtual space 78.75 @@ -475,7 +476,6 @@ 78.76 return _current_virtual_space; 78.77 } 78.78 78.79 - ChunkManager* chunk_manager() { return &_chunk_manager; } 78.80 bool is_class() const { return _is_class; } 78.81 78.82 // Allocate the first virtualspace. 78.83 @@ -494,14 +494,7 @@ 78.84 void dec_virtual_space_count(); 78.85 78.86 // Unlink empty VirtualSpaceNodes and free it. 78.87 - void purge(); 78.88 - 78.89 - // Used and capacity in the entire list of virtual spaces. 78.90 - // These are global values shared by all Metaspaces 78.91 - size_t capacity_words_sum(); 78.92 - size_t capacity_bytes_sum() { return capacity_words_sum() * BytesPerWord; } 78.93 - size_t used_words_sum(); 78.94 - size_t used_bytes_sum() { return used_words_sum() * BytesPerWord; } 78.95 + void purge(ChunkManager* chunk_manager); 78.96 78.97 bool contains(const void *ptr); 78.98 78.99 @@ -582,18 +575,12 @@ 78.100 // Type of metadata allocated. 78.101 Metaspace::MetadataType _mdtype; 78.102 78.103 - // Chunk related size 78.104 - size_t _medium_chunk_bunch; 78.105 - 78.106 // List of chunks in use by this SpaceManager. Allocations 78.107 // are done from the current chunk. The list is used for deallocating 78.108 // chunks when the SpaceManager is freed. 78.109 Metachunk* _chunks_in_use[NumberOfInUseLists]; 78.110 Metachunk* _current_chunk; 78.111 78.112 - // Virtual space where allocation comes from. 78.113 - VirtualSpaceList* _vs_list; 78.114 - 78.115 // Number of small chunks to allocate to a manager 78.116 // If class space manager, small chunks are unlimited 78.117 static uint const _small_chunk_limit; 78.118 @@ -626,7 +613,9 @@ 78.119 } 78.120 78.121 Metaspace::MetadataType mdtype() { return _mdtype; } 78.122 - VirtualSpaceList* vs_list() const { return _vs_list; } 78.123 + 78.124 + VirtualSpaceList* vs_list() const { return Metaspace::get_space_list(_mdtype); } 78.125 + ChunkManager* chunk_manager() const { return Metaspace::get_chunk_manager(_mdtype); } 78.126 78.127 Metachunk* current_chunk() const { return _current_chunk; } 78.128 void set_current_chunk(Metachunk* v) { 78.129 @@ -648,18 +637,19 @@ 78.130 78.131 public: 78.132 SpaceManager(Metaspace::MetadataType mdtype, 78.133 - Mutex* lock, 78.134 - VirtualSpaceList* vs_list); 78.135 + Mutex* lock); 78.136 ~SpaceManager(); 78.137 78.138 enum ChunkMultiples { 78.139 MediumChunkMultiple = 4 78.140 }; 78.141 78.142 + bool is_class() { return _mdtype == Metaspace::ClassType; } 78.143 + 78.144 // Accessors 78.145 size_t specialized_chunk_size() { return SpecializedChunk; } 78.146 - size_t small_chunk_size() { return (size_t) vs_list()->is_class() ? ClassSmallChunk : SmallChunk; } 78.147 - size_t medium_chunk_size() { return (size_t) vs_list()->is_class() ? ClassMediumChunk : MediumChunk; } 78.148 + size_t small_chunk_size() { return (size_t) is_class() ? ClassSmallChunk : SmallChunk; } 78.149 + size_t medium_chunk_size() { return (size_t) is_class() ? ClassMediumChunk : MediumChunk; } 78.150 size_t medium_chunk_bunch() { return medium_chunk_size() * MediumChunkMultiple; } 78.151 78.152 size_t allocated_blocks_words() const { return _allocated_blocks_words; } 78.153 @@ -762,7 +752,7 @@ 78.154 _container_count++; 78.155 assert(_container_count == container_count_slow(), 78.156 err_msg("Inconsistency in countainer_count _container_count " SIZE_FORMAT 78.157 - "container_count_slow() " SIZE_FORMAT, 78.158 + " container_count_slow() " SIZE_FORMAT, 78.159 _container_count, container_count_slow())); 78.160 } 78.161 78.162 @@ -775,7 +765,7 @@ 78.163 void VirtualSpaceNode::verify_container_count() { 78.164 assert(_container_count == container_count_slow(), 78.165 err_msg("Inconsistency in countainer_count _container_count " SIZE_FORMAT 78.166 - "container_count_slow() " SIZE_FORMAT, _container_count, container_count_slow())); 78.167 + " container_count_slow() " SIZE_FORMAT, _container_count, container_count_slow())); 78.168 } 78.169 #endif 78.170 78.171 @@ -1020,7 +1010,7 @@ 78.172 // Walk the list of VirtualSpaceNodes and delete 78.173 // nodes with a 0 container_count. Remove Metachunks in 78.174 // the node from their respective freelists. 78.175 -void VirtualSpaceList::purge() { 78.176 +void VirtualSpaceList::purge(ChunkManager* chunk_manager) { 78.177 assert_lock_strong(SpaceManager::expand_lock()); 78.178 // Don't use a VirtualSpaceListIterator because this 78.179 // list is being changed and a straightforward use of an iterator is not safe. 78.180 @@ -1042,7 +1032,7 @@ 78.181 prev_vsl->set_next(vsl->next()); 78.182 } 78.183 78.184 - vsl->purge(chunk_manager()); 78.185 + vsl->purge(chunk_manager); 78.186 dec_reserved_words(vsl->reserved_words()); 78.187 dec_committed_words(vsl->committed_words()); 78.188 dec_virtual_space_count(); 78.189 @@ -1064,36 +1054,6 @@ 78.190 #endif 78.191 } 78.192 78.193 -size_t VirtualSpaceList::used_words_sum() { 78.194 - size_t allocated_by_vs = 0; 78.195 - VirtualSpaceListIterator iter(virtual_space_list()); 78.196 - while (iter.repeat()) { 78.197 - VirtualSpaceNode* vsl = iter.get_next(); 78.198 - // Sum used region [bottom, top) in each virtualspace 78.199 - allocated_by_vs += vsl->used_words_in_vs(); 78.200 - } 78.201 - assert(allocated_by_vs >= chunk_manager()->free_chunks_total_words(), 78.202 - err_msg("Total in free chunks " SIZE_FORMAT 78.203 - " greater than total from virtual_spaces " SIZE_FORMAT, 78.204 - allocated_by_vs, chunk_manager()->free_chunks_total_words())); 78.205 - size_t used = 78.206 - allocated_by_vs - chunk_manager()->free_chunks_total_words(); 78.207 - return used; 78.208 -} 78.209 - 78.210 -// Space available in all MetadataVirtualspaces allocated 78.211 -// for metadata. This is the upper limit on the capacity 78.212 -// of chunks allocated out of all the MetadataVirtualspaces. 78.213 -size_t VirtualSpaceList::capacity_words_sum() { 78.214 - size_t capacity = 0; 78.215 - VirtualSpaceListIterator iter(virtual_space_list()); 78.216 - while (iter.repeat()) { 78.217 - VirtualSpaceNode* vsl = iter.get_next(); 78.218 - capacity += vsl->capacity_words_in_vs(); 78.219 - } 78.220 - return capacity; 78.221 -} 78.222 - 78.223 VirtualSpaceList::VirtualSpaceList(size_t word_size ) : 78.224 _is_class(false), 78.225 _virtual_space_list(NULL), 78.226 @@ -1104,10 +1064,6 @@ 78.227 MutexLockerEx cl(SpaceManager::expand_lock(), 78.228 Mutex::_no_safepoint_check_flag); 78.229 bool initialization_succeeded = grow_vs(word_size); 78.230 - 78.231 - _chunk_manager.free_chunks(SpecializedIndex)->set_size(SpecializedChunk); 78.232 - _chunk_manager.free_chunks(SmallIndex)->set_size(SmallChunk); 78.233 - _chunk_manager.free_chunks(MediumIndex)->set_size(MediumChunk); 78.234 assert(initialization_succeeded, 78.235 " VirtualSpaceList initialization should not fail"); 78.236 } 78.237 @@ -1123,9 +1079,6 @@ 78.238 Mutex::_no_safepoint_check_flag); 78.239 VirtualSpaceNode* class_entry = new VirtualSpaceNode(rs); 78.240 bool succeeded = class_entry->initialize(); 78.241 - _chunk_manager.free_chunks(SpecializedIndex)->set_size(SpecializedChunk); 78.242 - _chunk_manager.free_chunks(SmallIndex)->set_size(ClassSmallChunk); 78.243 - _chunk_manager.free_chunks(MediumIndex)->set_size(ClassMediumChunk); 78.244 assert(succeeded, " VirtualSpaceList initialization should not fail"); 78.245 link_vs(class_entry); 78.246 } 78.247 @@ -1142,7 +1095,7 @@ 78.248 } 78.249 // Reserve the space 78.250 size_t vs_byte_size = vs_word_size * BytesPerWord; 78.251 - assert(vs_byte_size % os::vm_page_size() == 0, "Not aligned"); 78.252 + assert(vs_byte_size % os::vm_allocation_granularity() == 0, "Not aligned"); 78.253 78.254 // Allocate the meta virtual space and initialize it. 78.255 VirtualSpaceNode* new_entry = new VirtualSpaceNode(vs_byte_size); 78.256 @@ -1195,15 +1148,8 @@ 78.257 size_t grow_chunks_by_words, 78.258 size_t medium_chunk_bunch) { 78.259 78.260 - // Get a chunk from the chunk freelist 78.261 - Metachunk* next = chunk_manager()->chunk_freelist_allocate(grow_chunks_by_words); 78.262 - 78.263 - if (next != NULL) { 78.264 - next->container()->inc_container_count(); 78.265 - } else { 78.266 - // Allocate a chunk out of the current virtual space. 78.267 - next = current_virtual_space()->get_chunk_vs(grow_chunks_by_words); 78.268 - } 78.269 + // Allocate a chunk out of the current virtual space. 78.270 + Metachunk* next = current_virtual_space()->get_chunk_vs(grow_chunks_by_words); 78.271 78.272 if (next == NULL) { 78.273 // Not enough room in current virtual space. Try to commit 78.274 @@ -1221,12 +1167,14 @@ 78.275 // being used for CompressedHeaders, don't allocate a new virtualspace. 78.276 if (can_grow() && MetaspaceGC::should_expand(this, word_size)) { 78.277 // Get another virtual space. 78.278 - size_t grow_vs_words = 78.279 - MAX2((size_t)VirtualSpaceSize, aligned_expand_vs_by_words); 78.280 + size_t allocation_aligned_expand_words = 78.281 + align_size_up(aligned_expand_vs_by_words, os::vm_allocation_granularity() / BytesPerWord); 78.282 + size_t grow_vs_words = 78.283 + MAX2((size_t)VirtualSpaceSize, allocation_aligned_expand_words); 78.284 if (grow_vs(grow_vs_words)) { 78.285 // Got it. It's on the list now. Get a chunk from it. 78.286 assert(current_virtual_space()->expanded_words() == 0, 78.287 - "New virtuals space nodes should not have expanded"); 78.288 + "New virtual space nodes should not have expanded"); 78.289 78.290 size_t grow_chunks_by_words_aligned = align_size_up(grow_chunks_by_words, 78.291 page_size_words); 78.292 @@ -1342,8 +1290,9 @@ 78.293 // reserved space, because this is a larger space prereserved for compressed 78.294 // class pointers. 78.295 if (!FLAG_IS_DEFAULT(MaxMetaspaceSize)) { 78.296 - size_t real_allocated = Metaspace::space_list()->reserved_words() + 78.297 - MetaspaceAux::allocated_capacity_bytes(Metaspace::ClassType); 78.298 + size_t nonclass_allocated = MetaspaceAux::reserved_bytes(Metaspace::NonClassType); 78.299 + size_t class_allocated = MetaspaceAux::allocated_capacity_bytes(Metaspace::ClassType); 78.300 + size_t real_allocated = nonclass_allocated + class_allocated; 78.301 if (real_allocated >= MaxMetaspaceSize) { 78.302 return false; 78.303 } 78.304 @@ -1536,15 +1485,15 @@ 78.305 if (dummy_chunk == NULL) { 78.306 break; 78.307 } 78.308 - vsl->chunk_manager()->chunk_freelist_deallocate(dummy_chunk); 78.309 + sm->chunk_manager()->chunk_freelist_deallocate(dummy_chunk); 78.310 78.311 if (TraceMetadataChunkAllocation && Verbose) { 78.312 gclog_or_tty->print("Metadebug::deallocate_chunk_a_lot: %d) ", 78.313 sm->sum_count_in_chunks_in_use()); 78.314 dummy_chunk->print_on(gclog_or_tty); 78.315 gclog_or_tty->print_cr(" Free chunks total %d count %d", 78.316 - vsl->chunk_manager()->free_chunks_total_words(), 78.317 - vsl->chunk_manager()->free_chunks_count()); 78.318 + sm->chunk_manager()->free_chunks_total_words(), 78.319 + sm->chunk_manager()->free_chunks_count()); 78.320 } 78.321 } 78.322 } else { 78.323 @@ -1796,6 +1745,8 @@ 78.324 // work. 78.325 chunk->set_is_free(false); 78.326 #endif 78.327 + chunk->container()->inc_container_count(); 78.328 + 78.329 slow_locked_verify(); 78.330 return chunk; 78.331 } 78.332 @@ -1830,9 +1781,9 @@ 78.333 return chunk; 78.334 } 78.335 78.336 -void ChunkManager::print_on(outputStream* out) { 78.337 +void ChunkManager::print_on(outputStream* out) const { 78.338 if (PrintFLSStatistics != 0) { 78.339 - humongous_dictionary()->report_statistics(); 78.340 + const_cast<ChunkManager *>(this)->humongous_dictionary()->report_statistics(); 78.341 } 78.342 } 78.343 78.344 @@ -1979,8 +1930,8 @@ 78.345 } 78.346 } 78.347 78.348 - vs_list()->chunk_manager()->locked_print_free_chunks(st); 78.349 - vs_list()->chunk_manager()->locked_print_sum_free_chunks(st); 78.350 + chunk_manager()->locked_print_free_chunks(st); 78.351 + chunk_manager()->locked_print_sum_free_chunks(st); 78.352 } 78.353 78.354 size_t SpaceManager::calc_chunk_size(size_t word_size) { 78.355 @@ -2084,9 +2035,7 @@ 78.356 } 78.357 78.358 SpaceManager::SpaceManager(Metaspace::MetadataType mdtype, 78.359 - Mutex* lock, 78.360 - VirtualSpaceList* vs_list) : 78.361 - _vs_list(vs_list), 78.362 + Mutex* lock) : 78.363 _mdtype(mdtype), 78.364 _allocated_blocks_words(0), 78.365 _allocated_chunks_words(0), 78.366 @@ -2172,9 +2121,7 @@ 78.367 MutexLockerEx fcl(SpaceManager::expand_lock(), 78.368 Mutex::_no_safepoint_check_flag); 78.369 78.370 - ChunkManager* chunk_manager = vs_list()->chunk_manager(); 78.371 - 78.372 - chunk_manager->slow_locked_verify(); 78.373 + chunk_manager()->slow_locked_verify(); 78.374 78.375 dec_total_from_size_metrics(); 78.376 78.377 @@ -2188,8 +2135,8 @@ 78.378 78.379 // Have to update before the chunks_in_use lists are emptied 78.380 // below. 78.381 - chunk_manager->inc_free_chunks_total(allocated_chunks_words(), 78.382 - sum_count_in_chunks_in_use()); 78.383 + chunk_manager()->inc_free_chunks_total(allocated_chunks_words(), 78.384 + sum_count_in_chunks_in_use()); 78.385 78.386 // Add all the chunks in use by this space manager 78.387 // to the global list of free chunks. 78.388 @@ -2204,11 +2151,11 @@ 78.389 chunk_size_name(i)); 78.390 } 78.391 Metachunk* chunks = chunks_in_use(i); 78.392 - chunk_manager->return_chunks(i, chunks); 78.393 + chunk_manager()->return_chunks(i, chunks); 78.394 set_chunks_in_use(i, NULL); 78.395 if (TraceMetadataChunkAllocation && Verbose) { 78.396 gclog_or_tty->print_cr("updated freelist count %d %s", 78.397 - chunk_manager->free_chunks(i)->count(), 78.398 + chunk_manager()->free_chunks(i)->count(), 78.399 chunk_size_name(i)); 78.400 } 78.401 assert(i != HumongousIndex, "Humongous chunks are handled explicitly later"); 78.402 @@ -2245,16 +2192,16 @@ 78.403 humongous_chunks->word_size(), HumongousChunkGranularity)); 78.404 Metachunk* next_humongous_chunks = humongous_chunks->next(); 78.405 humongous_chunks->container()->dec_container_count(); 78.406 - chunk_manager->humongous_dictionary()->return_chunk(humongous_chunks); 78.407 + chunk_manager()->humongous_dictionary()->return_chunk(humongous_chunks); 78.408 humongous_chunks = next_humongous_chunks; 78.409 } 78.410 if (TraceMetadataChunkAllocation && Verbose) { 78.411 gclog_or_tty->print_cr(""); 78.412 gclog_or_tty->print_cr("updated dictionary count %d %s", 78.413 - chunk_manager->humongous_dictionary()->total_count(), 78.414 + chunk_manager()->humongous_dictionary()->total_count(), 78.415 chunk_size_name(HumongousIndex)); 78.416 } 78.417 - chunk_manager->slow_locked_verify(); 78.418 + chunk_manager()->slow_locked_verify(); 78.419 } 78.420 78.421 const char* SpaceManager::chunk_size_name(ChunkIndex index) const { 78.422 @@ -2343,9 +2290,7 @@ 78.423 gclog_or_tty->print("SpaceManager::add_chunk: %d) ", 78.424 sum_count_in_chunks_in_use()); 78.425 new_chunk->print_on(gclog_or_tty); 78.426 - if (vs_list() != NULL) { 78.427 - vs_list()->chunk_manager()->locked_print_free_chunks(gclog_or_tty); 78.428 - } 78.429 + chunk_manager()->locked_print_free_chunks(gclog_or_tty); 78.430 } 78.431 } 78.432 78.433 @@ -2361,10 +2306,14 @@ 78.434 78.435 Metachunk* SpaceManager::get_new_chunk(size_t word_size, 78.436 size_t grow_chunks_by_words) { 78.437 - 78.438 - Metachunk* next = vs_list()->get_new_chunk(word_size, 78.439 - grow_chunks_by_words, 78.440 - medium_chunk_bunch()); 78.441 + // Get a chunk from the chunk freelist 78.442 + Metachunk* next = chunk_manager()->chunk_freelist_allocate(grow_chunks_by_words); 78.443 + 78.444 + if (next == NULL) { 78.445 + next = vs_list()->get_new_chunk(word_size, 78.446 + grow_chunks_by_words, 78.447 + medium_chunk_bunch()); 78.448 + } 78.449 78.450 if (TraceMetadataHumongousAllocation && next != NULL && 78.451 SpaceManager::is_humongous(next->word_size())) { 78.452 @@ -2644,13 +2593,12 @@ 78.453 size_t MetaspaceAux::min_chunk_size_words() { return Metaspace::first_chunk_word_size(); } 78.454 78.455 size_t MetaspaceAux::free_chunks_total_words(Metaspace::MetadataType mdtype) { 78.456 - VirtualSpaceList* list = Metaspace::get_space_list(mdtype); 78.457 - if (list == NULL) { 78.458 + ChunkManager* chunk_manager = Metaspace::get_chunk_manager(mdtype); 78.459 + if (chunk_manager == NULL) { 78.460 return 0; 78.461 } 78.462 - ChunkManager* chunk = list->chunk_manager(); 78.463 - chunk->slow_verify(); 78.464 - return chunk->free_chunks_total_words(); 78.465 + chunk_manager->slow_verify(); 78.466 + return chunk_manager->free_chunks_total_words(); 78.467 } 78.468 78.469 size_t MetaspaceAux::free_chunks_total_bytes(Metaspace::MetadataType mdtype) { 78.470 @@ -2801,9 +2749,9 @@ 78.471 } 78.472 78.473 void MetaspaceAux::verify_free_chunks() { 78.474 - Metaspace::space_list()->chunk_manager()->verify(); 78.475 + Metaspace::chunk_manager_metadata()->verify(); 78.476 if (Metaspace::using_class_space()) { 78.477 - Metaspace::class_space_list()->chunk_manager()->verify(); 78.478 + Metaspace::chunk_manager_class()->verify(); 78.479 } 78.480 } 78.481 78.482 @@ -2874,6 +2822,9 @@ 78.483 VirtualSpaceList* Metaspace::_space_list = NULL; 78.484 VirtualSpaceList* Metaspace::_class_space_list = NULL; 78.485 78.486 +ChunkManager* Metaspace::_chunk_manager_metadata = NULL; 78.487 +ChunkManager* Metaspace::_chunk_manager_class = NULL; 78.488 + 78.489 #define VIRTUALSPACEMULTIPLIER 2 78.490 78.491 #ifdef _LP64 78.492 @@ -2981,6 +2932,7 @@ 78.493 err_msg(SIZE_FORMAT " != " UINTX_FORMAT, rs.size(), CompressedClassSpaceSize)); 78.494 assert(using_class_space(), "Must be using class space"); 78.495 _class_space_list = new VirtualSpaceList(rs); 78.496 + _chunk_manager_class = new ChunkManager(SpecializedChunk, ClassSmallChunk, ClassMediumChunk); 78.497 } 78.498 78.499 #endif 78.500 @@ -3006,6 +2958,7 @@ 78.501 // remainder is the misc code and data chunks. 78.502 cds_total = FileMapInfo::shared_spaces_size(); 78.503 _space_list = new VirtualSpaceList(cds_total/wordSize); 78.504 + _chunk_manager_metadata = new ChunkManager(SpecializedChunk, SmallChunk, MediumChunk); 78.505 78.506 #ifdef _LP64 78.507 // Set the compressed klass pointer base so that decoding of these pointers works 78.508 @@ -3073,15 +3026,30 @@ 78.509 size_t word_size = VIRTUALSPACEMULTIPLIER * first_chunk_word_size(); 78.510 // Initialize the list of virtual spaces. 78.511 _space_list = new VirtualSpaceList(word_size); 78.512 + _chunk_manager_metadata = new ChunkManager(SpecializedChunk, SmallChunk, MediumChunk); 78.513 } 78.514 } 78.515 78.516 +Metachunk* Metaspace::get_initialization_chunk(MetadataType mdtype, 78.517 + size_t chunk_word_size, 78.518 + size_t chunk_bunch) { 78.519 + // Get a chunk from the chunk freelist 78.520 + Metachunk* chunk = get_chunk_manager(mdtype)->chunk_freelist_allocate(chunk_word_size); 78.521 + if (chunk != NULL) { 78.522 + return chunk; 78.523 + } 78.524 + 78.525 + return get_space_list(mdtype)->get_initialization_chunk(chunk_word_size, chunk_bunch); 78.526 +} 78.527 + 78.528 void Metaspace::initialize(Mutex* lock, MetaspaceType type) { 78.529 78.530 assert(space_list() != NULL, 78.531 "Metadata VirtualSpaceList has not been initialized"); 78.532 - 78.533 - _vsm = new SpaceManager(NonClassType, lock, space_list()); 78.534 + assert(chunk_manager_metadata() != NULL, 78.535 + "Metadata ChunkManager has not been initialized"); 78.536 + 78.537 + _vsm = new SpaceManager(NonClassType, lock); 78.538 if (_vsm == NULL) { 78.539 return; 78.540 } 78.541 @@ -3090,11 +3058,13 @@ 78.542 vsm()->get_initial_chunk_sizes(type, &word_size, &class_word_size); 78.543 78.544 if (using_class_space()) { 78.545 - assert(class_space_list() != NULL, 78.546 - "Class VirtualSpaceList has not been initialized"); 78.547 + assert(class_space_list() != NULL, 78.548 + "Class VirtualSpaceList has not been initialized"); 78.549 + assert(chunk_manager_class() != NULL, 78.550 + "Class ChunkManager has not been initialized"); 78.551 78.552 // Allocate SpaceManager for classes. 78.553 - _class_vsm = new SpaceManager(ClassType, lock, class_space_list()); 78.554 + _class_vsm = new SpaceManager(ClassType, lock); 78.555 if (_class_vsm == NULL) { 78.556 return; 78.557 } 78.558 @@ -3103,9 +3073,9 @@ 78.559 MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); 78.560 78.561 // Allocate chunk for metadata objects 78.562 - Metachunk* new_chunk = 78.563 - space_list()->get_initialization_chunk(word_size, 78.564 - vsm()->medium_chunk_bunch()); 78.565 + Metachunk* new_chunk = get_initialization_chunk(NonClassType, 78.566 + word_size, 78.567 + vsm()->medium_chunk_bunch()); 78.568 assert(!DumpSharedSpaces || new_chunk != NULL, "should have enough space for both chunks"); 78.569 if (new_chunk != NULL) { 78.570 // Add to this manager's list of chunks in use and current_chunk(). 78.571 @@ -3114,9 +3084,9 @@ 78.572 78.573 // Allocate chunk for class metadata objects 78.574 if (using_class_space()) { 78.575 - Metachunk* class_chunk = 78.576 - class_space_list()->get_initialization_chunk(class_word_size, 78.577 - class_vsm()->medium_chunk_bunch()); 78.578 + Metachunk* class_chunk = get_initialization_chunk(ClassType, 78.579 + class_word_size, 78.580 + class_vsm()->medium_chunk_bunch()); 78.581 if (class_chunk != NULL) { 78.582 class_vsm()->add_chunk(class_chunk, true); 78.583 } 78.584 @@ -3134,7 +3104,7 @@ 78.585 MetaWord* Metaspace::allocate(size_t word_size, MetadataType mdtype) { 78.586 // DumpSharedSpaces doesn't use class metadata area (yet) 78.587 // Also, don't use class_vsm() unless UseCompressedClassPointers is true. 78.588 - if (mdtype == ClassType && using_class_space()) { 78.589 + if (is_class_space_allocation(mdtype)) { 78.590 return class_vsm()->allocate(word_size); 78.591 } else { 78.592 return vsm()->allocate(word_size); 78.593 @@ -3282,8 +3252,8 @@ 78.594 MetaspaceAux::dump(gclog_or_tty); 78.595 } 78.596 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support 78.597 - const char* space_string = (mdtype == ClassType) ? "Compressed class space" : 78.598 - "Metadata space"; 78.599 + const char* space_string = is_class_space_allocation(mdtype) ? "Compressed class space" : 78.600 + "Metadata space"; 78.601 report_java_out_of_memory(space_string); 78.602 78.603 if (JvmtiExport::should_post_resource_exhausted()) { 78.604 @@ -3291,7 +3261,7 @@ 78.605 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR, 78.606 space_string); 78.607 } 78.608 - if (mdtype == ClassType) { 78.609 + if (is_class_space_allocation(mdtype)) { 78.610 THROW_OOP_0(Universe::out_of_memory_error_class_metaspace()); 78.611 } else { 78.612 THROW_OOP_0(Universe::out_of_memory_error_metaspace()); 78.613 @@ -3333,12 +3303,16 @@ 78.614 } 78.615 } 78.616 78.617 +void Metaspace::purge(MetadataType mdtype) { 78.618 + get_space_list(mdtype)->purge(get_chunk_manager(mdtype)); 78.619 +} 78.620 + 78.621 void Metaspace::purge() { 78.622 MutexLockerEx cl(SpaceManager::expand_lock(), 78.623 Mutex::_no_safepoint_check_flag); 78.624 - space_list()->purge(); 78.625 + purge(NonClassType); 78.626 if (using_class_space()) { 78.627 - class_space_list()->purge(); 78.628 + purge(ClassType); 78.629 } 78.630 } 78.631 78.632 @@ -3385,7 +3359,7 @@ 78.633 78.634 #ifndef PRODUCT 78.635 78.636 -class MetaspaceAuxTest : AllStatic { 78.637 +class TestMetaspaceAuxTest : AllStatic { 78.638 public: 78.639 static void test_reserved() { 78.640 size_t reserved = MetaspaceAux::reserved_bytes(); 78.641 @@ -3425,14 +3399,25 @@ 78.642 } 78.643 } 78.644 78.645 + static void test_virtual_space_list_large_chunk() { 78.646 + VirtualSpaceList* vs_list = new VirtualSpaceList(os::vm_allocation_granularity()); 78.647 + MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); 78.648 + // A size larger than VirtualSpaceSize (256k) and add one page to make it _not_ be 78.649 + // vm_allocation_granularity aligned on Windows. 78.650 + size_t large_size = (size_t)(2*256*K + (os::vm_page_size()/BytesPerWord)); 78.651 + large_size += (os::vm_page_size()/BytesPerWord); 78.652 + vs_list->get_new_chunk(large_size, large_size, 0); 78.653 + } 78.654 + 78.655 static void test() { 78.656 test_reserved(); 78.657 test_committed(); 78.658 + test_virtual_space_list_large_chunk(); 78.659 } 78.660 }; 78.661 78.662 -void MetaspaceAux_test() { 78.663 - MetaspaceAuxTest::test(); 78.664 +void TestMetaspaceAux_test() { 78.665 + TestMetaspaceAuxTest::test(); 78.666 } 78.667 78.668 #endif
79.1 --- a/src/share/vm/memory/metaspace.hpp Wed Oct 09 13:00:20 2013 +0200 79.2 +++ b/src/share/vm/memory/metaspace.hpp Wed Oct 09 05:03:34 2013 -0700 79.3 @@ -56,12 +56,15 @@ 79.4 // +-------------------+ 79.5 // 79.6 79.7 +class ChunkManager; 79.8 class ClassLoaderData; 79.9 class Metablock; 79.10 +class Metachunk; 79.11 class MetaWord; 79.12 class Mutex; 79.13 class outputStream; 79.14 class SpaceManager; 79.15 +class VirtualSpaceList; 79.16 79.17 // Metaspaces each have a SpaceManager and allocations 79.18 // are done by the SpaceManager. Allocations are done 79.19 @@ -76,8 +79,6 @@ 79.20 // allocate() method returns a block for use as a 79.21 // quantum of metadata. 79.22 79.23 -class VirtualSpaceList; 79.24 - 79.25 class Metaspace : public CHeapObj<mtClass> { 79.26 friend class VMStructs; 79.27 friend class SpaceManager; 79.28 @@ -102,6 +103,10 @@ 79.29 private: 79.30 void initialize(Mutex* lock, MetaspaceType type); 79.31 79.32 + Metachunk* get_initialization_chunk(MetadataType mdtype, 79.33 + size_t chunk_word_size, 79.34 + size_t chunk_bunch); 79.35 + 79.36 // Align up the word size to the allocation word size 79.37 static size_t align_word_size_up(size_t); 79.38 79.39 @@ -134,6 +139,10 @@ 79.40 static VirtualSpaceList* _space_list; 79.41 static VirtualSpaceList* _class_space_list; 79.42 79.43 + static ChunkManager* _chunk_manager_metadata; 79.44 + static ChunkManager* _chunk_manager_class; 79.45 + 79.46 + public: 79.47 static VirtualSpaceList* space_list() { return _space_list; } 79.48 static VirtualSpaceList* class_space_list() { return _class_space_list; } 79.49 static VirtualSpaceList* get_space_list(MetadataType mdtype) { 79.50 @@ -141,6 +150,14 @@ 79.51 return mdtype == ClassType ? class_space_list() : space_list(); 79.52 } 79.53 79.54 + static ChunkManager* chunk_manager_metadata() { return _chunk_manager_metadata; } 79.55 + static ChunkManager* chunk_manager_class() { return _chunk_manager_class; } 79.56 + static ChunkManager* get_chunk_manager(MetadataType mdtype) { 79.57 + assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); 79.58 + return mdtype == ClassType ? chunk_manager_class() : chunk_manager_metadata(); 79.59 + } 79.60 + 79.61 + private: 79.62 // This is used by DumpSharedSpaces only, where only _vsm is used. So we will 79.63 // maintain a single list for now. 79.64 void record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size); 79.65 @@ -199,6 +216,7 @@ 79.66 void dump(outputStream* const out) const; 79.67 79.68 // Free empty virtualspaces 79.69 + static void purge(MetadataType mdtype); 79.70 static void purge(); 79.71 79.72 void print_on(outputStream* st) const; 79.73 @@ -217,6 +235,9 @@ 79.74 return NOT_LP64(false) LP64_ONLY(UseCompressedClassPointers && !DumpSharedSpaces); 79.75 } 79.76 79.77 + static bool is_class_space_allocation(MetadataType mdType) { 79.78 + return mdType == ClassType && using_class_space(); 79.79 + } 79.80 }; 79.81 79.82 class MetaspaceAux : AllStatic {
80.1 --- a/src/share/vm/memory/referenceProcessor.cpp Wed Oct 09 13:00:20 2013 +0200 80.2 +++ b/src/share/vm/memory/referenceProcessor.cpp Wed Oct 09 05:03:34 2013 -0700 80.3 @@ -367,7 +367,7 @@ 80.4 next_d = java_lang_ref_Reference::discovered(obj); 80.5 if (TraceReferenceGC && PrintGCDetails) { 80.6 gclog_or_tty->print_cr(" obj " INTPTR_FORMAT "/next_d " INTPTR_FORMAT, 80.7 - obj, next_d); 80.8 + (void *)obj, (void *)next_d); 80.9 } 80.10 assert(java_lang_ref_Reference::next(obj) == NULL, 80.11 "Reference not active; should not be discovered"); 80.12 @@ -392,7 +392,7 @@ 80.13 next_d = java_lang_ref_Reference::discovered(obj); 80.14 if (TraceReferenceGC && PrintGCDetails) { 80.15 gclog_or_tty->print_cr(" obj " INTPTR_FORMAT "/next_d " INTPTR_FORMAT, 80.16 - obj, next_d); 80.17 + (void *)obj, (void *)next_d); 80.18 } 80.19 assert(java_lang_ref_Reference::next(obj) == NULL, 80.20 "The reference should not be enqueued"); 80.21 @@ -562,7 +562,7 @@ 80.22 !policy->should_clear_reference(iter.obj(), _soft_ref_timestamp_clock)) { 80.23 if (TraceReferenceGC) { 80.24 gclog_or_tty->print_cr("Dropping reference (" INTPTR_FORMAT ": %s" ") by policy", 80.25 - iter.obj(), iter.obj()->klass()->internal_name()); 80.26 + (void *)iter.obj(), iter.obj()->klass()->internal_name()); 80.27 } 80.28 // Remove Reference object from list 80.29 iter.remove(); 80.30 @@ -601,7 +601,7 @@ 80.31 if (iter.is_referent_alive()) { 80.32 if (TraceReferenceGC) { 80.33 gclog_or_tty->print_cr("Dropping strongly reachable reference (" INTPTR_FORMAT ": %s)", 80.34 - iter.obj(), iter.obj()->klass()->internal_name()); 80.35 + (void *)iter.obj(), iter.obj()->klass()->internal_name()); 80.36 } 80.37 // The referent is reachable after all. 80.38 // Remove Reference object from list. 80.39 @@ -687,7 +687,7 @@ 80.40 if (TraceReferenceGC) { 80.41 gclog_or_tty->print_cr("Adding %sreference (" INTPTR_FORMAT ": %s) as pending", 80.42 clear_referent ? "cleared " : "", 80.43 - iter.obj(), iter.obj()->klass()->internal_name()); 80.44 + (void *)iter.obj(), iter.obj()->klass()->internal_name()); 80.45 } 80.46 assert(iter.obj()->is_oop(UseConcMarkSweepGC), "Adding a bad reference"); 80.47 iter.next(); 80.48 @@ -1003,7 +1003,7 @@ 80.49 gclog_or_tty->print_cr("clean_up_discovered_list: Dropping Reference: " 80.50 INTPTR_FORMAT " with next field: " INTPTR_FORMAT 80.51 " and referent: " INTPTR_FORMAT, 80.52 - iter.obj(), next, iter.referent()); 80.53 + (void *)iter.obj(), (void *)next, (void *)iter.referent()); 80.54 } 80.55 ) 80.56 // Remove Reference object from list 80.57 @@ -1103,14 +1103,14 @@ 80.58 80.59 if (TraceReferenceGC) { 80.60 gclog_or_tty->print_cr("Discovered reference (mt) (" INTPTR_FORMAT ": %s)", 80.61 - obj, obj->klass()->internal_name()); 80.62 + (void *)obj, obj->klass()->internal_name()); 80.63 } 80.64 } else { 80.65 // If retest was non NULL, another thread beat us to it: 80.66 // The reference has already been discovered... 80.67 if (TraceReferenceGC) { 80.68 gclog_or_tty->print_cr("Already discovered reference (" INTPTR_FORMAT ": %s)", 80.69 - obj, obj->klass()->internal_name()); 80.70 + (void *)obj, obj->klass()->internal_name()); 80.71 } 80.72 } 80.73 } 80.74 @@ -1125,7 +1125,7 @@ 80.75 assert(da ? referent->is_oop() : referent->is_oop_or_null(), 80.76 err_msg("Bad referent " INTPTR_FORMAT " found in Reference " 80.77 INTPTR_FORMAT " during %satomic discovery ", 80.78 - (intptr_t)referent, (intptr_t)obj, da ? "" : "non-")); 80.79 + (void *)referent, (void *)obj, da ? "" : "non-")); 80.80 } 80.81 #endif 80.82 80.83 @@ -1205,7 +1205,7 @@ 80.84 // The reference has already been discovered... 80.85 if (TraceReferenceGC) { 80.86 gclog_or_tty->print_cr("Already discovered reference (" INTPTR_FORMAT ": %s)", 80.87 - obj, obj->klass()->internal_name()); 80.88 + (void *)obj, obj->klass()->internal_name()); 80.89 } 80.90 if (RefDiscoveryPolicy == ReferentBasedDiscovery) { 80.91 // assumes that an object is not processed twice; 80.92 @@ -1273,7 +1273,7 @@ 80.93 80.94 if (TraceReferenceGC) { 80.95 gclog_or_tty->print_cr("Discovered reference (" INTPTR_FORMAT ": %s)", 80.96 - obj, obj->klass()->internal_name()); 80.97 + (void *)obj, obj->klass()->internal_name()); 80.98 } 80.99 } 80.100 assert(obj->is_oop(), "Discovered a bad reference"); 80.101 @@ -1372,7 +1372,7 @@ 80.102 // active; we need to trace and mark its cohort. 80.103 if (TraceReferenceGC) { 80.104 gclog_or_tty->print_cr("Precleaning Reference (" INTPTR_FORMAT ": %s)", 80.105 - iter.obj(), iter.obj()->klass()->internal_name()); 80.106 + (void *)iter.obj(), iter.obj()->klass()->internal_name()); 80.107 } 80.108 // Remove Reference object from list 80.109 iter.remove();
81.1 --- a/src/share/vm/oops/constantPool.cpp Wed Oct 09 13:00:20 2013 +0200 81.2 +++ b/src/share/vm/oops/constantPool.cpp Wed Oct 09 05:03:34 2013 -0700 81.3 @@ -1918,7 +1918,7 @@ 81.4 st->print_cr(" - holder: " INTPTR_FORMAT, pool_holder()); 81.5 } 81.6 st->print_cr(" - cache: " INTPTR_FORMAT, cache()); 81.7 - st->print_cr(" - resolved_references: " INTPTR_FORMAT, resolved_references()); 81.8 + st->print_cr(" - resolved_references: " INTPTR_FORMAT, (void *)resolved_references()); 81.9 st->print_cr(" - reference_map: " INTPTR_FORMAT, reference_map()); 81.10 81.11 for (int index = 1; index < length(); index++) { // Index 0 is unused
82.1 --- a/src/share/vm/oops/cpCache.cpp Wed Oct 09 13:00:20 2013 +0200 82.2 +++ b/src/share/vm/oops/cpCache.cpp Wed Oct 09 05:03:34 2013 -0700 82.3 @@ -306,8 +306,8 @@ 82.4 if (TraceInvokeDynamic) { 82.5 tty->print_cr("set_method_handle bc=%d appendix="PTR_FORMAT"%s method_type="PTR_FORMAT"%s method="PTR_FORMAT" ", 82.6 invoke_code, 82.7 - (intptr_t)appendix(), (has_appendix ? "" : " (unused)"), 82.8 - (intptr_t)method_type(), (has_method_type ? "" : " (unused)"), 82.9 + (void *)appendix(), (has_appendix ? "" : " (unused)"), 82.10 + (void *)method_type(), (has_method_type ? "" : " (unused)"), 82.11 (intptr_t)adapter()); 82.12 adapter->print(); 82.13 if (has_appendix) appendix()->print();
83.1 --- a/src/share/vm/oops/instanceKlass.cpp Wed Oct 09 13:00:20 2013 +0200 83.2 +++ b/src/share/vm/oops/instanceKlass.cpp Wed Oct 09 05:03:34 2013 -0700 83.3 @@ -106,7 +106,7 @@ 83.4 len = name->utf8_length(); \ 83.5 } \ 83.6 HS_DTRACE_PROBE4(hotspot, class__initialization__##type, \ 83.7 - data, len, (clss)->class_loader(), thread_type); \ 83.8 + data, len, SOLARIS_ONLY((void *))(clss)->class_loader(), thread_type); \ 83.9 } 83.10 83.11 #define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait) \ 83.12 @@ -119,7 +119,7 @@ 83.13 len = name->utf8_length(); \ 83.14 } \ 83.15 HS_DTRACE_PROBE5(hotspot, class__initialization__##type, \ 83.16 - data, len, (clss)->class_loader(), thread_type, wait); \ 83.17 + data, len, SOLARIS_ONLY((void *))(clss)->class_loader(), thread_type, wait); \ 83.18 } 83.19 #else /* USDT2 */ 83.20 83.21 @@ -1419,6 +1419,8 @@ 83.22 } 83.23 83.24 // lookup a method in all the interfaces that this class implements 83.25 +// Do NOT return private or static methods, new in JDK8 which are not externally visible 83.26 +// They should only be found in the initial InterfaceMethodRef 83.27 Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name, 83.28 Symbol* signature) const { 83.29 Array<Klass*>* all_ifs = transitive_interfaces(); 83.30 @@ -1427,7 +1429,7 @@ 83.31 for (int i = 0; i < num_ifs; i++) { 83.32 ik = InstanceKlass::cast(all_ifs->at(i)); 83.33 Method* m = ik->lookup_method(name, signature); 83.34 - if (m != NULL) { 83.35 + if (m != NULL && m->is_public() && !m->is_static()) { 83.36 return m; 83.37 } 83.38 } 83.39 @@ -2303,7 +2305,7 @@ 83.40 } 83.41 83.42 address InstanceKlass::static_field_addr(int offset) { 83.43 - return (address)(offset + InstanceMirrorKlass::offset_of_static_fields() + (intptr_t)java_mirror()); 83.44 + return (address)(offset + InstanceMirrorKlass::offset_of_static_fields() + cast_from_oop<intptr_t>(java_mirror())); 83.45 } 83.46 83.47
84.1 --- a/src/share/vm/oops/instanceMirrorKlass.hpp Wed Oct 09 13:00:20 2013 +0200 84.2 +++ b/src/share/vm/oops/instanceMirrorKlass.hpp Wed Oct 09 05:03:34 2013 -0700 84.3 @@ -1,5 +1,5 @@ 84.4 /* 84.5 - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 84.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 84.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 84.8 * 84.9 * This code is free software; you can redistribute it and/or modify it 84.10 @@ -66,7 +66,7 @@ 84.11 // Static field offset is an offset into the Heap, should be converted by 84.12 // based on UseCompressedOop for traversal 84.13 static HeapWord* start_of_static_fields(oop obj) { 84.14 - return (HeapWord*)((intptr_t)obj + offset_of_static_fields()); 84.15 + return (HeapWord*)(cast_from_oop<intptr_t>(obj) + offset_of_static_fields()); 84.16 } 84.17 84.18 static void init_offset_of_static_fields() {
85.1 --- a/src/share/vm/oops/instanceRefKlass.cpp Wed Oct 09 13:00:20 2013 +0200 85.2 +++ b/src/share/vm/oops/instanceRefKlass.cpp Wed Oct 09 05:03:34 2013 -0700 85.3 @@ -1,5 +1,5 @@ 85.4 /* 85.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 85.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 85.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 85.8 * 85.9 * This code is free software; you can redistribute it and/or modify it 85.10 @@ -51,7 +51,7 @@ 85.11 T heap_oop = oopDesc::load_heap_oop(referent_addr); 85.12 debug_only( 85.13 if(TraceReferenceGC && PrintGCDetails) { 85.14 - gclog_or_tty->print_cr("InstanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj); 85.15 + gclog_or_tty->print_cr("InstanceRefKlass::oop_follow_contents " INTPTR_FORMAT, (void *)obj); 85.16 } 85.17 ) 85.18 if (!oopDesc::is_null(heap_oop)) { 85.19 @@ -62,7 +62,7 @@ 85.20 ref->InstanceKlass::oop_follow_contents(obj); 85.21 debug_only( 85.22 if(TraceReferenceGC && PrintGCDetails) { 85.23 - gclog_or_tty->print_cr(" Non NULL enqueued " INTPTR_FORMAT, obj); 85.24 + gclog_or_tty->print_cr(" Non NULL enqueued " INTPTR_FORMAT, (void *)obj); 85.25 } 85.26 ) 85.27 return; 85.28 @@ -70,7 +70,7 @@ 85.29 // treat referent as normal oop 85.30 debug_only( 85.31 if(TraceReferenceGC && PrintGCDetails) { 85.32 - gclog_or_tty->print_cr(" Non NULL normal " INTPTR_FORMAT, obj); 85.33 + gclog_or_tty->print_cr(" Non NULL normal " INTPTR_FORMAT, (void *)obj); 85.34 } 85.35 ) 85.36 MarkSweep::mark_and_push(referent_addr); 85.37 @@ -130,7 +130,7 @@ 85.38 T heap_oop = oopDesc::load_heap_oop(referent_addr); 85.39 debug_only( 85.40 if(TraceReferenceGC && PrintGCDetails) { 85.41 - gclog_or_tty->print_cr("InstanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj); 85.42 + gclog_or_tty->print_cr("InstanceRefKlass::oop_follow_contents " INTPTR_FORMAT, (void *)obj); 85.43 } 85.44 ) 85.45 if (!oopDesc::is_null(heap_oop)) { 85.46 @@ -142,7 +142,7 @@ 85.47 ref->InstanceKlass::oop_follow_contents(cm, obj); 85.48 debug_only( 85.49 if(TraceReferenceGC && PrintGCDetails) { 85.50 - gclog_or_tty->print_cr(" Non NULL enqueued " INTPTR_FORMAT, obj); 85.51 + gclog_or_tty->print_cr(" Non NULL enqueued " INTPTR_FORMAT, (void *)obj); 85.52 } 85.53 ) 85.54 return; 85.55 @@ -150,7 +150,7 @@ 85.56 // treat referent as normal oop 85.57 debug_only( 85.58 if(TraceReferenceGC && PrintGCDetails) { 85.59 - gclog_or_tty->print_cr(" Non NULL normal " INTPTR_FORMAT, obj); 85.60 + gclog_or_tty->print_cr(" Non NULL normal " INTPTR_FORMAT, (void *)obj); 85.61 } 85.62 ) 85.63 PSParallelCompact::mark_and_push(cm, referent_addr);
86.1 --- a/src/share/vm/oops/klassVtable.cpp Wed Oct 09 13:00:20 2013 +0200 86.2 +++ b/src/share/vm/oops/klassVtable.cpp Wed Oct 09 05:03:34 2013 -0700 86.3 @@ -292,9 +292,10 @@ 86.4 return allocate_new; 86.5 } 86.6 86.7 - // private methods always have a new entry in the vtable 86.8 + // private methods in classes always have a new entry in the vtable 86.9 // specification interpretation since classic has 86.10 // private methods not overriding 86.11 + // JDK8 adds private methods in interfaces which require invokespecial 86.12 if (target_method()->is_private()) { 86.13 return allocate_new; 86.14 } 86.15 @@ -442,9 +443,10 @@ 86.16 return true; 86.17 } 86.18 86.19 - // private methods always have a new entry in the vtable 86.20 + // private methods in classes always have a new entry in the vtable 86.21 // specification interpretation since classic has 86.22 // private methods not overriding 86.23 + // JDK8 adds private methods in interfaces which require invokespecial 86.24 if (target_method()->is_private()) { 86.25 return true; 86.26 } 86.27 @@ -520,7 +522,7 @@ 86.28 Klass* method_holder = m->method_holder(); 86.29 InstanceKlass *mhk = InstanceKlass::cast(method_holder); 86.30 86.31 - // miranda methods are interface methods in a class's vtable 86.32 + // miranda methods are public abstract instance interface methods in a class's vtable 86.33 if (mhk->is_interface()) { 86.34 assert(m->is_public(), "should be public"); 86.35 assert(ik()->implements_interface(method_holder) , "this class should implement the interface"); 86.36 @@ -534,6 +536,8 @@ 86.37 // "miranda" means not static, not defined by this class, and not defined 86.38 // in super unless it is private and therefore inaccessible to this class. 86.39 // the caller must make sure that the method belongs to an interface implemented by the class 86.40 +// Miranda methods only include public interface instance methods 86.41 +// Not private methods, not static methods, not default = concrete abstract 86.42 bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods, Klass* super) { 86.43 if (m->is_static()) { 86.44 return false;
87.1 --- a/src/share/vm/oops/method.hpp Wed Oct 09 13:00:20 2013 +0200 87.2 +++ b/src/share/vm/oops/method.hpp Wed Oct 09 05:03:34 2013 -0700 87.3 @@ -804,6 +804,7 @@ 87.4 private: 87.5 void print_made_not_compilable(int comp_level, bool is_osr, bool report, const char* reason); 87.6 87.7 + public: 87.8 MethodCounters* get_method_counters(TRAPS) { 87.9 if (_method_counters == NULL) { 87.10 build_method_counters(this, CHECK_AND_CLEAR_NULL); 87.11 @@ -811,7 +812,6 @@ 87.12 return _method_counters; 87.13 } 87.14 87.15 - public: 87.16 bool is_not_c1_compilable() const { return access_flags().is_not_c1_compilable(); } 87.17 void set_not_c1_compilable() { _access_flags.set_not_c1_compilable(); } 87.18 void clear_not_c1_compilable() { _access_flags.clear_not_c1_compilable(); }
88.1 --- a/src/share/vm/oops/methodData.hpp Wed Oct 09 13:00:20 2013 +0200 88.2 +++ b/src/share/vm/oops/methodData.hpp Wed Oct 09 05:03:34 2013 -0700 88.3 @@ -333,10 +333,10 @@ 88.4 return (int)data()->cell_at(index); 88.5 } 88.6 void set_oop_at(int index, oop value) { 88.7 - set_intptr_at(index, (intptr_t) value); 88.8 + set_intptr_at(index, cast_from_oop<intptr_t>(value)); 88.9 } 88.10 oop oop_at(int index) { 88.11 - return (oop)intptr_at(index); 88.12 + return cast_to_oop(intptr_at(index)); 88.13 } 88.14 88.15 void set_flag_at(int flag_number) {
89.1 --- a/src/share/vm/oops/oop.inline.hpp Wed Oct 09 13:00:20 2013 +0200 89.2 +++ b/src/share/vm/oops/oop.inline.hpp Wed Oct 09 05:03:34 2013 -0700 89.3 @@ -183,7 +183,7 @@ 89.4 // in inner GC loops so these are separated. 89.5 89.6 inline bool check_obj_alignment(oop obj) { 89.7 - return (intptr_t)obj % MinObjAlignmentInBytes == 0; 89.8 + return cast_from_oop<intptr_t>(obj) % MinObjAlignmentInBytes == 0; 89.9 } 89.10 89.11 inline narrowOop oopDesc::encode_heap_oop_not_null(oop v) {
90.1 --- a/src/share/vm/oops/oopsHierarchy.hpp Wed Oct 09 13:00:20 2013 +0200 90.2 +++ b/src/share/vm/oops/oopsHierarchy.hpp Wed Oct 09 05:03:34 2013 -0700 90.3 @@ -55,11 +55,16 @@ 90.4 // to and from the underlying oopDesc pointer type. 90.5 // 90.6 // Because oop and its subclasses <type>Oop are class types, arbitrary 90.7 -// conversions are not accepted by the compiler, and you may get a message 90.8 -// about overloading ambiguity (between long and int is common when converting 90.9 -// from a constant in 64 bit mode), or unable to convert from type to 'oop'. 90.10 -// Applying a cast to one of these conversion operators first will get to the 90.11 -// underlying oopDesc* type if appropriate. 90.12 +// conversions are not accepted by the compiler. Applying a cast to 90.13 +// an oop will cause the best matched conversion operator to be 90.14 +// invoked returning the underlying oopDesc* type if appropriate. 90.15 +// No copy constructors, explicit user conversions or operators of 90.16 +// numerical type should be defined within the oop class. Most C++ 90.17 +// compilers will issue a compile time error concerning the overloading 90.18 +// ambiguity between operators of numerical and pointer types. If 90.19 +// a conversion to or from an oop to a numerical type is needed, 90.20 +// use the inline template methods, cast_*_oop, defined below. 90.21 +// 90.22 // Converting NULL to oop to Handle implicit is no longer accepted by the 90.23 // compiler because there are too many steps in the conversion. Use Handle() 90.24 // instead, which generates less code anyway. 90.25 @@ -83,12 +88,9 @@ 90.26 void raw_set_obj(const void* p) { _o = (oopDesc*)p; } 90.27 90.28 oop() { set_obj(NULL); } 90.29 + oop(const oop& o) { set_obj(o.obj()); } 90.30 oop(const volatile oop& o) { set_obj(o.obj()); } 90.31 oop(const void* p) { set_obj(p); } 90.32 - oop(intptr_t i) { set_obj((void *)i); } 90.33 -#ifdef _LP64 90.34 - oop(int i) { set_obj((void *)i); } 90.35 -#endif 90.36 ~oop() { 90.37 if (CheckUnhandledOops) unregister_oop(); 90.38 } 90.39 @@ -101,8 +103,6 @@ 90.40 bool operator==(void *p) const { return obj() == p; } 90.41 bool operator!=(const volatile oop o) const { return obj() != o.obj(); } 90.42 bool operator!=(void *p) const { return obj() != p; } 90.43 - bool operator==(intptr_t p) const { return obj() == (oopDesc*)p; } 90.44 - bool operator!=(intptr_t p) const { return obj() != (oopDesc*)p; } 90.45 90.46 bool operator<(oop o) const { return obj() < o.obj(); } 90.47 bool operator>(oop o) const { return obj() > o.obj(); } 90.48 @@ -110,8 +110,18 @@ 90.49 bool operator>=(oop o) const { return obj() >= o.obj(); } 90.50 bool operator!() const { return !obj(); } 90.51 90.52 - // Cast 90.53 + // Assignment 90.54 + oop& operator=(const oop& o) { _o = o.obj(); return *this; } 90.55 +#ifndef SOLARIS 90.56 + volatile oop& operator=(const oop& o) volatile { _o = o.obj(); return *this; } 90.57 +#endif 90.58 + volatile oop& operator=(const volatile oop& o) volatile { _o = o.obj(); return *this; } 90.59 + 90.60 + // Explict user conversions 90.61 operator void* () const { return (void *)obj(); } 90.62 +#ifndef SOLARIS 90.63 + operator void* () const volatile { return (void *)obj(); } 90.64 +#endif 90.65 operator HeapWord* () const { return (HeapWord*)obj(); } 90.66 operator oopDesc* () const { return obj(); } 90.67 operator intptr_t* () const { return (intptr_t*)obj(); } 90.68 @@ -119,7 +129,6 @@ 90.69 operator markOop () const { return markOop(obj()); } 90.70 90.71 operator address () const { return (address)obj(); } 90.72 - operator intptr_t () const volatile { return (intptr_t)obj(); } 90.73 90.74 // from javaCalls.cpp 90.75 operator jobject () const { return (jobject)obj(); } 90.76 @@ -141,12 +150,26 @@ 90.77 class type##Oop : public oop { \ 90.78 public: \ 90.79 type##Oop() : oop() {} \ 90.80 + type##Oop(const oop& o) : oop(o) {} \ 90.81 type##Oop(const volatile oop& o) : oop(o) {} \ 90.82 type##Oop(const void* p) : oop(p) {} \ 90.83 operator type##OopDesc* () const { return (type##OopDesc*)obj(); } \ 90.84 type##OopDesc* operator->() const { \ 90.85 return (type##OopDesc*)obj(); \ 90.86 } \ 90.87 + type##Oop& operator=(const type##Oop& o) { \ 90.88 + oop::operator=(o); \ 90.89 + return *this; \ 90.90 + } \ 90.91 + NOT_SOLARIS( \ 90.92 + volatile type##Oop& operator=(const type##Oop& o) volatile { \ 90.93 + (void)const_cast<oop&>(oop::operator=(o)); \ 90.94 + return *this; \ 90.95 + }) \ 90.96 + volatile type##Oop& operator=(const volatile type##Oop& o) volatile {\ 90.97 + (void)const_cast<oop&>(oop::operator=(o)); \ 90.98 + return *this; \ 90.99 + } \ 90.100 }; 90.101 90.102 DEF_OOP(instance); 90.103 @@ -156,6 +179,16 @@ 90.104 90.105 #endif // CHECK_UNHANDLED_OOPS 90.106 90.107 +// For CHECK_UNHANDLED_OOPS, it is ambiguous C++ behavior to have the oop 90.108 +// structure contain explicit user defined conversions of both numerical 90.109 +// and pointer type. Define inline methods to provide the numerical conversions. 90.110 +template <class T> inline oop cast_to_oop(T value) { 90.111 + return (oop)(CHECK_UNHANDLED_OOPS_ONLY((void *))(value)); 90.112 +} 90.113 +template <class T> inline T cast_from_oop(oop o) { 90.114 + return (T)(CHECK_UNHANDLED_OOPS_ONLY((void*))o); 90.115 +} 90.116 + 90.117 // The metadata hierarchy is separate from the oop hierarchy 90.118 90.119 // class MetaspaceObj
91.1 --- a/src/share/vm/opto/escape.cpp Wed Oct 09 13:00:20 2013 +0200 91.2 +++ b/src/share/vm/opto/escape.cpp Wed Oct 09 05:03:34 2013 -0700 91.3 @@ -780,6 +780,7 @@ 91.4 } 91.5 } else { // Allocate instance 91.6 if (cik->is_subclass_of(_compile->env()->Thread_klass()) || 91.7 + cik->is_subclass_of(_compile->env()->Reference_klass()) || 91.8 !cik->is_instance_klass() || // StressReflectiveCode 91.9 cik->as_instance_klass()->has_finalizer()) { 91.10 es = PointsToNode::GlobalEscape;
92.1 --- a/src/share/vm/opto/graphKit.cpp Wed Oct 09 13:00:20 2013 +0200 92.2 +++ b/src/share/vm/opto/graphKit.cpp Wed Oct 09 05:03:34 2013 -0700 92.3 @@ -2122,7 +2122,7 @@ 92.4 // Null check oop. Set null-path control into Region in slot 3. 92.5 // Make a cast-not-nullness use the other not-null control. Return cast. 92.6 Node* GraphKit::null_check_oop(Node* value, Node* *null_control, 92.7 - bool never_see_null) { 92.8 + bool never_see_null, bool safe_for_replace) { 92.9 // Initial NULL check taken path 92.10 (*null_control) = top(); 92.11 Node* cast = null_check_common(value, T_OBJECT, false, null_control); 92.12 @@ -2140,6 +2140,9 @@ 92.13 Deoptimization::Action_make_not_entrant); 92.14 (*null_control) = top(); // NULL path is dead 92.15 } 92.16 + if ((*null_control) == top() && safe_for_replace) { 92.17 + replace_in_map(value, cast); 92.18 + } 92.19 92.20 // Cast away null-ness on the result 92.21 return cast; 92.22 @@ -2634,15 +2637,17 @@ 92.23 C->set_has_split_ifs(true); // Has chance for split-if optimization 92.24 92.25 ciProfileData* data = NULL; 92.26 + bool safe_for_replace = false; 92.27 if (java_bc() == Bytecodes::_instanceof) { // Only for the bytecode 92.28 data = method()->method_data()->bci_to_data(bci()); 92.29 + safe_for_replace = true; 92.30 } 92.31 bool never_see_null = (ProfileDynamicTypes // aggressive use of profile 92.32 && seems_never_null(obj, data)); 92.33 92.34 // Null check; get casted pointer; set region slot 3 92.35 Node* null_ctl = top(); 92.36 - Node* not_null_obj = null_check_oop(obj, &null_ctl, never_see_null); 92.37 + Node* not_null_obj = null_check_oop(obj, &null_ctl, never_see_null, safe_for_replace); 92.38 92.39 // If not_null_obj is dead, only null-path is taken 92.40 if (stopped()) { // Doing instance-of on a NULL? 92.41 @@ -2723,11 +2728,13 @@ 92.42 } 92.43 92.44 ciProfileData* data = NULL; 92.45 + bool safe_for_replace = false; 92.46 if (failure_control == NULL) { // use MDO in regular case only 92.47 assert(java_bc() == Bytecodes::_aastore || 92.48 java_bc() == Bytecodes::_checkcast, 92.49 "interpreter profiles type checks only for these BCs"); 92.50 data = method()->method_data()->bci_to_data(bci()); 92.51 + safe_for_replace = true; 92.52 } 92.53 92.54 // Make the merge point 92.55 @@ -2742,7 +2749,7 @@ 92.56 92.57 // Null check; get casted pointer; set region slot 3 92.58 Node* null_ctl = top(); 92.59 - Node* not_null_obj = null_check_oop(obj, &null_ctl, never_see_null); 92.60 + Node* not_null_obj = null_check_oop(obj, &null_ctl, never_see_null, safe_for_replace); 92.61 92.62 // If not_null_obj is dead, only null-path is taken 92.63 if (stopped()) { // Doing instance-of on a NULL?
93.1 --- a/src/share/vm/opto/graphKit.hpp Wed Oct 09 13:00:20 2013 +0200 93.2 +++ b/src/share/vm/opto/graphKit.hpp Wed Oct 09 05:03:34 2013 -0700 93.3 @@ -378,8 +378,10 @@ 93.4 // Return a cast-not-null node which depends on the not-null control. 93.5 // If never_see_null, use an uncommon trap (*null_control sees a top). 93.6 // The cast is not valid along the null path; keep a copy of the original. 93.7 + // If safe_for_replace, then we can replace the value with the cast 93.8 + // in the parsing map (the cast is guaranteed to dominate the map) 93.9 Node* null_check_oop(Node* value, Node* *null_control, 93.10 - bool never_see_null = false); 93.11 + bool never_see_null = false, bool safe_for_replace = false); 93.12 93.13 // Check the null_seen bit. 93.14 bool seems_never_null(Node* obj, ciProfileData* data);
94.1 --- a/src/share/vm/opto/machnode.cpp Wed Oct 09 13:00:20 2013 +0200 94.2 +++ b/src/share/vm/opto/machnode.cpp Wed Oct 09 05:03:34 2013 -0700 94.3 @@ -1,5 +1,5 @@ 94.4 /* 94.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 94.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 94.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 94.8 * 94.9 * This code is free software; you can redistribute it and/or modify it 94.10 @@ -341,7 +341,7 @@ 94.11 return TypePtr::BOTTOM; 94.12 } 94.13 // %%% make offset be intptr_t 94.14 - assert(!Universe::heap()->is_in_reserved((oop)offset), "must be a raw ptr"); 94.15 + assert(!Universe::heap()->is_in_reserved(cast_to_oop(offset)), "must be a raw ptr"); 94.16 return TypeRawPtr::BOTTOM; 94.17 } 94.18
95.1 --- a/src/share/vm/opto/parseHelper.cpp Wed Oct 09 13:00:20 2013 +0200 95.2 +++ b/src/share/vm/opto/parseHelper.cpp Wed Oct 09 05:03:34 2013 -0700 95.3 @@ -343,10 +343,14 @@ 95.4 95.5 // Get the Method* node. 95.6 ciMethod* m = method(); 95.7 - address counters_adr = m->ensure_method_counters(); 95.8 + MethodCounters* counters_adr = m->ensure_method_counters(); 95.9 + if (counters_adr == NULL) { 95.10 + C->record_failure("method counters allocation failed"); 95.11 + return; 95.12 + } 95.13 95.14 Node* ctrl = control(); 95.15 - const TypePtr* adr_type = TypeRawPtr::make(counters_adr); 95.16 + const TypePtr* adr_type = TypeRawPtr::make((address) counters_adr); 95.17 Node *counters_node = makecon(adr_type); 95.18 Node* adr_iic_node = basic_plus_adr(counters_node, counters_node, 95.19 MethodCounters::interpreter_invocation_counter_offset_in_bytes());
96.1 --- a/src/share/vm/prims/jni.cpp Wed Oct 09 13:00:20 2013 +0200 96.2 +++ b/src/share/vm/prims/jni.cpp Wed Oct 09 05:03:34 2013 -0700 96.3 @@ -5046,7 +5046,10 @@ 96.4 void TestReservedSpace_test(); 96.5 void TestReserveMemorySpecial_test(); 96.6 void TestVirtualSpace_test(); 96.7 -void MetaspaceAux_test(); 96.8 +void TestMetaspaceAux_test(); 96.9 +#if INCLUDE_ALL_GCS 96.10 +void TestG1BiasedArray_test(); 96.11 +#endif 96.12 96.13 void execute_internal_vm_tests() { 96.14 if (ExecuteInternalVMTests) { 96.15 @@ -5054,7 +5057,7 @@ 96.16 run_unit_test(TestReservedSpace_test()); 96.17 run_unit_test(TestReserveMemorySpecial_test()); 96.18 run_unit_test(TestVirtualSpace_test()); 96.19 - run_unit_test(MetaspaceAux_test()); 96.20 + run_unit_test(TestMetaspaceAux_test()); 96.21 run_unit_test(GlobalDefinitions::test_globals()); 96.22 run_unit_test(GCTimerAllTest::all()); 96.23 run_unit_test(arrayOopDesc::test_max_array_length()); 96.24 @@ -5066,6 +5069,7 @@ 96.25 run_unit_test(VMStructs::test()); 96.26 #endif 96.27 #if INCLUDE_ALL_GCS 96.28 + run_unit_test(TestG1BiasedArray_test()); 96.29 run_unit_test(HeapRegionRemSet::test_prt()); 96.30 #endif 96.31 tty->print_cr("All internal VM tests passed");
97.1 --- a/src/share/vm/prims/jvmtiTagMap.cpp Wed Oct 09 13:00:20 2013 +0200 97.2 +++ b/src/share/vm/prims/jvmtiTagMap.cpp Wed Oct 09 05:03:34 2013 -0700 97.3 @@ -165,7 +165,7 @@ 97.4 static unsigned int hash(oop key, int size) { 97.5 // shift right to get better distribution (as these bits will be zero 97.6 // with aligned addresses) 97.7 - unsigned int addr = (unsigned int)((intptr_t)key); 97.8 + unsigned int addr = (unsigned int)(cast_from_oop<intptr_t>(key)); 97.9 #ifdef _LP64 97.10 return (addr >> 3) % size; 97.11 #else
98.1 --- a/src/share/vm/prims/unsafe.cpp Wed Oct 09 13:00:20 2013 +0200 98.2 +++ b/src/share/vm/prims/unsafe.cpp Wed Oct 09 05:03:34 2013 -0700 98.3 @@ -292,9 +292,9 @@ 98.4 volatile oop v; 98.5 if (UseCompressedOops) { 98.6 volatile narrowOop n = *(volatile narrowOop*) addr; 98.7 - v = oopDesc::decode_heap_oop(n); 98.8 + (void)const_cast<oop&>(v = oopDesc::decode_heap_oop(n)); 98.9 } else { 98.10 - v = *(volatile oop*) addr; 98.11 + (void)const_cast<oop&>(v = *(volatile oop*) addr); 98.12 } 98.13 OrderAccess::acquire(); 98.14 return JNIHandles::make_local(env, v); 98.15 @@ -1222,9 +1222,9 @@ 98.16 #endif /* USDT2 */ 98.17 if (event.should_commit()) { 98.18 oop obj = thread->current_park_blocker(); 98.19 - event.set_klass(obj ? obj->klass() : NULL); 98.20 + event.set_klass((obj != NULL) ? obj->klass() : NULL); 98.21 event.set_timeout(time); 98.22 - event.set_address(obj ? (TYPE_ADDRESS) (uintptr_t) obj : 0); 98.23 + event.set_address((obj != NULL) ? (TYPE_ADDRESS) cast_from_oop<uintptr_t>(obj) : 0); 98.24 event.commit(); 98.25 } 98.26 UNSAFE_END
99.1 --- a/src/share/vm/runtime/biasedLocking.cpp Wed Oct 09 13:00:20 2013 +0200 99.2 +++ b/src/share/vm/runtime/biasedLocking.cpp Wed Oct 09 05:03:34 2013 -0700 99.3 @@ -1,5 +1,5 @@ 99.4 /* 99.5 - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 99.6 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 99.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 99.8 * 99.9 * This code is free software; you can redistribute it and/or modify it 99.10 @@ -161,7 +161,7 @@ 99.11 if (TraceBiasedLocking && (Verbose || !is_bulk)) { 99.12 ResourceMark rm; 99.13 tty->print_cr("Revoking bias of object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s , prototype header " INTPTR_FORMAT " , allow rebias %d , requesting thread " INTPTR_FORMAT, 99.14 - (intptr_t) obj, (intptr_t) mark, obj->klass()->external_name(), (intptr_t) obj->klass()->prototype_header(), (allow_rebias ? 1 : 0), (intptr_t) requesting_thread); 99.15 + (void *)obj, (intptr_t) mark, obj->klass()->external_name(), (intptr_t) obj->klass()->prototype_header(), (allow_rebias ? 1 : 0), (intptr_t) requesting_thread); 99.16 } 99.17 99.18 JavaThread* biased_thread = mark->biased_locker(); 99.19 @@ -214,8 +214,8 @@ 99.20 if (mon_info->owner() == obj) { 99.21 if (TraceBiasedLocking && Verbose) { 99.22 tty->print_cr(" mon_info->owner (" PTR_FORMAT ") == obj (" PTR_FORMAT ")", 99.23 - (intptr_t) mon_info->owner(), 99.24 - (intptr_t) obj); 99.25 + (void *) mon_info->owner(), 99.26 + (void *) obj); 99.27 } 99.28 // Assume recursive case and fix up highest lock later 99.29 markOop mark = markOopDesc::encode((BasicLock*) NULL); 99.30 @@ -224,8 +224,8 @@ 99.31 } else { 99.32 if (TraceBiasedLocking && Verbose) { 99.33 tty->print_cr(" mon_info->owner (" PTR_FORMAT ") != obj (" PTR_FORMAT ")", 99.34 - (intptr_t) mon_info->owner(), 99.35 - (intptr_t) obj); 99.36 + (void *) mon_info->owner(), 99.37 + (void *) obj); 99.38 } 99.39 } 99.40 } 99.41 @@ -326,7 +326,7 @@ 99.42 tty->print_cr("* Beginning bulk revocation (kind == %s) because of object " 99.43 INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s", 99.44 (bulk_rebias ? "rebias" : "revoke"), 99.45 - (intptr_t) o, (intptr_t) o->mark(), o->klass()->external_name()); 99.46 + (void *) o, (intptr_t) o->mark(), o->klass()->external_name()); 99.47 } 99.48 99.49 jlong cur_time = os::javaTimeMillis();
100.1 --- a/src/share/vm/runtime/deoptimization.cpp Wed Oct 09 13:00:20 2013 +0200 100.2 +++ b/src/share/vm/runtime/deoptimization.cpp Wed Oct 09 05:03:34 2013 -0700 100.3 @@ -1,5 +1,5 @@ 100.4 /* 100.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 100.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 100.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 100.8 * 100.9 * This code is free software; you can redistribute it and/or modify it 100.10 @@ -234,7 +234,7 @@ 100.11 assert(Universe::heap()->is_in_or_null(result), "must be heap pointer"); 100.12 if (TraceDeoptimization) { 100.13 ttyLocker ttyl; 100.14 - tty->print_cr("SAVED OOP RESULT " INTPTR_FORMAT " in thread " INTPTR_FORMAT, result, thread); 100.15 + tty->print_cr("SAVED OOP RESULT " INTPTR_FORMAT " in thread " INTPTR_FORMAT, (void *)result, thread); 100.16 } 100.17 } 100.18 bool reallocated = false; 100.19 @@ -278,7 +278,7 @@ 100.20 first = false; 100.21 tty->print_cr("RELOCK OBJECTS in thread " INTPTR_FORMAT, thread); 100.22 } 100.23 - tty->print_cr(" object <" INTPTR_FORMAT "> locked", mi->owner()); 100.24 + tty->print_cr(" object <" INTPTR_FORMAT "> locked", (void *)mi->owner()); 100.25 } 100.26 } 100.27 } 100.28 @@ -977,7 +977,7 @@ 100.29 KlassHandle k(java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()())); 100.30 Handle obj = sv->value(); 100.31 100.32 - tty->print(" object <" INTPTR_FORMAT "> of type ", sv->value()()); 100.33 + tty->print(" object <" INTPTR_FORMAT "> of type ", (void *)sv->value()()); 100.34 k->print_value(); 100.35 tty->print(" allocated (%d bytes)", obj->size() * HeapWordSize); 100.36 tty->cr();
101.1 --- a/src/share/vm/runtime/frame.cpp Wed Oct 09 13:00:20 2013 +0200 101.2 +++ b/src/share/vm/runtime/frame.cpp Wed Oct 09 05:03:34 2013 -0700 101.3 @@ -1,5 +1,5 @@ 101.4 /* 101.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 101.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 101.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 101.8 * 101.9 * This code is free software; you can redistribute it and/or modify it 101.10 @@ -1097,7 +1097,7 @@ 101.11 return NULL; 101.12 } 101.13 oop r = *oop_adr; 101.14 - assert(Universe::heap()->is_in_or_null(r), err_msg("bad receiver: " INTPTR_FORMAT " (" INTX_FORMAT ")", (intptr_t) r, (intptr_t) r)); 101.15 + assert(Universe::heap()->is_in_or_null(r), err_msg("bad receiver: " INTPTR_FORMAT " (" INTX_FORMAT ")", (void *) r, (void *) r)); 101.16 return r; 101.17 } 101.18 101.19 @@ -1228,9 +1228,7 @@ 101.20 101.21 void frame::ZapDeadClosure::do_oop(oop* p) { 101.22 if (TraceZapDeadLocals) tty->print_cr("zapping @ " INTPTR_FORMAT " containing " INTPTR_FORMAT, p, (address)*p); 101.23 - // Need cast because on _LP64 the conversion to oop is ambiguous. Constant 101.24 - // can be either long or int. 101.25 - *p = (oop)(int)0xbabebabe; 101.26 + *p = cast_to_oop<intptr_t>(0xbabebabe); 101.27 } 101.28 frame::ZapDeadClosure frame::_zap_dead; 101.29
102.1 --- a/src/share/vm/runtime/javaCalls.cpp Wed Oct 09 13:00:20 2013 +0200 102.2 +++ b/src/share/vm/runtime/javaCalls.cpp Wed Oct 09 05:03:34 2013 -0700 102.3 @@ -1,5 +1,5 @@ 102.4 /* 102.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 102.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 102.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 102.8 * 102.9 * This code is free software; you can redistribute it and/or modify it 102.10 @@ -430,7 +430,7 @@ 102.11 for(int i = 0; i < _size; i++) { 102.12 if (_is_oop[i]) { 102.13 // Handle conversion 102.14 - _value[i] = (intptr_t)Handle::raw_resolve((oop *)_value[i]); 102.15 + _value[i] = cast_from_oop<intptr_t>(Handle::raw_resolve((oop *)_value[i])); 102.16 } 102.17 } 102.18 // Return argument vector
103.1 --- a/src/share/vm/runtime/safepoint.cpp Wed Oct 09 13:00:20 2013 +0200 103.2 +++ b/src/share/vm/runtime/safepoint.cpp Wed Oct 09 05:03:34 2013 -0700 103.3 @@ -1,5 +1,5 @@ 103.4 /* 103.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 103.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 103.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 103.8 * 103.9 * This code is free software; you can redistribute it and/or modify it 103.10 @@ -745,14 +745,14 @@ 103.11 #endif 103.12 103.13 static void print_ptrs(intptr_t oldptr, intptr_t newptr, bool wasoop) { 103.14 - bool is_oop = newptr ? ((oop)newptr)->is_oop() : false; 103.15 + bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false; 103.16 tty->print_cr(PTR_FORMAT PTR_PAD " %s %c " PTR_FORMAT PTR_PAD " %s %s", 103.17 oldptr, wasoop?"oop":" ", oldptr == newptr ? ' ' : '!', 103.18 newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" ")); 103.19 } 103.20 103.21 static void print_longs(jlong oldptr, jlong newptr, bool wasoop) { 103.22 - bool is_oop = newptr ? ((oop)(intptr_t)newptr)->is_oop() : false; 103.23 + bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false; 103.24 tty->print_cr(PTR64_FORMAT " %s %c " PTR64_FORMAT " %s %s", 103.25 oldptr, wasoop?"oop":" ", oldptr == newptr ? ' ' : '!', 103.26 newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" "));
104.1 --- a/src/share/vm/runtime/sharedRuntime.cpp Wed Oct 09 13:00:20 2013 +0200 104.2 +++ b/src/share/vm/runtime/sharedRuntime.cpp Wed Oct 09 05:03:34 2013 -0700 104.3 @@ -1,5 +1,5 @@ 104.4 /* 104.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 104.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 104.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 104.8 * 104.9 * This code is free software; you can redistribute it and/or modify it 104.10 @@ -577,7 +577,7 @@ 104.11 assert(caller.is_interpreted_frame(), ""); 104.12 int args_size = ArgumentSizeComputer(sig).size() + 1; 104.13 assert(args_size <= caller.interpreter_frame_expression_stack_size(), "receiver must be on interpreter stack"); 104.14 - oop result = (oop) *caller.interpreter_frame_tos_at(args_size - 1); 104.15 + oop result = cast_to_oop(*caller.interpreter_frame_tos_at(args_size - 1)); 104.16 assert(Universe::heap()->is_in(result) && result->is_oop(), "receiver must be an oop"); 104.17 return result; 104.18 } 104.19 @@ -2875,7 +2875,7 @@ 104.20 ObjectSynchronizer::inflate_helper(kptr2->obj()); 104.21 // Now the displaced header is free to move 104.22 buf[i++] = (intptr_t)lock->displaced_header(); 104.23 - buf[i++] = (intptr_t)kptr2->obj(); 104.24 + buf[i++] = cast_from_oop<intptr_t>(kptr2->obj()); 104.25 } 104.26 } 104.27 assert( i - max_locals == active_monitor_count*2, "found the expected number of monitors" );
105.1 --- a/src/share/vm/runtime/synchronizer.cpp Wed Oct 09 13:00:20 2013 +0200 105.2 +++ b/src/share/vm/runtime/synchronizer.cpp Wed Oct 09 05:03:34 2013 -0700 105.3 @@ -154,7 +154,7 @@ 105.4 static volatile intptr_t ListLock = 0 ; // protects global monitor free-list cache 105.5 static volatile int MonitorFreeCount = 0 ; // # on gFreeList 105.6 static volatile int MonitorPopulation = 0 ; // # Extant -- in circulation 105.7 -#define CHAINMARKER ((oop)-1) 105.8 +#define CHAINMARKER (cast_to_oop<intptr_t>(-1)) 105.9 105.10 // ----------------------------------------------------------------------------- 105.11 // Fast Monitor Enter/Exit 105.12 @@ -510,7 +510,7 @@ 105.13 // then for each thread on the list, set the flag and unpark() the thread. 105.14 // This is conceptually similar to muxAcquire-muxRelease, except that muxRelease 105.15 // wakes at most one thread whereas we need to wake the entire list. 105.16 - int ix = (intptr_t(obj) >> 5) & (NINFLATIONLOCKS-1) ; 105.17 + int ix = (cast_from_oop<intptr_t>(obj) >> 5) & (NINFLATIONLOCKS-1) ; 105.18 int YieldThenBlock = 0 ; 105.19 assert (ix >= 0 && ix < NINFLATIONLOCKS, "invariant") ; 105.20 assert ((NINFLATIONLOCKS & (NINFLATIONLOCKS-1)) == 0, "invariant") ; 105.21 @@ -565,7 +565,7 @@ 105.22 // This variation has the property of being stable (idempotent) 105.23 // between STW operations. This can be useful in some of the 1-0 105.24 // synchronization schemes. 105.25 - intptr_t addrBits = intptr_t(obj) >> 3 ; 105.26 + intptr_t addrBits = cast_from_oop<intptr_t>(obj) >> 3 ; 105.27 value = addrBits ^ (addrBits >> 5) ^ GVars.stwRandom ; 105.28 } else 105.29 if (hashCode == 2) { 105.30 @@ -575,7 +575,7 @@ 105.31 value = ++GVars.hcSequence ; 105.32 } else 105.33 if (hashCode == 4) { 105.34 - value = intptr_t(obj) ; 105.35 + value = cast_from_oop<intptr_t>(obj) ; 105.36 } else { 105.37 // Marsaglia's xor-shift scheme with thread-specific state 105.38 // This is probably the best overall implementation -- we'll 105.39 @@ -1321,7 +1321,7 @@ 105.40 if (object->is_instance()) { 105.41 ResourceMark rm; 105.42 tty->print_cr("Inflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s", 105.43 - (intptr_t) object, (intptr_t) object->mark(), 105.44 + (void *) object, (intptr_t) object->mark(), 105.45 object->klass()->external_name()); 105.46 } 105.47 } 105.48 @@ -1371,7 +1371,7 @@ 105.49 if (object->is_instance()) { 105.50 ResourceMark rm; 105.51 tty->print_cr("Inflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s", 105.52 - (intptr_t) object, (intptr_t) object->mark(), 105.53 + (void *) object, (intptr_t) object->mark(), 105.54 object->klass()->external_name()); 105.55 } 105.56 } 105.57 @@ -1439,7 +1439,7 @@ 105.58 if (obj->is_instance()) { 105.59 ResourceMark rm; 105.60 tty->print_cr("Deflating object " INTPTR_FORMAT " , mark " INTPTR_FORMAT " , type %s", 105.61 - (intptr_t) obj, (intptr_t) obj->mark(), obj->klass()->external_name()); 105.62 + (void *) obj, (intptr_t) obj->mark(), obj->klass()->external_name()); 105.63 } 105.64 } 105.65
106.1 --- a/src/share/vm/runtime/thread.cpp Wed Oct 09 13:00:20 2013 +0200 106.2 +++ b/src/share/vm/runtime/thread.cpp Wed Oct 09 05:03:34 2013 -0700 106.3 @@ -1444,7 +1444,7 @@ 106.4 _in_deopt_handler = 0; 106.5 _doing_unsafe_access = false; 106.6 _stack_guard_state = stack_guard_unused; 106.7 - _exception_oop = NULL; 106.8 + (void)const_cast<oop&>(_exception_oop = NULL); 106.9 _exception_pc = 0; 106.10 _exception_handler_pc = 0; 106.11 _is_method_handle_return = 0;
107.1 --- a/src/share/vm/runtime/thread.hpp Wed Oct 09 13:00:20 2013 +0200 107.2 +++ b/src/share/vm/runtime/thread.hpp Wed Oct 09 05:03:34 2013 -0700 107.3 @@ -1278,7 +1278,7 @@ 107.4 address exception_handler_pc() const { return _exception_handler_pc; } 107.5 bool is_method_handle_return() const { return _is_method_handle_return == 1; } 107.6 107.7 - void set_exception_oop(oop o) { _exception_oop = o; } 107.8 + void set_exception_oop(oop o) { (void)const_cast<oop&>(_exception_oop = o); } 107.9 void set_exception_pc(address a) { _exception_pc = a; } 107.10 void set_exception_handler_pc(address a) { _exception_handler_pc = a; } 107.11 void set_is_method_handle_return(bool value) { _is_method_handle_return = value ? 1 : 0; }
108.1 --- a/src/share/vm/runtime/vframeArray.cpp Wed Oct 09 13:00:20 2013 +0200 108.2 +++ b/src/share/vm/runtime/vframeArray.cpp Wed Oct 09 05:03:34 2013 -0700 108.3 @@ -1,5 +1,5 @@ 108.4 /* 108.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 108.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 108.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 108.8 * 108.9 * This code is free software; you can redistribute it and/or modify it 108.10 @@ -111,7 +111,7 @@ 108.11 case T_OBJECT: 108.12 assert(!value->obj_is_scalar_replaced(), "object should be reallocated already"); 108.13 // preserve object type 108.14 - _locals->add( new StackValue((intptr_t) (value->get_obj()()), T_OBJECT )); 108.15 + _locals->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT )); 108.16 break; 108.17 case T_CONFLICT: 108.18 // A dead local. Will be initialized to null/zero. 108.19 @@ -136,7 +136,7 @@ 108.20 case T_OBJECT: 108.21 assert(!value->obj_is_scalar_replaced(), "object should be reallocated already"); 108.22 // preserve object type 108.23 - _expressions->add( new StackValue((intptr_t) (value->get_obj()()), T_OBJECT )); 108.24 + _expressions->add( new StackValue(cast_from_oop<intptr_t>((value->get_obj()())), T_OBJECT )); 108.25 break; 108.26 case T_CONFLICT: 108.27 // A dead stack element. Will be initialized to null/zero.
109.1 --- a/src/share/vm/runtime/vm_version.hpp Wed Oct 09 13:00:20 2013 +0200 109.2 +++ b/src/share/vm/runtime/vm_version.hpp Wed Oct 09 05:03:34 2013 -0700 109.3 @@ -78,7 +78,13 @@ 109.4 static const char* jre_release_version(); 109.5 109.6 // does HW support an 8-byte compare-exchange operation? 109.7 - static bool supports_cx8() {return _supports_cx8;} 109.8 + static bool supports_cx8() { 109.9 +#ifdef SUPPORTS_NATIVE_CX8 109.10 + return true; 109.11 +#else 109.12 + return _supports_cx8; 109.13 +#endif 109.14 + } 109.15 // does HW support atomic get-and-set or atomic get-and-add? Used 109.16 // to guide intrinsification decisions for Unsafe atomic ops 109.17 static bool supports_atomic_getset4() {return _supports_atomic_getset4;}
110.1 --- a/src/share/vm/services/classLoadingService.cpp Wed Oct 09 13:00:20 2013 +0200 110.2 +++ b/src/share/vm/services/classLoadingService.cpp Wed Oct 09 05:03:34 2013 -0700 110.3 @@ -1,5 +1,5 @@ 110.4 /* 110.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 110.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 110.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 110.8 * 110.9 * This code is free software; you can redistribute it and/or modify it 110.10 @@ -52,7 +52,7 @@ 110.11 len = name->utf8_length(); \ 110.12 } \ 110.13 HS_DTRACE_PROBE4(hotspot, class__##type, \ 110.14 - data, len, (clss)->class_loader(), (shared)); \ 110.15 + data, len, SOLARIS_ONLY((void *))(clss)->class_loader(), (shared)); \ 110.16 } 110.17 110.18 #else /* USDT2 */
111.1 --- a/src/share/vm/services/heapDumper.cpp Wed Oct 09 13:00:20 2013 +0200 111.2 +++ b/src/share/vm/services/heapDumper.cpp Wed Oct 09 05:03:34 2013 -0700 111.3 @@ -563,7 +563,7 @@ 111.4 } 111.5 111.6 void DumpWriter::write_objectID(oop o) { 111.7 - address a = (address)((uintptr_t)o); 111.8 + address a = (address)o; 111.9 #ifdef _LP64 111.10 write_u8((u8)a); 111.11 #else
112.1 --- a/src/share/vm/services/memoryManager.cpp Wed Oct 09 13:00:20 2013 +0200 112.2 +++ b/src/share/vm/services/memoryManager.cpp Wed Oct 09 05:03:34 2013 -0700 112.3 @@ -1,5 +1,5 @@ 112.4 /* 112.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 112.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 112.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 112.8 * 112.9 * This code is free software; you can redistribute it and/or modify it 112.10 @@ -45,7 +45,7 @@ 112.11 112.12 MemoryManager::MemoryManager() { 112.13 _num_pools = 0; 112.14 - _memory_mgr_obj = NULL; 112.15 + (void)const_cast<instanceOop&>(_memory_mgr_obj = NULL); 112.16 } 112.17 112.18 void MemoryManager::add_pool(MemoryPool* pool) {
113.1 --- a/src/share/vm/services/memoryPool.cpp Wed Oct 09 13:00:20 2013 +0200 113.2 +++ b/src/share/vm/services/memoryPool.cpp Wed Oct 09 05:03:34 2013 -0700 113.3 @@ -1,5 +1,5 @@ 113.4 /* 113.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 113.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 113.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 113.8 * 113.9 * This code is free software; you can redistribute it and/or modify it 113.10 @@ -45,7 +45,7 @@ 113.11 _name = name; 113.12 _initial_size = init_size; 113.13 _max_size = max_size; 113.14 - _memory_pool_obj = NULL; 113.15 + (void)const_cast<instanceOop&>(_memory_pool_obj = NULL); 113.16 _available_for_allocation = true; 113.17 _num_managers = 0; 113.18 _type = type;
114.1 --- a/src/share/vm/utilities/array.hpp Wed Oct 09 13:00:20 2013 +0200 114.2 +++ b/src/share/vm/utilities/array.hpp Wed Oct 09 05:03:34 2013 -0700 114.3 @@ -353,9 +353,9 @@ 114.4 // sort the array. 114.5 bool contains(const T& x) const { return index_of(x) >= 0; } 114.6 114.7 - T at(int i) const { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); return _data[i]; } 114.8 - void at_put(const int i, const T& x) { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); _data[i] = x; } 114.9 - T* adr_at(const int i) { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); return &_data[i]; } 114.10 + T at(int i) const { assert(i >= 0 && i< _length, err_msg("oob: 0 <= %d < %d", i, _length)); return _data[i]; } 114.11 + void at_put(const int i, const T& x) { assert(i >= 0 && i< _length, err_msg("oob: 0 <= %d < %d", i, _length)); _data[i] = x; } 114.12 + T* adr_at(const int i) { assert(i >= 0 && i< _length, err_msg("oob: 0 <= %d < %d", i, _length)); return &_data[i]; } 114.13 int find(const T& x) { return index_of(x); } 114.14 114.15 T at_acquire(const int which) { return OrderAccess::load_acquire(adr_at(which)); }
115.1 --- a/src/share/vm/utilities/globalDefinitions.hpp Wed Oct 09 13:00:20 2013 +0200 115.2 +++ b/src/share/vm/utilities/globalDefinitions.hpp Wed Oct 09 05:03:34 2013 -0700 115.3 @@ -967,9 +967,9 @@ 115.4 // (These must be implemented as #defines because C++ compilers are 115.5 // not obligated to inline non-integral constants!) 115.6 #define badAddress ((address)::badAddressVal) 115.7 -#define badOop ((oop)::badOopVal) 115.8 +#define badOop (cast_to_oop(::badOopVal)) 115.9 #define badHeapWord (::badHeapWordVal) 115.10 -#define badJNIHandle ((oop)::badJNIHandleVal) 115.11 +#define badJNIHandle (cast_to_oop(::badJNIHandleVal)) 115.12 115.13 // Default TaskQueue size is 16K (32-bit) or 128K (64-bit) 115.14 #define TASKQUEUE_SIZE (NOT_LP64(1<<14) LP64_ONLY(1<<17))
116.1 --- a/src/share/vm/utilities/globalDefinitions_visCPP.hpp Wed Oct 09 13:00:20 2013 +0200 116.2 +++ b/src/share/vm/utilities/globalDefinitions_visCPP.hpp Wed Oct 09 05:03:34 2013 -0700 116.3 @@ -189,6 +189,10 @@ 116.4 #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union (needed in windows.h) 116.5 #pragma warning( disable : 4511 ) // copy constructor could not be generated 116.6 #pragma warning( disable : 4291 ) // no matching operator delete found; memory will not be freed if initialization thows an exception 116.7 +#ifdef CHECK_UNHANDLED_OOPS 116.8 +#pragma warning( disable : 4521 ) // class has multiple copy ctors of a single type 116.9 +#pragma warning( disable : 4522 ) // class has multiple assignment operators of a single type 116.10 +#endif // CHECK_UNHANDLED_OOPS 116.11 #if _MSC_VER >= 1400 116.12 #pragma warning( disable : 4996 ) // unsafe string functions. Same as define _CRT_SECURE_NO_WARNINGS/_CRT_SECURE_NO_DEPRICATE 116.13 #endif
117.1 --- a/src/share/vm/utilities/hashtable.cpp Wed Oct 09 13:00:20 2013 +0200 117.2 +++ b/src/share/vm/utilities/hashtable.cpp Wed Oct 09 05:03:34 2013 -0700 117.3 @@ -1,5 +1,5 @@ 117.4 /* 117.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 117.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 117.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 117.8 * 117.9 * This code is free software; you can redistribute it and/or modify it 117.10 @@ -356,9 +356,9 @@ 117.11 template class Hashtable<Symbol*, mtSymbol>; 117.12 template class Hashtable<Klass*, mtClass>; 117.13 template class Hashtable<oop, mtClass>; 117.14 -#ifdef SOLARIS 117.15 +#if defined(SOLARIS) || defined(CHECK_UNHANDLED_OOPS) 117.16 template class Hashtable<oop, mtSymbol>; 117.17 -#endif 117.18 +#endif // SOLARIS || CHECK_UNHANDLED_OOPS 117.19 template class Hashtable<oopDesc*, mtSymbol>; 117.20 template class Hashtable<Symbol*, mtClass>; 117.21 template class HashtableEntry<Symbol*, mtSymbol>;
118.1 --- a/src/share/vm/utilities/taskqueue.hpp Wed Oct 09 13:00:20 2013 +0200 118.2 +++ b/src/share/vm/utilities/taskqueue.hpp Wed Oct 09 05:03:34 2013 -0700 118.3 @@ -322,11 +322,11 @@ 118.4 // Attempts to claim a task from the "local" end of the queue (the most 118.5 // recently pushed). If successful, returns true and sets t to the task; 118.6 // otherwise, returns false (the queue is empty). 118.7 - inline bool pop_local(E& t); 118.8 + inline bool pop_local(volatile E& t); 118.9 118.10 // Like pop_local(), but uses the "global" end of the queue (the least 118.11 // recently pushed). 118.12 - bool pop_global(E& t); 118.13 + bool pop_global(volatile E& t); 118.14 118.15 // Delete any resource associated with the queue. 118.16 ~GenericTaskQueue(); 118.17 @@ -424,7 +424,7 @@ 118.18 } 118.19 118.20 template<class E, MEMFLAGS F, unsigned int N> 118.21 -bool GenericTaskQueue<E, F, N>::pop_global(E& t) { 118.22 +bool GenericTaskQueue<E, F, N>::pop_global(volatile E& t) { 118.23 Age oldAge = _age.get(); 118.24 // Architectures with weak memory model require a barrier here 118.25 // to guarantee that bottom is not older than age, 118.26 @@ -701,7 +701,7 @@ 118.27 } 118.28 118.29 template<class E, MEMFLAGS F, unsigned int N> inline bool 118.30 -GenericTaskQueue<E, F, N>::pop_local(E& t) { 118.31 +GenericTaskQueue<E, F, N>::pop_local(volatile E& t) { 118.32 uint localBot = _bottom; 118.33 // This value cannot be N-1. That can only occur as a result of 118.34 // the assignment to bottom in this method. If it does, this method 118.35 @@ -799,7 +799,7 @@ 118.36 } 118.37 volatile ObjArrayTask& 118.38 operator =(const volatile ObjArrayTask& t) volatile { 118.39 - _obj = t._obj; 118.40 + (void)const_cast<oop&>(_obj = t._obj); 118.41 _index = t._index; 118.42 return *this; 118.43 }
119.1 --- a/test/TEST.groups Wed Oct 09 13:00:20 2013 +0200 119.2 +++ b/test/TEST.groups Wed Oct 09 05:03:34 2013 -0700 119.3 @@ -193,6 +193,7 @@ 119.4 serviceability/ \ 119.5 compiler/ \ 119.6 testlibrary/ \ 119.7 + testlibrary_tests/ \ 119.8 sanity/ \ 119.9 runtime/ \ 119.10 gc/ \
120.1 --- a/test/gc/g1/TestSummarizeRSetStats.java Wed Oct 09 13:00:20 2013 +0200 120.2 +++ b/test/gc/g1/TestSummarizeRSetStats.java Wed Oct 09 05:03:34 2013 -0700 120.3 @@ -25,140 +25,61 @@ 120.4 * @test TestSummarizeRSetStats.java 120.5 * @bug 8013895 120.6 * @library /testlibrary 120.7 - * @build TestSummarizeRSetStats 120.8 + * @build TestSummarizeRSetStatsTools TestSummarizeRSetStats 120.9 * @summary Verify output of -XX:+G1SummarizeRSetStats 120.10 * @run main TestSummarizeRSetStats 120.11 * 120.12 * Test the output of G1SummarizeRSetStats in conjunction with G1SummarizeRSetStatsPeriod. 120.13 */ 120.14 120.15 -import com.oracle.java.testlibrary.*; 120.16 -import java.lang.Thread; 120.17 -import java.util.ArrayList; 120.18 -import java.util.Arrays; 120.19 - 120.20 -class RunSystemGCs { 120.21 - // 4M size, both are directly allocated into the old gen 120.22 - static Object[] largeObject1 = new Object[1024 * 1024]; 120.23 - static Object[] largeObject2 = new Object[1024 * 1024]; 120.24 - 120.25 - static int[] temp; 120.26 - 120.27 - public static void main(String[] args) { 120.28 - // create some cross-references between these objects 120.29 - for (int i = 0; i < largeObject1.length; i++) { 120.30 - largeObject1[i] = largeObject2; 120.31 - } 120.32 - 120.33 - for (int i = 0; i < largeObject2.length; i++) { 120.34 - largeObject2[i] = largeObject1; 120.35 - } 120.36 - 120.37 - int numGCs = Integer.parseInt(args[0]); 120.38 - 120.39 - if (numGCs > 0) { 120.40 - // try to force a minor collection: the young gen is 4M, the 120.41 - // amount of data allocated below is roughly that (4*1024*1024 + 120.42 - // some header data) 120.43 - for (int i = 0; i < 1024 ; i++) { 120.44 - temp = new int[1024]; 120.45 - } 120.46 - } 120.47 - 120.48 - for (int i = 0; i < numGCs - 1; i++) { 120.49 - System.gc(); 120.50 - } 120.51 - } 120.52 -} 120.53 - 120.54 public class TestSummarizeRSetStats { 120.55 120.56 - public static String runTest(String[] additionalArgs, int numGCs) throws Exception { 120.57 - ArrayList<String> finalargs = new ArrayList<String>(); 120.58 - String[] defaultArgs = new String[] { 120.59 - "-XX:+UseG1GC", 120.60 - "-Xmn4m", 120.61 - "-Xmx20m", 120.62 - "-XX:InitiatingHeapOccupancyPercent=100", // we don't want the additional GCs due to initial marking 120.63 - "-XX:+PrintGC", 120.64 - "-XX:+UnlockDiagnosticVMOptions", 120.65 - "-XX:G1HeapRegionSize=1M", 120.66 - }; 120.67 - 120.68 - finalargs.addAll(Arrays.asList(defaultArgs)); 120.69 - 120.70 - if (additionalArgs != null) { 120.71 - finalargs.addAll(Arrays.asList(additionalArgs)); 120.72 - } 120.73 - 120.74 - finalargs.add(RunSystemGCs.class.getName()); 120.75 - finalargs.add(String.valueOf(numGCs)); 120.76 - 120.77 - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( 120.78 - finalargs.toArray(new String[0])); 120.79 - OutputAnalyzer output = new OutputAnalyzer(pb.start()); 120.80 - 120.81 - output.shouldHaveExitValue(0); 120.82 - 120.83 - String result = output.getStdout(); 120.84 - return result; 120.85 - } 120.86 - 120.87 - private static void expectStatistics(String result, int expectedCumulative, int expectedPeriodic) throws Exception { 120.88 - int actualTotal = result.split("Concurrent RS processed").length - 1; 120.89 - int actualCumulative = result.split("Cumulative RS summary").length - 1; 120.90 - 120.91 - if (expectedCumulative != actualCumulative) { 120.92 - throw new Exception("Incorrect amount of RSet summaries at the end. Expected " + expectedCumulative + ", got " + actualCumulative); 120.93 - } 120.94 - 120.95 - if (expectedPeriodic != (actualTotal - actualCumulative)) { 120.96 - throw new Exception("Incorrect amount of per-period RSet summaries at the end. Expected " + expectedPeriodic + ", got " + (actualTotal - actualCumulative)); 120.97 - } 120.98 - } 120.99 - 120.100 public static void main(String[] args) throws Exception { 120.101 String result; 120.102 120.103 - // no RSet statistics output 120.104 - result = runTest(null, 0); 120.105 - expectStatistics(result, 0, 0); 120.106 + if (!TestSummarizeRSetStatsTools.testingG1GC()) { 120.107 + return; 120.108 + } 120.109 120.110 - // no RSet statistics output 120.111 - result = runTest(null, 2); 120.112 - expectStatistics(result, 0, 0); 120.113 + // no remembered set summary output 120.114 + result = TestSummarizeRSetStatsTools.runTest(null, 0); 120.115 + TestSummarizeRSetStatsTools.expectRSetSummaries(result, 0, 0); 120.116 120.117 - // no RSet statistics output 120.118 - result = runTest(new String[] { "-XX:G1SummarizeRSetStatsPeriod=1" }, 3); 120.119 - expectStatistics(result, 0, 0); 120.120 + // no remembered set summary output 120.121 + result = TestSummarizeRSetStatsTools.runTest(null, 2); 120.122 + TestSummarizeRSetStatsTools.expectRSetSummaries(result, 0, 0); 120.123 120.124 - // single RSet statistics output at the end 120.125 - result = runTest(new String[] { "-XX:+G1SummarizeRSetStats" }, 0); 120.126 - expectStatistics(result, 1, 0); 120.127 + // no remembered set summary output 120.128 + result = TestSummarizeRSetStatsTools.runTest(new String[] { "-XX:G1SummarizeRSetStatsPeriod=1" }, 3); 120.129 + TestSummarizeRSetStatsTools.expectRSetSummaries(result, 0, 0); 120.130 120.131 - // single RSet statistics output at the end 120.132 - result = runTest(new String[] { "-XX:+G1SummarizeRSetStats" }, 2); 120.133 - expectStatistics(result, 1, 0); 120.134 + // single remembered set summary output at the end 120.135 + result = TestSummarizeRSetStatsTools.runTest(new String[] { "-XX:+G1SummarizeRSetStats" }, 0); 120.136 + TestSummarizeRSetStatsTools.expectRSetSummaries(result, 1, 0); 120.137 120.138 - // single RSet statistics output 120.139 - result = runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=1" }, 0); 120.140 - expectStatistics(result, 1, 0); 120.141 + // single remembered set summary output at the end 120.142 + result = TestSummarizeRSetStatsTools.runTest(new String[] { "-XX:+G1SummarizeRSetStats" }, 2); 120.143 + TestSummarizeRSetStatsTools.expectRSetSummaries(result, 1, 0); 120.144 120.145 - // two times RSet statistics output 120.146 - result = runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=1" }, 1); 120.147 - expectStatistics(result, 1, 1); 120.148 + // single remembered set summary output 120.149 + result = TestSummarizeRSetStatsTools.runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=1" }, 0); 120.150 + TestSummarizeRSetStatsTools.expectRSetSummaries(result, 1, 0); 120.151 120.152 - // four times RSet statistics output 120.153 - result = runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=1" }, 3); 120.154 - expectStatistics(result, 1, 3); 120.155 + // two times remembered set summary output 120.156 + result = TestSummarizeRSetStatsTools.runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=1" }, 1); 120.157 + TestSummarizeRSetStatsTools.expectRSetSummaries(result, 1, 2); 120.158 120.159 - // three times RSet statistics output 120.160 - result = runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=2" }, 3); 120.161 - expectStatistics(result, 1, 2); 120.162 + // four times remembered set summary output 120.163 + result = TestSummarizeRSetStatsTools.runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=1" }, 3); 120.164 + TestSummarizeRSetStatsTools.expectRSetSummaries(result, 1, 6); 120.165 120.166 - // single RSet statistics output 120.167 - result = runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=100" }, 3); 120.168 - expectStatistics(result, 1, 1); 120.169 + // three times remembered set summary output 120.170 + result = TestSummarizeRSetStatsTools.runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=2" }, 3); 120.171 + TestSummarizeRSetStatsTools.expectRSetSummaries(result, 1, 4); 120.172 + 120.173 + // single remembered set summary output 120.174 + result = TestSummarizeRSetStatsTools.runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=100" }, 3); 120.175 + TestSummarizeRSetStatsTools.expectRSetSummaries(result, 1, 2); 120.176 } 120.177 } 120.178
121.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 121.2 +++ b/test/gc/g1/TestSummarizeRSetStatsPerRegion.java Wed Oct 09 05:03:34 2013 -0700 121.3 @@ -0,0 +1,55 @@ 121.4 +/* 121.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 121.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 121.7 + * 121.8 + * This code is free software; you can redistribute it and/or modify it 121.9 + * under the terms of the GNU General Public License version 2 only, as 121.10 + * published by the Free Software Foundation. 121.11 + * 121.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 121.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 121.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 121.15 + * version 2 for more details (a copy is included in the LICENSE file that 121.16 + * accompanied this code). 121.17 + * 121.18 + * You should have received a copy of the GNU General Public License version 121.19 + * 2 along with this work; if not, write to the Free Software Foundation, 121.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 121.21 + * 121.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 121.23 + * or visit www.oracle.com if you need additional information or have any 121.24 + * questions. 121.25 + */ 121.26 + 121.27 +/* 121.28 + * @test TestSummarizeRSetStatsPerRegion.java 121.29 + * @bug 8014078 121.30 + * @library /testlibrary 121.31 + * @build TestSummarizeRSetStatsTools TestSummarizeRSetStatsPerRegion 121.32 + * @summary Verify output of -XX:+G1SummarizeRSetStats in regards to per-region type output 121.33 + * @run main TestSummarizeRSetStatsPerRegion 121.34 + */ 121.35 + 121.36 +import com.oracle.java.testlibrary.*; 121.37 +import java.lang.Thread; 121.38 +import java.util.ArrayList; 121.39 +import java.util.Arrays; 121.40 + 121.41 +public class TestSummarizeRSetStatsPerRegion { 121.42 + 121.43 + public static void main(String[] args) throws Exception { 121.44 + String result; 121.45 + 121.46 + if (!TestSummarizeRSetStatsTools.testingG1GC()) { 121.47 + return; 121.48 + } 121.49 + 121.50 + // single remembered set summary output at the end 121.51 + result = TestSummarizeRSetStatsTools.runTest(new String[] { "-XX:+G1SummarizeRSetStats" }, 0); 121.52 + TestSummarizeRSetStatsTools.expectPerRegionRSetSummaries(result, 1, 0); 121.53 + 121.54 + // two times remembered set summary output 121.55 + result = TestSummarizeRSetStatsTools.runTest(new String[] { "-XX:+G1SummarizeRSetStats", "-XX:G1SummarizeRSetStatsPeriod=1" }, 1); 121.56 + TestSummarizeRSetStatsTools.expectPerRegionRSetSummaries(result, 1, 2); 121.57 + } 121.58 +}
122.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 122.2 +++ b/test/gc/g1/TestSummarizeRSetStatsThreads.java Wed Oct 09 05:03:34 2013 -0700 122.3 @@ -0,0 +1,83 @@ 122.4 +/* 122.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 122.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 122.7 + * 122.8 + * This code is free software; you can redistribute it and/or modify it 122.9 + * under the terms of the GNU General Public License version 2 only, as 122.10 + * published by the Free Software Foundation. 122.11 + * 122.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 122.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 122.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 122.15 + * version 2 for more details (a copy is included in the LICENSE file that 122.16 + * accompanied this code). 122.17 + * 122.18 + * You should have received a copy of the GNU General Public License version 122.19 + * 2 along with this work; if not, write to the Free Software Foundation, 122.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 122.21 + * 122.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 122.23 + * or visit www.oracle.com if you need additional information or have any 122.24 + * questions. 122.25 + */ 122.26 + 122.27 +/* 122.28 + * @test TestSummarizeRSetStatsThreads 122.29 + * @bug 8025441 122.30 + * @summary Ensure that various values of worker threads/concurrent 122.31 + * refinement threads do not crash the VM. 122.32 + * @key gc 122.33 + * @library /testlibrary 122.34 + */ 122.35 + 122.36 +import java.util.regex.Matcher; 122.37 +import java.util.regex.Pattern; 122.38 + 122.39 +import com.oracle.java.testlibrary.ProcessTools; 122.40 +import com.oracle.java.testlibrary.OutputAnalyzer; 122.41 + 122.42 +public class TestSummarizeRSetStatsThreads { 122.43 + 122.44 + private static void runTest(int refinementThreads, int workerThreads) throws Exception { 122.45 + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", 122.46 + "-XX:+UnlockDiagnosticVMOptions", 122.47 + "-XX:+G1SummarizeRSetStats", 122.48 + "-XX:G1ConcRefinementThreads=" + refinementThreads, 122.49 + "-XX:ParallelGCThreads=" + workerThreads, 122.50 + "-version"); 122.51 + 122.52 + OutputAnalyzer output = new OutputAnalyzer(pb.start()); 122.53 + 122.54 + // check output to contain the string "Concurrent RS threads times (s)" followed by 122.55 + // the correct number of values in the next line. 122.56 + 122.57 + // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used. 122.58 + // Additionally use at least one thread. 122.59 + int expectedNumRefinementThreads = refinementThreads == 0 ? workerThreads : refinementThreads; 122.60 + expectedNumRefinementThreads = Math.max(1, expectedNumRefinementThreads); 122.61 + // create the pattern made up of n copies of a floating point number pattern 122.62 + String numberPattern = String.format("%0" + expectedNumRefinementThreads + "d", 0) 122.63 + .replace("0", "\\s+\\d+\\.\\d+"); 122.64 + String pattern = "Concurrent RS threads times \\(s\\)$" + numberPattern + "$"; 122.65 + Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout()); 122.66 + 122.67 + if (!m.find()) { 122.68 + throw new Exception("Could not find correct output for concurrent RS threads times in stdout," + 122.69 + " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout()); 122.70 + } 122.71 + output.shouldHaveExitValue(0); 122.72 + } 122.73 + 122.74 + public static void main(String[] args) throws Exception { 122.75 + if (!TestSummarizeRSetStatsTools.testingG1GC()) { 122.76 + return; 122.77 + } 122.78 + // different valid combinations of number of refinement and gc worker threads 122.79 + runTest(0, 0); 122.80 + runTest(0, 5); 122.81 + runTest(5, 0); 122.82 + runTest(10, 10); 122.83 + runTest(1, 2); 122.84 + runTest(4, 3); 122.85 + } 122.86 +}
123.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 123.2 +++ b/test/gc/g1/TestSummarizeRSetStatsTools.java Wed Oct 09 05:03:34 2013 -0700 123.3 @@ -0,0 +1,154 @@ 123.4 +/* 123.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 123.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 123.7 + * 123.8 + * This code is free software; you can redistribute it and/or modify it 123.9 + * under the terms of the GNU General Public License version 2 only, as 123.10 + * published by the Free Software Foundation. 123.11 + * 123.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 123.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 123.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 123.15 + * version 2 for more details (a copy is included in the LICENSE file that 123.16 + * accompanied this code). 123.17 + * 123.18 + * You should have received a copy of the GNU General Public License version 123.19 + * 2 along with this work; if not, write to the Free Software Foundation, 123.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 123.21 + * 123.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 123.23 + * or visit www.oracle.com if you need additional information or have any 123.24 + * questions. 123.25 + */ 123.26 + 123.27 +/* 123.28 + * Common helpers for TestSummarizeRSetStats* tests 123.29 + */ 123.30 + 123.31 +import sun.management.ManagementFactoryHelper; 123.32 +import com.sun.management.HotSpotDiagnosticMXBean; 123.33 +import com.sun.management.VMOption; 123.34 + 123.35 +import com.oracle.java.testlibrary.*; 123.36 +import java.util.regex.Matcher; 123.37 +import java.util.regex.Pattern; 123.38 +import java.lang.Thread; 123.39 +import java.util.ArrayList; 123.40 +import java.util.Arrays; 123.41 + 123.42 +class VerifySummaryOutput { 123.43 + // 4M size, both are directly allocated into the old gen 123.44 + static Object[] largeObject1 = new Object[1024 * 1024]; 123.45 + static Object[] largeObject2 = new Object[1024 * 1024]; 123.46 + 123.47 + static int[] temp; 123.48 + 123.49 + public static void main(String[] args) { 123.50 + // create some cross-references between these objects 123.51 + for (int i = 0; i < largeObject1.length; i++) { 123.52 + largeObject1[i] = largeObject2; 123.53 + } 123.54 + 123.55 + for (int i = 0; i < largeObject2.length; i++) { 123.56 + largeObject2[i] = largeObject1; 123.57 + } 123.58 + 123.59 + int numGCs = Integer.parseInt(args[0]); 123.60 + 123.61 + if (numGCs > 0) { 123.62 + // try to force a minor collection: the young gen is 4M, the 123.63 + // amount of data allocated below is roughly that (4*1024*1024 + 123.64 + // some header data) 123.65 + for (int i = 0; i < 1024 ; i++) { 123.66 + temp = new int[1024]; 123.67 + } 123.68 + } 123.69 + 123.70 + for (int i = 0; i < numGCs - 1; i++) { 123.71 + System.gc(); 123.72 + } 123.73 + } 123.74 +} 123.75 + 123.76 +public class TestSummarizeRSetStatsTools { 123.77 + 123.78 + // the VM is currently run using G1GC, i.e. trying to test G1 functionality. 123.79 + public static boolean testingG1GC() { 123.80 + HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); 123.81 + 123.82 + VMOption option = diagnostic.getVMOption("UseG1GC"); 123.83 + if (option.getValue().equals("false")) { 123.84 + System.out.println("Skipping this test. It is only a G1 test."); 123.85 + return false; 123.86 + } 123.87 + return true; 123.88 + } 123.89 + 123.90 + public static String runTest(String[] additionalArgs, int numGCs) throws Exception { 123.91 + ArrayList<String> finalargs = new ArrayList<String>(); 123.92 + String[] defaultArgs = new String[] { 123.93 + "-XX:+UseG1GC", 123.94 + "-XX:+UseCompressedOops", 123.95 + "-Xmn4m", 123.96 + "-Xmx20m", 123.97 + "-XX:InitiatingHeapOccupancyPercent=100", // we don't want the additional GCs due to initial marking 123.98 + "-XX:+PrintGC", 123.99 + "-XX:+UnlockDiagnosticVMOptions", 123.100 + "-XX:G1HeapRegionSize=1M", 123.101 + }; 123.102 + 123.103 + finalargs.addAll(Arrays.asList(defaultArgs)); 123.104 + 123.105 + if (additionalArgs != null) { 123.106 + finalargs.addAll(Arrays.asList(additionalArgs)); 123.107 + } 123.108 + 123.109 + finalargs.add(VerifySummaryOutput.class.getName()); 123.110 + finalargs.add(String.valueOf(numGCs)); 123.111 + 123.112 + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( 123.113 + finalargs.toArray(new String[0])); 123.114 + OutputAnalyzer output = new OutputAnalyzer(pb.start()); 123.115 + 123.116 + output.shouldHaveExitValue(0); 123.117 + 123.118 + String result = output.getStdout(); 123.119 + return result; 123.120 + } 123.121 + 123.122 + private static void checkCounts(int expected, int actual, String which) throws Exception { 123.123 + if (expected != actual) { 123.124 + throw new Exception("RSet summaries mention " + which + " regions an incorrect number of times. Expected " + expected + ", got " + actual); 123.125 + } 123.126 + } 123.127 + 123.128 + public static void expectPerRegionRSetSummaries(String result, int expectedCumulative, int expectedPeriodic) throws Exception { 123.129 + expectRSetSummaries(result, expectedCumulative, expectedPeriodic); 123.130 + int actualYoung = result.split("Young regions").length - 1; 123.131 + int actualHumonguous = result.split("Humonguous regions").length - 1; 123.132 + int actualFree = result.split("Free regions").length - 1; 123.133 + int actualOther = result.split("Old regions").length - 1; 123.134 + 123.135 + // the strings we check for above are printed four times per summary 123.136 + int expectedPerRegionTypeInfo = (expectedCumulative + expectedPeriodic) * 4; 123.137 + 123.138 + checkCounts(expectedPerRegionTypeInfo, actualYoung, "Young"); 123.139 + checkCounts(expectedPerRegionTypeInfo, actualHumonguous, "Humonguous"); 123.140 + checkCounts(expectedPerRegionTypeInfo, actualFree, "Free"); 123.141 + checkCounts(expectedPerRegionTypeInfo, actualOther, "Old"); 123.142 + } 123.143 + 123.144 + public static void expectRSetSummaries(String result, int expectedCumulative, int expectedPeriodic) throws Exception { 123.145 + int actualTotal = result.split("concurrent refinement").length - 1; 123.146 + int actualCumulative = result.split("Cumulative RS summary").length - 1; 123.147 + 123.148 + if (expectedCumulative != actualCumulative) { 123.149 + throw new Exception("Incorrect amount of RSet summaries at the end. Expected " + expectedCumulative + ", got " + actualCumulative); 123.150 + } 123.151 + 123.152 + if (expectedPeriodic != (actualTotal - actualCumulative)) { 123.153 + throw new Exception("Incorrect amount of per-period RSet summaries at the end. Expected " + expectedPeriodic + ", got " + (actualTotal - actualCumulative)); 123.154 + } 123.155 + } 123.156 +} 123.157 +
124.1 --- a/test/gc/metaspace/G1AddMetaspaceDependency.java Wed Oct 09 13:00:20 2013 +0200 124.2 +++ b/test/gc/metaspace/G1AddMetaspaceDependency.java Wed Oct 09 05:03:34 2013 -0700 124.3 @@ -107,7 +107,6 @@ 124.4 Loader f_loader = new Loader(b_name, b_bytes, a_name, a_loader); 124.5 Loader g_loader = new Loader(b_name, b_bytes, a_name, a_loader); 124.6 124.7 - byte[] b = new byte[20 * 2 << 20]; 124.8 Class<?> c; 124.9 c = b_loader.loadClass(b_name); 124.10 c = c_loader.loadClass(b_name);
125.1 --- a/test/gc/metaspace/TestPerfCountersAndMemoryPools.java Wed Oct 09 13:00:20 2013 +0200 125.2 +++ b/test/gc/metaspace/TestPerfCountersAndMemoryPools.java Wed Oct 09 05:03:34 2013 -0700 125.3 @@ -29,10 +29,11 @@ 125.4 125.5 /* @test TestPerfCountersAndMemoryPools 125.6 * @bug 8023476 125.7 + * @library /testlibrary 125.8 * @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace 125.9 * report the same data. 125.10 - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData TestPerfCountersAndMemoryPools 125.11 - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData TestPerfCountersAndMemoryPools 125.12 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools 125.13 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools 125.14 */ 125.15 public class TestPerfCountersAndMemoryPools { 125.16 public static void main(String[] args) throws Exception { 125.17 @@ -43,11 +44,11 @@ 125.18 } 125.19 } 125.20 125.21 - private static MemoryUsage getMemoryUsage(String memoryPoolName) { 125.22 + private static MemoryPoolMXBean getMemoryPool(String memoryPoolName) { 125.23 List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans(); 125.24 for (MemoryPoolMXBean pool : pools) { 125.25 if (pool.getName().equals(memoryPoolName)) { 125.26 - return pool.getUsage(); 125.27 + return pool; 125.28 } 125.29 } 125.30 125.31 @@ -57,19 +58,18 @@ 125.32 125.33 private static void checkMemoryUsage(String memoryPoolName, String perfNS) 125.34 throws Exception { 125.35 - // Need to do a gc before each comparison to update the perf counters 125.36 + MemoryPoolMXBean pool = getMemoryPool(memoryPoolName); 125.37 125.38 + // Must do a GC to update performance counters 125.39 System.gc(); 125.40 - MemoryUsage mu = getMemoryUsage(memoryPoolName); 125.41 - assertEQ(getMinCapacity(perfNS), mu.getInit()); 125.42 + assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit()); 125.43 125.44 + // Must do a second GC to update the perfomance counters again, since 125.45 + // the call pool.getUsage().getInit() could have allocated some 125.46 + // metadata. 125.47 System.gc(); 125.48 - mu = getMemoryUsage(memoryPoolName); 125.49 - assertEQ(getUsed(perfNS), mu.getUsed()); 125.50 - 125.51 - System.gc(); 125.52 - mu = getMemoryUsage(memoryPoolName); 125.53 - assertEQ(getCapacity(perfNS), mu.getCommitted()); 125.54 + assertEQ(getUsed(perfNS), pool.getUsage().getUsed()); 125.55 + assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted()); 125.56 } 125.57 125.58 private static long getMinCapacity(String ns) throws Exception {
126.1 --- a/test/testlibrary/AssertsTest.java Wed Oct 09 13:00:20 2013 +0200 126.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 126.3 @@ -1,237 +0,0 @@ 126.4 -/* 126.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 126.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 126.7 - * 126.8 - * This code is free software; you can redistribute it and/or modify it 126.9 - * under the terms of the GNU General Public License version 2 only, as 126.10 - * published by the Free Software Foundation. 126.11 - * 126.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 126.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 126.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 126.15 - * version 2 for more details (a copy is included in the LICENSE file that 126.16 - * accompanied this code). 126.17 - * 126.18 - * You should have received a copy of the GNU General Public License version 126.19 - * 2 along with this work; if not, write to the Free Software Foundation, 126.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 126.21 - * 126.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 126.23 - * or visit www.oracle.com if you need additional information or have any 126.24 - * questions. 126.25 - */ 126.26 - 126.27 -import static com.oracle.java.testlibrary.Asserts.*; 126.28 - 126.29 -/* @test 126.30 - * @summary Tests the different assertions in the Assert class 126.31 - * @library /testlibrary 126.32 - */ 126.33 -public class AssertsTest { 126.34 - private static class Foo implements Comparable<Foo> { 126.35 - final int id; 126.36 - public Foo(int id) { 126.37 - this.id = id; 126.38 - } 126.39 - 126.40 - public int compareTo(Foo f) { 126.41 - return new Integer(id).compareTo(new Integer(f.id)); 126.42 - } 126.43 - } 126.44 - 126.45 - public static void main(String[] args) throws Exception { 126.46 - testLessThan(); 126.47 - testLessThanOrEqual(); 126.48 - testEquals(); 126.49 - testGreaterThanOrEqual(); 126.50 - testGreaterThan(); 126.51 - testNotEquals(); 126.52 - testNull(); 126.53 - testNotNull(); 126.54 - testTrue(); 126.55 - testFalse(); 126.56 - } 126.57 - 126.58 - private static void testLessThan() throws Exception { 126.59 - expectPass(Assertion.LT, 1, 2); 126.60 - 126.61 - expectFail(Assertion.LT, 2, 2); 126.62 - expectFail(Assertion.LT, 2, 1); 126.63 - expectFail(Assertion.LT, null, 2); 126.64 - expectFail(Assertion.LT, 2, null); 126.65 - } 126.66 - 126.67 - private static void testLessThanOrEqual() throws Exception { 126.68 - expectPass(Assertion.LTE, 1, 2); 126.69 - expectPass(Assertion.LTE, 2, 2); 126.70 - 126.71 - expectFail(Assertion.LTE, 3, 2); 126.72 - expectFail(Assertion.LTE, null, 2); 126.73 - expectFail(Assertion.LTE, 2, null); 126.74 - } 126.75 - 126.76 - private static void testEquals() throws Exception { 126.77 - expectPass(Assertion.EQ, 1, 1); 126.78 - expectPass(Assertion.EQ, null, null); 126.79 - 126.80 - Foo f1 = new Foo(1); 126.81 - expectPass(Assertion.EQ, f1, f1); 126.82 - 126.83 - Foo f2 = new Foo(1); 126.84 - expectFail(Assertion.EQ, f1, f2); 126.85 - expectFail(Assertion.LTE, null, 2); 126.86 - expectFail(Assertion.LTE, 2, null); 126.87 - } 126.88 - 126.89 - private static void testGreaterThanOrEqual() throws Exception { 126.90 - expectPass(Assertion.GTE, 1, 1); 126.91 - expectPass(Assertion.GTE, 2, 1); 126.92 - 126.93 - expectFail(Assertion.GTE, 1, 2); 126.94 - expectFail(Assertion.GTE, null, 2); 126.95 - expectFail(Assertion.GTE, 2, null); 126.96 - } 126.97 - 126.98 - private static void testGreaterThan() throws Exception { 126.99 - expectPass(Assertion.GT, 2, 1); 126.100 - 126.101 - expectFail(Assertion.GT, 1, 1); 126.102 - expectFail(Assertion.GT, 1, 2); 126.103 - expectFail(Assertion.GT, null, 2); 126.104 - expectFail(Assertion.GT, 2, null); 126.105 - } 126.106 - 126.107 - private static void testNotEquals() throws Exception { 126.108 - expectPass(Assertion.NE, null, 1); 126.109 - expectPass(Assertion.NE, 1, null); 126.110 - 126.111 - Foo f1 = new Foo(1); 126.112 - Foo f2 = new Foo(1); 126.113 - expectPass(Assertion.NE, f1, f2); 126.114 - 126.115 - expectFail(Assertion.NE, null, null); 126.116 - expectFail(Assertion.NE, f1, f1); 126.117 - expectFail(Assertion.NE, 1, 1); 126.118 - } 126.119 - 126.120 - private static void testNull() throws Exception { 126.121 - expectPass(Assertion.NULL, null); 126.122 - 126.123 - expectFail(Assertion.NULL, 1); 126.124 - } 126.125 - 126.126 - private static void testNotNull() throws Exception { 126.127 - expectPass(Assertion.NOTNULL, 1); 126.128 - 126.129 - expectFail(Assertion.NOTNULL, null); 126.130 - } 126.131 - 126.132 - private static void testTrue() throws Exception { 126.133 - expectPass(Assertion.TRUE, true); 126.134 - 126.135 - expectFail(Assertion.TRUE, false); 126.136 - } 126.137 - 126.138 - private static void testFalse() throws Exception { 126.139 - expectPass(Assertion.FALSE, false); 126.140 - 126.141 - expectFail(Assertion.FALSE, true); 126.142 - } 126.143 - 126.144 - private static <T extends Comparable<T>> void expectPass(Assertion assertion, T ... args) 126.145 - throws Exception { 126.146 - Assertion.run(assertion, args); 126.147 - } 126.148 - 126.149 - private static <T extends Comparable<T>> void expectFail(Assertion assertion, T ... args) 126.150 - throws Exception { 126.151 - try { 126.152 - Assertion.run(assertion, args); 126.153 - } catch (RuntimeException e) { 126.154 - return; 126.155 - } 126.156 - throw new Exception("Expected " + Assertion.format(assertion, (Object[]) args) + 126.157 - " to throw a RuntimeException"); 126.158 - } 126.159 - 126.160 -} 126.161 - 126.162 -enum Assertion { 126.163 - LT, LTE, EQ, GTE, GT, NE, NULL, NOTNULL, FALSE, TRUE; 126.164 - 126.165 - public static <T extends Comparable<T>> void run(Assertion assertion, T ... args) { 126.166 - String msg = "Expected " + format(assertion, args) + " to pass"; 126.167 - switch (assertion) { 126.168 - case LT: 126.169 - assertLessThan(args[0], args[1], msg); 126.170 - break; 126.171 - case LTE: 126.172 - assertLessThanOrEqual(args[0], args[1], msg); 126.173 - break; 126.174 - case EQ: 126.175 - assertEquals(args[0], args[1], msg); 126.176 - break; 126.177 - case GTE: 126.178 - assertGreaterThanOrEqual(args[0], args[1], msg); 126.179 - break; 126.180 - case GT: 126.181 - assertGreaterThan(args[0], args[1], msg); 126.182 - break; 126.183 - case NE: 126.184 - assertNotEquals(args[0], args[1], msg); 126.185 - break; 126.186 - case NULL: 126.187 - assertNull(args == null ? args : args[0], msg); 126.188 - break; 126.189 - case NOTNULL: 126.190 - assertNotNull(args == null ? args : args[0], msg); 126.191 - break; 126.192 - case FALSE: 126.193 - assertFalse((Boolean) args[0], msg); 126.194 - break; 126.195 - case TRUE: 126.196 - assertTrue((Boolean) args[0], msg); 126.197 - break; 126.198 - default: 126.199 - // do nothing 126.200 - } 126.201 - } 126.202 - 126.203 - public static String format(Assertion assertion, Object ... args) { 126.204 - switch (assertion) { 126.205 - case LT: 126.206 - return asString("assertLessThan", args); 126.207 - case LTE: 126.208 - return asString("assertLessThanOrEqual", args); 126.209 - case EQ: 126.210 - return asString("assertEquals", args); 126.211 - case GTE: 126.212 - return asString("assertGreaterThanOrEquals", args); 126.213 - case GT: 126.214 - return asString("assertGreaterThan", args); 126.215 - case NE: 126.216 - return asString("assertNotEquals", args); 126.217 - case NULL: 126.218 - return asString("assertNull", args); 126.219 - case NOTNULL: 126.220 - return asString("assertNotNull", args); 126.221 - case FALSE: 126.222 - return asString("assertFalse", args); 126.223 - case TRUE: 126.224 - return asString("assertTrue", args); 126.225 - default: 126.226 - return ""; 126.227 - } 126.228 - } 126.229 - 126.230 - private static String asString(String assertion, Object ... args) { 126.231 - if (args == null) { 126.232 - return String.format("%s(null)", assertion); 126.233 - } 126.234 - if (args.length == 1) { 126.235 - return String.format("%s(%s)", assertion, args[0]); 126.236 - } else { 126.237 - return String.format("%s(%s, %s)", assertion, args[0], args[1]); 126.238 - } 126.239 - } 126.240 -}
127.1 --- a/test/testlibrary/OutputAnalyzerReportingTest.java Wed Oct 09 13:00:20 2013 +0200 127.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 127.3 @@ -1,124 +0,0 @@ 127.4 -/* 127.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 127.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 127.7 - * 127.8 - * This code is free software; you can redistribute it and/or modify it 127.9 - * under the terms of the GNU General Public License version 2 only, as 127.10 - * published by the Free Software Foundation. 127.11 - * 127.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 127.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 127.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 127.15 - * version 2 for more details (a copy is included in the LICENSE file that 127.16 - * accompanied this code). 127.17 - * 127.18 - * You should have received a copy of the GNU General Public License version 127.19 - * 2 along with this work; if not, write to the Free Software Foundation, 127.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 127.21 - * 127.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 127.23 - * or visit www.oracle.com if you need additional information or have any 127.24 - * questions. 127.25 - */ 127.26 - 127.27 - 127.28 -/* 127.29 - * @test 127.30 - * @summary Test the OutputAnalyzer reporting functionality, 127.31 - * such as printing additional diagnostic info 127.32 - * (exit code, stdout, stderr, command line, etc.) 127.33 - * @library /testlibrary 127.34 - */ 127.35 - 127.36 -import java.io.ByteArrayOutputStream; 127.37 -import java.io.PrintStream; 127.38 - 127.39 -import com.oracle.java.testlibrary.OutputAnalyzer; 127.40 -import com.oracle.java.testlibrary.ProcessTools; 127.41 - 127.42 - 127.43 -public class OutputAnalyzerReportingTest { 127.44 - 127.45 - public static void main(String[] args) throws Exception { 127.46 - // Create the output analyzer under test 127.47 - String stdout = "aaaaaa"; 127.48 - String stderr = "bbbbbb"; 127.49 - OutputAnalyzer output = new OutputAnalyzer(stdout, stderr); 127.50 - 127.51 - // Expected summary values should be the same for all cases, 127.52 - // since the outputAnalyzer object is the same 127.53 - String expectedExitValue = "-1"; 127.54 - String expectedSummary = 127.55 - " stdout: [" + stdout + "];\n" + 127.56 - " stderr: [" + stderr + "]\n" + 127.57 - " exitValue = " + expectedExitValue + "\n"; 127.58 - 127.59 - 127.60 - DiagnosticSummaryTestRunner testRunner = 127.61 - new DiagnosticSummaryTestRunner(); 127.62 - 127.63 - // should have exit value 127.64 - testRunner.init(expectedSummary); 127.65 - int unexpectedExitValue = 2; 127.66 - try { 127.67 - output.shouldHaveExitValue(unexpectedExitValue); 127.68 - } catch (RuntimeException e) { } 127.69 - testRunner.closeAndCheckResults(); 127.70 - 127.71 - // should not contain 127.72 - testRunner.init(expectedSummary); 127.73 - try { 127.74 - output.shouldNotContain(stdout); 127.75 - } catch (RuntimeException e) { } 127.76 - testRunner.closeAndCheckResults(); 127.77 - 127.78 - // should contain 127.79 - testRunner.init(expectedSummary); 127.80 - try { 127.81 - output.shouldContain("unexpected-stuff"); 127.82 - } catch (RuntimeException e) { } 127.83 - testRunner.closeAndCheckResults(); 127.84 - 127.85 - // should not match 127.86 - testRunner.init(expectedSummary); 127.87 - try { 127.88 - output.shouldNotMatch("[a]"); 127.89 - } catch (RuntimeException e) { } 127.90 - testRunner.closeAndCheckResults(); 127.91 - 127.92 - // should match 127.93 - testRunner.init(expectedSummary); 127.94 - try { 127.95 - output.shouldMatch("[qwerty]"); 127.96 - } catch (RuntimeException e) { } 127.97 - testRunner.closeAndCheckResults(); 127.98 - 127.99 - } 127.100 - 127.101 - private static class DiagnosticSummaryTestRunner { 127.102 - private ByteArrayOutputStream byteStream = 127.103 - new ByteArrayOutputStream(10000); 127.104 - 127.105 - private String expectedSummary = ""; 127.106 - private PrintStream errStream; 127.107 - 127.108 - 127.109 - public void init(String expectedSummary) { 127.110 - this.expectedSummary = expectedSummary; 127.111 - byteStream.reset(); 127.112 - errStream = new PrintStream(byteStream); 127.113 - System.setErr(errStream); 127.114 - } 127.115 - 127.116 - public void closeAndCheckResults() { 127.117 - // check results 127.118 - errStream.close(); 127.119 - String stdErrStr = byteStream.toString(); 127.120 - if (!stdErrStr.contains(expectedSummary)) { 127.121 - throw new RuntimeException("The output does not contain " 127.122 - + "the diagnostic message, or the message is incorrect"); 127.123 - } 127.124 - } 127.125 - } 127.126 - 127.127 -}
128.1 --- a/test/testlibrary/OutputAnalyzerTest.java Wed Oct 09 13:00:20 2013 +0200 128.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 128.3 @@ -1,193 +0,0 @@ 128.4 -/* 128.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 128.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 128.7 - * 128.8 - * This code is free software; you can redistribute it and/or modify it 128.9 - * under the terms of the GNU General Public License version 2 only, as 128.10 - * published by the Free Software Foundation. 128.11 - * 128.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 128.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 128.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 128.15 - * version 2 for more details (a copy is included in the LICENSE file that 128.16 - * accompanied this code). 128.17 - * 128.18 - * You should have received a copy of the GNU General Public License version 128.19 - * 2 along with this work; if not, write to the Free Software Foundation, 128.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 128.21 - * 128.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 128.23 - * or visit www.oracle.com if you need additional information or have any 128.24 - * questions. 128.25 - */ 128.26 - 128.27 -/* 128.28 - * @test 128.29 - * @summary Test the OutputAnalyzer utility class 128.30 - * @library /testlibrary 128.31 - */ 128.32 - 128.33 -import com.oracle.java.testlibrary.OutputAnalyzer; 128.34 - 128.35 -public class OutputAnalyzerTest { 128.36 - 128.37 - public static void main(String args[]) throws Exception { 128.38 - 128.39 - String stdout = "aaaaaa"; 128.40 - String stderr = "bbbbbb"; 128.41 - 128.42 - // Regexps used for testing pattern matching of the test input 128.43 - String stdoutPattern = "[a]"; 128.44 - String stderrPattern = "[b]"; 128.45 - String nonExistingPattern = "[c]"; 128.46 - 128.47 - OutputAnalyzer output = new OutputAnalyzer(stdout, stderr); 128.48 - 128.49 - if (!stdout.equals(output.getStdout())) { 128.50 - throw new Exception("getStdout() returned '" + output.getStdout() + "', expected '" + stdout + "'"); 128.51 - } 128.52 - 128.53 - if (!stderr.equals(output.getStderr())) { 128.54 - throw new Exception("getStderr() returned '" + output.getStderr() + "', expected '" + stderr + "'"); 128.55 - } 128.56 - 128.57 - try { 128.58 - output.shouldContain(stdout); 128.59 - output.stdoutShouldContain(stdout); 128.60 - output.shouldContain(stderr); 128.61 - output.stderrShouldContain(stderr); 128.62 - } catch (RuntimeException e) { 128.63 - throw new Exception("shouldContain() failed", e); 128.64 - } 128.65 - 128.66 - try { 128.67 - output.shouldContain("cccc"); 128.68 - throw new Exception("shouldContain() failed to throw exception"); 128.69 - } catch (RuntimeException e) { 128.70 - // expected 128.71 - } 128.72 - 128.73 - try { 128.74 - output.stdoutShouldContain(stderr); 128.75 - throw new Exception("stdoutShouldContain() failed to throw exception"); 128.76 - } catch (RuntimeException e) { 128.77 - // expected 128.78 - } 128.79 - 128.80 - try { 128.81 - output.stderrShouldContain(stdout); 128.82 - throw new Exception("stdoutShouldContain() failed to throw exception"); 128.83 - } catch (RuntimeException e) { 128.84 - // expected 128.85 - } 128.86 - 128.87 - try { 128.88 - output.shouldNotContain("cccc"); 128.89 - output.stdoutShouldNotContain("cccc"); 128.90 - output.stderrShouldNotContain("cccc"); 128.91 - } catch (RuntimeException e) { 128.92 - throw new Exception("shouldNotContain() failed", e); 128.93 - } 128.94 - 128.95 - try { 128.96 - output.shouldNotContain(stdout); 128.97 - throw new Exception("shouldContain() failed to throw exception"); 128.98 - } catch (RuntimeException e) { 128.99 - // expected 128.100 - } 128.101 - 128.102 - try { 128.103 - output.stdoutShouldNotContain(stdout); 128.104 - throw new Exception("shouldContain() failed to throw exception"); 128.105 - } catch (RuntimeException e) { 128.106 - // expected 128.107 - } 128.108 - 128.109 - try { 128.110 - output.stderrShouldNotContain(stderr); 128.111 - throw new Exception("shouldContain() failed to throw exception"); 128.112 - } catch (RuntimeException e) { 128.113 - // expected 128.114 - } 128.115 - 128.116 - // Should match 128.117 - try { 128.118 - output.shouldMatch(stdoutPattern); 128.119 - output.stdoutShouldMatch(stdoutPattern); 128.120 - output.shouldMatch(stderrPattern); 128.121 - output.stderrShouldMatch(stderrPattern); 128.122 - } catch (RuntimeException e) { 128.123 - throw new Exception("shouldMatch() failed", e); 128.124 - } 128.125 - 128.126 - try { 128.127 - output.shouldMatch(nonExistingPattern); 128.128 - throw new Exception("shouldMatch() failed to throw exception"); 128.129 - } catch (RuntimeException e) { 128.130 - // expected 128.131 - } 128.132 - 128.133 - try { 128.134 - output.stdoutShouldMatch(stderrPattern); 128.135 - throw new Exception( 128.136 - "stdoutShouldMatch() failed to throw exception"); 128.137 - } catch (RuntimeException e) { 128.138 - // expected 128.139 - } 128.140 - 128.141 - try { 128.142 - output.stderrShouldMatch(stdoutPattern); 128.143 - throw new Exception( 128.144 - "stderrShouldMatch() failed to throw exception"); 128.145 - } catch (RuntimeException e) { 128.146 - // expected 128.147 - } 128.148 - 128.149 - // Should not match 128.150 - try { 128.151 - output.shouldNotMatch(nonExistingPattern); 128.152 - output.stdoutShouldNotMatch(nonExistingPattern); 128.153 - output.stderrShouldNotMatch(nonExistingPattern); 128.154 - } catch (RuntimeException e) { 128.155 - throw new Exception("shouldNotMatch() failed", e); 128.156 - } 128.157 - 128.158 - try { 128.159 - output.shouldNotMatch(stdoutPattern); 128.160 - throw new Exception("shouldNotMatch() failed to throw exception"); 128.161 - } catch (RuntimeException e) { 128.162 - // expected 128.163 - } 128.164 - 128.165 - try { 128.166 - output.stdoutShouldNotMatch(stdoutPattern); 128.167 - throw new Exception("shouldNotMatch() failed to throw exception"); 128.168 - } catch (RuntimeException e) { 128.169 - // expected 128.170 - } 128.171 - 128.172 - try { 128.173 - output.stderrShouldNotMatch(stderrPattern); 128.174 - throw new Exception("shouldNotMatch() failed to throw exception"); 128.175 - } catch (RuntimeException e) { 128.176 - // expected 128.177 - } 128.178 - 128.179 - { 128.180 - String aaaa = "aaaa"; 128.181 - String result = output.firstMatch(aaaa); 128.182 - if (!aaaa.equals(result)) { 128.183 - throw new Exception("firstMatch(String) faild to match. Expected: " + aaaa + " got: " + result); 128.184 - } 128.185 - } 128.186 - 128.187 - { 128.188 - String aa = "aa"; 128.189 - String aa_grouped_aa = aa + "(" + aa + ")"; 128.190 - String result = output.firstMatch(aa_grouped_aa, 1); 128.191 - if (!aa.equals(result)) { 128.192 - throw new Exception("firstMatch(String, int) failed to match. Expected: " + aa + " got: " + result); 128.193 - } 128.194 - } 128.195 - } 128.196 -}
129.1 --- a/test/testlibrary/com/oracle/java/testlibrary/Platform.java Wed Oct 09 13:00:20 2013 +0200 129.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/Platform.java Wed Oct 09 05:03:34 2013 -0700 129.3 @@ -24,50 +24,80 @@ 129.4 package com.oracle.java.testlibrary; 129.5 129.6 public class Platform { 129.7 - private static final String osName = System.getProperty("os.name"); 129.8 - private static final String dataModel = System.getProperty("sun.arch.data.model"); 129.9 - private static final String vmVersion = System.getProperty("java.vm.version"); 129.10 - private static final String osArch = System.getProperty("os.arch"); 129.11 + private static final String osName = System.getProperty("os.name"); 129.12 + private static final String dataModel = System.getProperty("sun.arch.data.model"); 129.13 + private static final String vmVersion = System.getProperty("java.vm.version"); 129.14 + private static final String osArch = System.getProperty("os.arch"); 129.15 129.16 - public static boolean is64bit() { 129.17 - return dataModel.equals("64"); 129.18 - } 129.19 + public static boolean is32bit() { 129.20 + return dataModel.equals("32"); 129.21 + } 129.22 129.23 - public static boolean isSolaris() { 129.24 - return osName.toLowerCase().startsWith("sunos"); 129.25 - } 129.26 + public static boolean is64bit() { 129.27 + return dataModel.equals("64"); 129.28 + } 129.29 129.30 - public static boolean isWindows() { 129.31 - return osName.toLowerCase().startsWith("win"); 129.32 - } 129.33 + public static boolean isSolaris() { 129.34 + return isOs("sunos"); 129.35 + } 129.36 129.37 - public static boolean isOSX() { 129.38 - return osName.toLowerCase().startsWith("mac"); 129.39 - } 129.40 + public static boolean isWindows() { 129.41 + return isOs("win"); 129.42 + } 129.43 129.44 - public static boolean isLinux() { 129.45 - return osName.toLowerCase().startsWith("linux"); 129.46 - } 129.47 + public static boolean isOSX() { 129.48 + return isOs("mac"); 129.49 + } 129.50 129.51 - public static String getOsName() { 129.52 - return osName; 129.53 - } 129.54 + public static boolean isLinux() { 129.55 + return isOs("linux"); 129.56 + } 129.57 129.58 - public static boolean isDebugBuild() { 129.59 - return vmVersion.toLowerCase().contains("debug"); 129.60 - } 129.61 + private static boolean isOs(String osname) { 129.62 + return osName.toLowerCase().startsWith(osname.toLowerCase()); 129.63 + } 129.64 129.65 - public static String getVMVersion() { 129.66 - return vmVersion; 129.67 - } 129.68 + public static String getOsName() { 129.69 + return osName; 129.70 + } 129.71 129.72 - // Returns true for sparc and sparcv9. 129.73 - public static boolean isSparc() { 129.74 - return osArch.toLowerCase().startsWith("sparc"); 129.75 - } 129.76 + public static boolean isDebugBuild() { 129.77 + return vmVersion.toLowerCase().contains("debug"); 129.78 + } 129.79 129.80 - public static String getOsArch() { 129.81 - return osArch; 129.82 - } 129.83 + public static String getVMVersion() { 129.84 + return vmVersion; 129.85 + } 129.86 + 129.87 + // Returns true for sparc and sparcv9. 129.88 + public static boolean isSparc() { 129.89 + return isArch("sparc"); 129.90 + } 129.91 + 129.92 + public static boolean isARM() { 129.93 + return isArch("arm"); 129.94 + } 129.95 + 129.96 + public static boolean isPPC() { 129.97 + return isArch("ppc"); 129.98 + } 129.99 + 129.100 + public static boolean isX86() { 129.101 + // On Linux it's 'i386', Windows 'x86' 129.102 + return (isArch("i386") || isArch("x86")); 129.103 + } 129.104 + 129.105 + public static boolean isX64() { 129.106 + // On OSX it's 'x86_64' and on other (Linux, Windows and Solaris) platforms it's 'amd64' 129.107 + return (isArch("amd64") || isArch("x86_64")); 129.108 + } 129.109 + 129.110 + private static boolean isArch(String archname) { 129.111 + return osArch.toLowerCase().startsWith(archname.toLowerCase()); 129.112 + } 129.113 + 129.114 + public static String getOsArch() { 129.115 + return osArch; 129.116 + } 129.117 129.118 }
130.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 130.2 +++ b/test/testlibrary_tests/AssertsTest.java Wed Oct 09 05:03:34 2013 -0700 130.3 @@ -0,0 +1,237 @@ 130.4 +/* 130.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 130.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 130.7 + * 130.8 + * This code is free software; you can redistribute it and/or modify it 130.9 + * under the terms of the GNU General Public License version 2 only, as 130.10 + * published by the Free Software Foundation. 130.11 + * 130.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 130.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 130.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 130.15 + * version 2 for more details (a copy is included in the LICENSE file that 130.16 + * accompanied this code). 130.17 + * 130.18 + * You should have received a copy of the GNU General Public License version 130.19 + * 2 along with this work; if not, write to the Free Software Foundation, 130.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 130.21 + * 130.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 130.23 + * or visit www.oracle.com if you need additional information or have any 130.24 + * questions. 130.25 + */ 130.26 + 130.27 +import static com.oracle.java.testlibrary.Asserts.*; 130.28 + 130.29 +/* @test 130.30 + * @summary Tests the different assertions in the Assert class 130.31 + * @library /testlibrary 130.32 + */ 130.33 +public class AssertsTest { 130.34 + private static class Foo implements Comparable<Foo> { 130.35 + final int id; 130.36 + public Foo(int id) { 130.37 + this.id = id; 130.38 + } 130.39 + 130.40 + public int compareTo(Foo f) { 130.41 + return new Integer(id).compareTo(new Integer(f.id)); 130.42 + } 130.43 + } 130.44 + 130.45 + public static void main(String[] args) throws Exception { 130.46 + testLessThan(); 130.47 + testLessThanOrEqual(); 130.48 + testEquals(); 130.49 + testGreaterThanOrEqual(); 130.50 + testGreaterThan(); 130.51 + testNotEquals(); 130.52 + testNull(); 130.53 + testNotNull(); 130.54 + testTrue(); 130.55 + testFalse(); 130.56 + } 130.57 + 130.58 + private static void testLessThan() throws Exception { 130.59 + expectPass(Assertion.LT, 1, 2); 130.60 + 130.61 + expectFail(Assertion.LT, 2, 2); 130.62 + expectFail(Assertion.LT, 2, 1); 130.63 + expectFail(Assertion.LT, null, 2); 130.64 + expectFail(Assertion.LT, 2, null); 130.65 + } 130.66 + 130.67 + private static void testLessThanOrEqual() throws Exception { 130.68 + expectPass(Assertion.LTE, 1, 2); 130.69 + expectPass(Assertion.LTE, 2, 2); 130.70 + 130.71 + expectFail(Assertion.LTE, 3, 2); 130.72 + expectFail(Assertion.LTE, null, 2); 130.73 + expectFail(Assertion.LTE, 2, null); 130.74 + } 130.75 + 130.76 + private static void testEquals() throws Exception { 130.77 + expectPass(Assertion.EQ, 1, 1); 130.78 + expectPass(Assertion.EQ, null, null); 130.79 + 130.80 + Foo f1 = new Foo(1); 130.81 + expectPass(Assertion.EQ, f1, f1); 130.82 + 130.83 + Foo f2 = new Foo(1); 130.84 + expectFail(Assertion.EQ, f1, f2); 130.85 + expectFail(Assertion.LTE, null, 2); 130.86 + expectFail(Assertion.LTE, 2, null); 130.87 + } 130.88 + 130.89 + private static void testGreaterThanOrEqual() throws Exception { 130.90 + expectPass(Assertion.GTE, 1, 1); 130.91 + expectPass(Assertion.GTE, 2, 1); 130.92 + 130.93 + expectFail(Assertion.GTE, 1, 2); 130.94 + expectFail(Assertion.GTE, null, 2); 130.95 + expectFail(Assertion.GTE, 2, null); 130.96 + } 130.97 + 130.98 + private static void testGreaterThan() throws Exception { 130.99 + expectPass(Assertion.GT, 2, 1); 130.100 + 130.101 + expectFail(Assertion.GT, 1, 1); 130.102 + expectFail(Assertion.GT, 1, 2); 130.103 + expectFail(Assertion.GT, null, 2); 130.104 + expectFail(Assertion.GT, 2, null); 130.105 + } 130.106 + 130.107 + private static void testNotEquals() throws Exception { 130.108 + expectPass(Assertion.NE, null, 1); 130.109 + expectPass(Assertion.NE, 1, null); 130.110 + 130.111 + Foo f1 = new Foo(1); 130.112 + Foo f2 = new Foo(1); 130.113 + expectPass(Assertion.NE, f1, f2); 130.114 + 130.115 + expectFail(Assertion.NE, null, null); 130.116 + expectFail(Assertion.NE, f1, f1); 130.117 + expectFail(Assertion.NE, 1, 1); 130.118 + } 130.119 + 130.120 + private static void testNull() throws Exception { 130.121 + expectPass(Assertion.NULL, null); 130.122 + 130.123 + expectFail(Assertion.NULL, 1); 130.124 + } 130.125 + 130.126 + private static void testNotNull() throws Exception { 130.127 + expectPass(Assertion.NOTNULL, 1); 130.128 + 130.129 + expectFail(Assertion.NOTNULL, null); 130.130 + } 130.131 + 130.132 + private static void testTrue() throws Exception { 130.133 + expectPass(Assertion.TRUE, true); 130.134 + 130.135 + expectFail(Assertion.TRUE, false); 130.136 + } 130.137 + 130.138 + private static void testFalse() throws Exception { 130.139 + expectPass(Assertion.FALSE, false); 130.140 + 130.141 + expectFail(Assertion.FALSE, true); 130.142 + } 130.143 + 130.144 + private static <T extends Comparable<T>> void expectPass(Assertion assertion, T ... args) 130.145 + throws Exception { 130.146 + Assertion.run(assertion, args); 130.147 + } 130.148 + 130.149 + private static <T extends Comparable<T>> void expectFail(Assertion assertion, T ... args) 130.150 + throws Exception { 130.151 + try { 130.152 + Assertion.run(assertion, args); 130.153 + } catch (RuntimeException e) { 130.154 + return; 130.155 + } 130.156 + throw new Exception("Expected " + Assertion.format(assertion, (Object[]) args) + 130.157 + " to throw a RuntimeException"); 130.158 + } 130.159 + 130.160 +} 130.161 + 130.162 +enum Assertion { 130.163 + LT, LTE, EQ, GTE, GT, NE, NULL, NOTNULL, FALSE, TRUE; 130.164 + 130.165 + public static <T extends Comparable<T>> void run(Assertion assertion, T ... args) { 130.166 + String msg = "Expected " + format(assertion, args) + " to pass"; 130.167 + switch (assertion) { 130.168 + case LT: 130.169 + assertLessThan(args[0], args[1], msg); 130.170 + break; 130.171 + case LTE: 130.172 + assertLessThanOrEqual(args[0], args[1], msg); 130.173 + break; 130.174 + case EQ: 130.175 + assertEquals(args[0], args[1], msg); 130.176 + break; 130.177 + case GTE: 130.178 + assertGreaterThanOrEqual(args[0], args[1], msg); 130.179 + break; 130.180 + case GT: 130.181 + assertGreaterThan(args[0], args[1], msg); 130.182 + break; 130.183 + case NE: 130.184 + assertNotEquals(args[0], args[1], msg); 130.185 + break; 130.186 + case NULL: 130.187 + assertNull(args == null ? args : args[0], msg); 130.188 + break; 130.189 + case NOTNULL: 130.190 + assertNotNull(args == null ? args : args[0], msg); 130.191 + break; 130.192 + case FALSE: 130.193 + assertFalse((Boolean) args[0], msg); 130.194 + break; 130.195 + case TRUE: 130.196 + assertTrue((Boolean) args[0], msg); 130.197 + break; 130.198 + default: 130.199 + // do nothing 130.200 + } 130.201 + } 130.202 + 130.203 + public static String format(Assertion assertion, Object ... args) { 130.204 + switch (assertion) { 130.205 + case LT: 130.206 + return asString("assertLessThan", args); 130.207 + case LTE: 130.208 + return asString("assertLessThanOrEqual", args); 130.209 + case EQ: 130.210 + return asString("assertEquals", args); 130.211 + case GTE: 130.212 + return asString("assertGreaterThanOrEquals", args); 130.213 + case GT: 130.214 + return asString("assertGreaterThan", args); 130.215 + case NE: 130.216 + return asString("assertNotEquals", args); 130.217 + case NULL: 130.218 + return asString("assertNull", args); 130.219 + case NOTNULL: 130.220 + return asString("assertNotNull", args); 130.221 + case FALSE: 130.222 + return asString("assertFalse", args); 130.223 + case TRUE: 130.224 + return asString("assertTrue", args); 130.225 + default: 130.226 + return ""; 130.227 + } 130.228 + } 130.229 + 130.230 + private static String asString(String assertion, Object ... args) { 130.231 + if (args == null) { 130.232 + return String.format("%s(null)", assertion); 130.233 + } 130.234 + if (args.length == 1) { 130.235 + return String.format("%s(%s)", assertion, args[0]); 130.236 + } else { 130.237 + return String.format("%s(%s, %s)", assertion, args[0], args[1]); 130.238 + } 130.239 + } 130.240 +}
131.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 131.2 +++ b/test/testlibrary_tests/OutputAnalyzerReportingTest.java Wed Oct 09 05:03:34 2013 -0700 131.3 @@ -0,0 +1,124 @@ 131.4 +/* 131.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 131.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 131.7 + * 131.8 + * This code is free software; you can redistribute it and/or modify it 131.9 + * under the terms of the GNU General Public License version 2 only, as 131.10 + * published by the Free Software Foundation. 131.11 + * 131.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 131.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 131.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 131.15 + * version 2 for more details (a copy is included in the LICENSE file that 131.16 + * accompanied this code). 131.17 + * 131.18 + * You should have received a copy of the GNU General Public License version 131.19 + * 2 along with this work; if not, write to the Free Software Foundation, 131.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 131.21 + * 131.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 131.23 + * or visit www.oracle.com if you need additional information or have any 131.24 + * questions. 131.25 + */ 131.26 + 131.27 + 131.28 +/* 131.29 + * @test 131.30 + * @summary Test the OutputAnalyzer reporting functionality, 131.31 + * such as printing additional diagnostic info 131.32 + * (exit code, stdout, stderr, command line, etc.) 131.33 + * @library /testlibrary 131.34 + */ 131.35 + 131.36 +import java.io.ByteArrayOutputStream; 131.37 +import java.io.PrintStream; 131.38 + 131.39 +import com.oracle.java.testlibrary.OutputAnalyzer; 131.40 +import com.oracle.java.testlibrary.ProcessTools; 131.41 + 131.42 + 131.43 +public class OutputAnalyzerReportingTest { 131.44 + 131.45 + public static void main(String[] args) throws Exception { 131.46 + // Create the output analyzer under test 131.47 + String stdout = "aaaaaa"; 131.48 + String stderr = "bbbbbb"; 131.49 + OutputAnalyzer output = new OutputAnalyzer(stdout, stderr); 131.50 + 131.51 + // Expected summary values should be the same for all cases, 131.52 + // since the outputAnalyzer object is the same 131.53 + String expectedExitValue = "-1"; 131.54 + String expectedSummary = 131.55 + " stdout: [" + stdout + "];\n" + 131.56 + " stderr: [" + stderr + "]\n" + 131.57 + " exitValue = " + expectedExitValue + "\n"; 131.58 + 131.59 + 131.60 + DiagnosticSummaryTestRunner testRunner = 131.61 + new DiagnosticSummaryTestRunner(); 131.62 + 131.63 + // should have exit value 131.64 + testRunner.init(expectedSummary); 131.65 + int unexpectedExitValue = 2; 131.66 + try { 131.67 + output.shouldHaveExitValue(unexpectedExitValue); 131.68 + } catch (RuntimeException e) { } 131.69 + testRunner.closeAndCheckResults(); 131.70 + 131.71 + // should not contain 131.72 + testRunner.init(expectedSummary); 131.73 + try { 131.74 + output.shouldNotContain(stdout); 131.75 + } catch (RuntimeException e) { } 131.76 + testRunner.closeAndCheckResults(); 131.77 + 131.78 + // should contain 131.79 + testRunner.init(expectedSummary); 131.80 + try { 131.81 + output.shouldContain("unexpected-stuff"); 131.82 + } catch (RuntimeException e) { } 131.83 + testRunner.closeAndCheckResults(); 131.84 + 131.85 + // should not match 131.86 + testRunner.init(expectedSummary); 131.87 + try { 131.88 + output.shouldNotMatch("[a]"); 131.89 + } catch (RuntimeException e) { } 131.90 + testRunner.closeAndCheckResults(); 131.91 + 131.92 + // should match 131.93 + testRunner.init(expectedSummary); 131.94 + try { 131.95 + output.shouldMatch("[qwerty]"); 131.96 + } catch (RuntimeException e) { } 131.97 + testRunner.closeAndCheckResults(); 131.98 + 131.99 + } 131.100 + 131.101 + private static class DiagnosticSummaryTestRunner { 131.102 + private ByteArrayOutputStream byteStream = 131.103 + new ByteArrayOutputStream(10000); 131.104 + 131.105 + private String expectedSummary = ""; 131.106 + private PrintStream errStream; 131.107 + 131.108 + 131.109 + public void init(String expectedSummary) { 131.110 + this.expectedSummary = expectedSummary; 131.111 + byteStream.reset(); 131.112 + errStream = new PrintStream(byteStream); 131.113 + System.setErr(errStream); 131.114 + } 131.115 + 131.116 + public void closeAndCheckResults() { 131.117 + // check results 131.118 + errStream.close(); 131.119 + String stdErrStr = byteStream.toString(); 131.120 + if (!stdErrStr.contains(expectedSummary)) { 131.121 + throw new RuntimeException("The output does not contain " 131.122 + + "the diagnostic message, or the message is incorrect"); 131.123 + } 131.124 + } 131.125 + } 131.126 + 131.127 +}
132.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 132.2 +++ b/test/testlibrary_tests/OutputAnalyzerTest.java Wed Oct 09 05:03:34 2013 -0700 132.3 @@ -0,0 +1,193 @@ 132.4 +/* 132.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 132.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 132.7 + * 132.8 + * This code is free software; you can redistribute it and/or modify it 132.9 + * under the terms of the GNU General Public License version 2 only, as 132.10 + * published by the Free Software Foundation. 132.11 + * 132.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 132.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 132.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 132.15 + * version 2 for more details (a copy is included in the LICENSE file that 132.16 + * accompanied this code). 132.17 + * 132.18 + * You should have received a copy of the GNU General Public License version 132.19 + * 2 along with this work; if not, write to the Free Software Foundation, 132.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 132.21 + * 132.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 132.23 + * or visit www.oracle.com if you need additional information or have any 132.24 + * questions. 132.25 + */ 132.26 + 132.27 +/* 132.28 + * @test 132.29 + * @summary Test the OutputAnalyzer utility class 132.30 + * @library /testlibrary 132.31 + */ 132.32 + 132.33 +import com.oracle.java.testlibrary.OutputAnalyzer; 132.34 + 132.35 +public class OutputAnalyzerTest { 132.36 + 132.37 + public static void main(String args[]) throws Exception { 132.38 + 132.39 + String stdout = "aaaaaa"; 132.40 + String stderr = "bbbbbb"; 132.41 + 132.42 + // Regexps used for testing pattern matching of the test input 132.43 + String stdoutPattern = "[a]"; 132.44 + String stderrPattern = "[b]"; 132.45 + String nonExistingPattern = "[c]"; 132.46 + 132.47 + OutputAnalyzer output = new OutputAnalyzer(stdout, stderr); 132.48 + 132.49 + if (!stdout.equals(output.getStdout())) { 132.50 + throw new Exception("getStdout() returned '" + output.getStdout() + "', expected '" + stdout + "'"); 132.51 + } 132.52 + 132.53 + if (!stderr.equals(output.getStderr())) { 132.54 + throw new Exception("getStderr() returned '" + output.getStderr() + "', expected '" + stderr + "'"); 132.55 + } 132.56 + 132.57 + try { 132.58 + output.shouldContain(stdout); 132.59 + output.stdoutShouldContain(stdout); 132.60 + output.shouldContain(stderr); 132.61 + output.stderrShouldContain(stderr); 132.62 + } catch (RuntimeException e) { 132.63 + throw new Exception("shouldContain() failed", e); 132.64 + } 132.65 + 132.66 + try { 132.67 + output.shouldContain("cccc"); 132.68 + throw new Exception("shouldContain() failed to throw exception"); 132.69 + } catch (RuntimeException e) { 132.70 + // expected 132.71 + } 132.72 + 132.73 + try { 132.74 + output.stdoutShouldContain(stderr); 132.75 + throw new Exception("stdoutShouldContain() failed to throw exception"); 132.76 + } catch (RuntimeException e) { 132.77 + // expected 132.78 + } 132.79 + 132.80 + try { 132.81 + output.stderrShouldContain(stdout); 132.82 + throw new Exception("stdoutShouldContain() failed to throw exception"); 132.83 + } catch (RuntimeException e) { 132.84 + // expected 132.85 + } 132.86 + 132.87 + try { 132.88 + output.shouldNotContain("cccc"); 132.89 + output.stdoutShouldNotContain("cccc"); 132.90 + output.stderrShouldNotContain("cccc"); 132.91 + } catch (RuntimeException e) { 132.92 + throw new Exception("shouldNotContain() failed", e); 132.93 + } 132.94 + 132.95 + try { 132.96 + output.shouldNotContain(stdout); 132.97 + throw new Exception("shouldContain() failed to throw exception"); 132.98 + } catch (RuntimeException e) { 132.99 + // expected 132.100 + } 132.101 + 132.102 + try { 132.103 + output.stdoutShouldNotContain(stdout); 132.104 + throw new Exception("shouldContain() failed to throw exception"); 132.105 + } catch (RuntimeException e) { 132.106 + // expected 132.107 + } 132.108 + 132.109 + try { 132.110 + output.stderrShouldNotContain(stderr); 132.111 + throw new Exception("shouldContain() failed to throw exception"); 132.112 + } catch (RuntimeException e) { 132.113 + // expected 132.114 + } 132.115 + 132.116 + // Should match 132.117 + try { 132.118 + output.shouldMatch(stdoutPattern); 132.119 + output.stdoutShouldMatch(stdoutPattern); 132.120 + output.shouldMatch(stderrPattern); 132.121 + output.stderrShouldMatch(stderrPattern); 132.122 + } catch (RuntimeException e) { 132.123 + throw new Exception("shouldMatch() failed", e); 132.124 + } 132.125 + 132.126 + try { 132.127 + output.shouldMatch(nonExistingPattern); 132.128 + throw new Exception("shouldMatch() failed to throw exception"); 132.129 + } catch (RuntimeException e) { 132.130 + // expected 132.131 + } 132.132 + 132.133 + try { 132.134 + output.stdoutShouldMatch(stderrPattern); 132.135 + throw new Exception( 132.136 + "stdoutShouldMatch() failed to throw exception"); 132.137 + } catch (RuntimeException e) { 132.138 + // expected 132.139 + } 132.140 + 132.141 + try { 132.142 + output.stderrShouldMatch(stdoutPattern); 132.143 + throw new Exception( 132.144 + "stderrShouldMatch() failed to throw exception"); 132.145 + } catch (RuntimeException e) { 132.146 + // expected 132.147 + } 132.148 + 132.149 + // Should not match 132.150 + try { 132.151 + output.shouldNotMatch(nonExistingPattern); 132.152 + output.stdoutShouldNotMatch(nonExistingPattern); 132.153 + output.stderrShouldNotMatch(nonExistingPattern); 132.154 + } catch (RuntimeException e) { 132.155 + throw new Exception("shouldNotMatch() failed", e); 132.156 + } 132.157 + 132.158 + try { 132.159 + output.shouldNotMatch(stdoutPattern); 132.160 + throw new Exception("shouldNotMatch() failed to throw exception"); 132.161 + } catch (RuntimeException e) { 132.162 + // expected 132.163 + } 132.164 + 132.165 + try { 132.166 + output.stdoutShouldNotMatch(stdoutPattern); 132.167 + throw new Exception("shouldNotMatch() failed to throw exception"); 132.168 + } catch (RuntimeException e) { 132.169 + // expected 132.170 + } 132.171 + 132.172 + try { 132.173 + output.stderrShouldNotMatch(stderrPattern); 132.174 + throw new Exception("shouldNotMatch() failed to throw exception"); 132.175 + } catch (RuntimeException e) { 132.176 + // expected 132.177 + } 132.178 + 132.179 + { 132.180 + String aaaa = "aaaa"; 132.181 + String result = output.firstMatch(aaaa); 132.182 + if (!aaaa.equals(result)) { 132.183 + throw new Exception("firstMatch(String) faild to match. Expected: " + aaaa + " got: " + result); 132.184 + } 132.185 + } 132.186 + 132.187 + { 132.188 + String aa = "aa"; 132.189 + String aa_grouped_aa = aa + "(" + aa + ")"; 132.190 + String result = output.firstMatch(aa_grouped_aa, 1); 132.191 + if (!aa.equals(result)) { 132.192 + throw new Exception("firstMatch(String, int) failed to match. Expected: " + aa + " got: " + result); 132.193 + } 132.194 + } 132.195 + } 132.196 +}