Wed, 04 Jun 2014 07:07:31 -0700
Merge
.hgtags | file | annotate | diff | comparison | revisions | |
make/hotspot_version | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Tue Jun 03 21:36:53 2014 -0700 1.2 +++ b/.hgtags Wed Jun 04 07:07:31 2014 -0700 1.3 @@ -480,4 +480,5 @@ 1.4 8c785f9bde6f603cbd13eecd2ee6acd699b376f8 jdk8u20-b15 1.5 50e5d560367b94275a91d5d579c32f1164eb5fa5 hs25.20-b16 1.6 c36ef639e6d3c2d238f4e4f8b2f5803a60de8be8 jdk8u20-b16 1.7 +ee8b934668694dba5dc0ac039f8d56e52499c0f9 hs25.20-b17 1.8 a4d44dfb7d30eea54bc172e4429a655454ae0bbf jdk8u25-b00
2.1 --- a/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp Tue Jun 03 21:36:53 2014 -0700 2.2 +++ b/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp Wed Jun 04 07:07:31 2014 -0700 2.3 @@ -1221,10 +1221,8 @@ 2.4 bool is_obj = (type == T_ARRAY || type == T_OBJECT); 2.5 LIR_Opr offset = off.result(); 2.6 2.7 - if (data != dst) { 2.8 - __ move(data, dst); 2.9 - data = dst; 2.10 - } 2.11 + // Because we want a 2-arg form of xchg 2.12 + __ move(data, dst); 2.13 2.14 assert (!x->is_add() && (type == T_INT || (is_obj LP64_ONLY(&& UseCompressedOops))), "unexpected type"); 2.15 LIR_Address* addr; 2.16 @@ -1254,7 +1252,7 @@ 2.17 pre_barrier(ptr, LIR_OprFact::illegalOpr /* pre_val */, 2.18 true /* do_load */, false /* patch */, NULL); 2.19 } 2.20 - __ xchg(LIR_OprFact::address(addr), data, dst, tmp); 2.21 + __ xchg(LIR_OprFact::address(addr), dst, dst, tmp); 2.22 if (is_obj) { 2.23 // Seems to be a precise address 2.24 post_barrier(ptr, data);
3.1 --- a/src/cpu/sparc/vm/stubGenerator_sparc.cpp Tue Jun 03 21:36:53 2014 -0700 3.2 +++ b/src/cpu/sparc/vm/stubGenerator_sparc.cpp Wed Jun 04 07:07:31 2014 -0700 3.3 @@ -3653,9 +3653,9 @@ 3.4 const Register len_reg = I4; // cipher length 3.5 const Register keylen = I5; // reg for storing expanded key array length 3.6 3.7 - // save cipher len before save_frame, to return in the end 3.8 - __ mov(O4, L0); 3.9 __ save_frame(0); 3.10 + // save cipher len to return in the end 3.11 + __ mov(len_reg, L0); 3.12 3.13 // read expanded key length 3.14 __ ldsw(Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)), keylen, 0); 3.15 @@ -3778,9 +3778,9 @@ 3.16 // re-init intial vector for next block, 8-byte alignment is guaranteed 3.17 __ stf(FloatRegisterImpl::D, F60, rvec, 0); 3.18 __ stf(FloatRegisterImpl::D, F62, rvec, 8); 3.19 - __ restore(); 3.20 - __ retl(); 3.21 - __ delayed()->mov(L0, O0); 3.22 + __ mov(L0, I0); 3.23 + __ ret(); 3.24 + __ delayed()->restore(); 3.25 3.26 __ align(OptoLoopAlignment); 3.27 __ BIND(L_cbcenc192); 3.28 @@ -3869,9 +3869,9 @@ 3.29 // re-init intial vector for next block, 8-byte alignment is guaranteed 3.30 __ stf(FloatRegisterImpl::D, F60, rvec, 0); 3.31 __ stf(FloatRegisterImpl::D, F62, rvec, 8); 3.32 - __ restore(); 3.33 - __ retl(); 3.34 - __ delayed()->mov(L0, O0); 3.35 + __ mov(L0, I0); 3.36 + __ ret(); 3.37 + __ delayed()->restore(); 3.38 3.39 __ align(OptoLoopAlignment); 3.40 __ BIND(L_cbcenc256); 3.41 @@ -3962,9 +3962,9 @@ 3.42 // re-init intial vector for next block, 8-byte alignment is guaranteed 3.43 __ stf(FloatRegisterImpl::D, F60, rvec, 0); 3.44 __ stf(FloatRegisterImpl::D, F62, rvec, 8); 3.45 - __ restore(); 3.46 - __ retl(); 3.47 - __ delayed()->mov(L0, O0); 3.48 + __ mov(L0, I0); 3.49 + __ ret(); 3.50 + __ delayed()->restore(); 3.51 3.52 return start; 3.53 } 3.54 @@ -3992,9 +3992,9 @@ 3.55 const Register original_key = I5; // original key array only required during decryption 3.56 const Register keylen = L6; // reg for storing expanded key array length 3.57 3.58 - // save cipher len before save_frame, to return in the end 3.59 - __ mov(O4, L0); 3.60 __ save_frame(0); //args are read from I* registers since we save the frame in the beginning 3.61 + // save cipher len to return in the end 3.62 + __ mov(len_reg, L7); 3.63 3.64 // load original key from SunJCE expanded decryption key 3.65 // Since we load original key buffer starting first element, 8-byte alignment is guaranteed 3.66 @@ -4568,10 +4568,9 @@ 3.67 // re-init intial vector for next block, 8-byte alignment is guaranteed 3.68 __ stx(L0, rvec, 0); 3.69 __ stx(L1, rvec, 8); 3.70 - __ restore(); 3.71 - __ mov(L0, O0); 3.72 - __ retl(); 3.73 - __ delayed()->nop(); 3.74 + __ mov(L7, I0); 3.75 + __ ret(); 3.76 + __ delayed()->restore(); 3.77 3.78 return start; 3.79 }
4.1 --- a/src/share/vm/c1/c1_LIR.cpp Tue Jun 03 21:36:53 2014 -0700 4.2 +++ b/src/share/vm/c1/c1_LIR.cpp Wed Jun 04 07:07:31 2014 -0700 4.3 @@ -1083,7 +1083,7 @@ 4.4 4.5 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) { 4.6 masm->emit_arraycopy(this); 4.7 - masm->emit_code_stub(stub()); 4.8 + masm->append_code_stub(stub()); 4.9 } 4.10 4.11 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) { 4.12 @@ -1100,20 +1100,20 @@ 4.13 4.14 void LIR_OpAllocObj::emit_code(LIR_Assembler* masm) { 4.15 masm->emit_alloc_obj(this); 4.16 - masm->emit_code_stub(stub()); 4.17 + masm->append_code_stub(stub()); 4.18 } 4.19 4.20 void LIR_OpBranch::emit_code(LIR_Assembler* masm) { 4.21 masm->emit_opBranch(this); 4.22 if (stub()) { 4.23 - masm->emit_code_stub(stub()); 4.24 + masm->append_code_stub(stub()); 4.25 } 4.26 } 4.27 4.28 void LIR_OpConvert::emit_code(LIR_Assembler* masm) { 4.29 masm->emit_opConvert(this); 4.30 if (stub() != NULL) { 4.31 - masm->emit_code_stub(stub()); 4.32 + masm->append_code_stub(stub()); 4.33 } 4.34 } 4.35 4.36 @@ -1123,13 +1123,13 @@ 4.37 4.38 void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) { 4.39 masm->emit_alloc_array(this); 4.40 - masm->emit_code_stub(stub()); 4.41 + masm->append_code_stub(stub()); 4.42 } 4.43 4.44 void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) { 4.45 masm->emit_opTypeCheck(this); 4.46 if (stub()) { 4.47 - masm->emit_code_stub(stub()); 4.48 + masm->append_code_stub(stub()); 4.49 } 4.50 } 4.51 4.52 @@ -1144,7 +1144,7 @@ 4.53 void LIR_OpLock::emit_code(LIR_Assembler* masm) { 4.54 masm->emit_lock(this); 4.55 if (stub()) { 4.56 - masm->emit_code_stub(stub()); 4.57 + masm->append_code_stub(stub()); 4.58 } 4.59 } 4.60
5.1 --- a/src/share/vm/c1/c1_LIR.hpp Tue Jun 03 21:36:53 2014 -0700 5.2 +++ b/src/share/vm/c1/c1_LIR.hpp Wed Jun 04 07:07:31 2014 -0700 5.3 @@ -1127,6 +1127,7 @@ 5.4 virtual void print_instr(outputStream* out) const = 0; 5.5 virtual void print_on(outputStream* st) const PRODUCT_RETURN; 5.6 5.7 + virtual bool is_patching() { return false; } 5.8 virtual LIR_OpCall* as_OpCall() { return NULL; } 5.9 virtual LIR_OpJavaCall* as_OpJavaCall() { return NULL; } 5.10 virtual LIR_OpLabel* as_OpLabel() { return NULL; } 5.11 @@ -1387,6 +1388,7 @@ 5.12 return (LIR_MoveKind)_flags; 5.13 } 5.14 5.15 + virtual bool is_patching() { return _patch != lir_patch_none; } 5.16 virtual void emit_code(LIR_Assembler* masm); 5.17 virtual LIR_Op1* as_Op1() { return this; } 5.18 virtual const char * name() const PRODUCT_RETURN0; 5.19 @@ -1619,6 +1621,7 @@ 5.20 int profiled_bci() const { return _profiled_bci; } 5.21 bool should_profile() const { return _should_profile; } 5.22 5.23 + virtual bool is_patching() { return _info_for_patch != NULL; } 5.24 virtual void emit_code(LIR_Assembler* masm); 5.25 virtual LIR_OpTypeCheck* as_OpTypeCheck() { return this; } 5.26 void print_instr(outputStream* out) const PRODUCT_RETURN;
6.1 --- a/src/share/vm/c1/c1_LIRAssembler.cpp Tue Jun 03 21:36:53 2014 -0700 6.2 +++ b/src/share/vm/c1/c1_LIRAssembler.cpp Wed Jun 04 07:07:31 2014 -0700 6.3 @@ -58,7 +58,7 @@ 6.4 _masm->nop(); 6.5 } 6.6 patch->install(_masm, patch_code, obj, info); 6.7 - append_patching_stub(patch); 6.8 + append_code_stub(patch); 6.9 6.10 #ifdef ASSERT 6.11 Bytecodes::Code code = info->scope()->method()->java_code_at_bci(info->stack()->bci()); 6.12 @@ -131,11 +131,6 @@ 6.13 } 6.14 6.15 6.16 -void LIR_Assembler::append_patching_stub(PatchingStub* stub) { 6.17 - _slow_case_stubs->append(stub); 6.18 -} 6.19 - 6.20 - 6.21 void LIR_Assembler::check_codespace() { 6.22 CodeSection* cs = _masm->code_section(); 6.23 if (cs->remaining() < (int)(NOT_LP64(1*K)LP64_ONLY(2*K))) { 6.24 @@ -144,7 +139,7 @@ 6.25 } 6.26 6.27 6.28 -void LIR_Assembler::emit_code_stub(CodeStub* stub) { 6.29 +void LIR_Assembler::append_code_stub(CodeStub* stub) { 6.30 _slow_case_stubs->append(stub); 6.31 } 6.32 6.33 @@ -435,7 +430,7 @@ 6.34 6.35 void LIR_Assembler::add_debug_info_for_null_check(int pc_offset, CodeEmitInfo* cinfo) { 6.36 ImplicitNullCheckStub* stub = new ImplicitNullCheckStub(pc_offset, cinfo); 6.37 - emit_code_stub(stub); 6.38 + append_code_stub(stub); 6.39 } 6.40 6.41 void LIR_Assembler::add_debug_info_for_div0_here(CodeEmitInfo* info) { 6.42 @@ -444,7 +439,7 @@ 6.43 6.44 void LIR_Assembler::add_debug_info_for_div0(int pc_offset, CodeEmitInfo* cinfo) { 6.45 DivByZeroStub* stub = new DivByZeroStub(pc_offset, cinfo); 6.46 - emit_code_stub(stub); 6.47 + append_code_stub(stub); 6.48 } 6.49 6.50 void LIR_Assembler::emit_rtcall(LIR_OpRTCall* op) {
7.1 --- a/src/share/vm/c1/c1_LIRAssembler.hpp Tue Jun 03 21:36:53 2014 -0700 7.2 +++ b/src/share/vm/c1/c1_LIRAssembler.hpp Wed Jun 04 07:07:31 2014 -0700 7.3 @@ -143,7 +143,7 @@ 7.4 // stubs 7.5 void emit_slow_case_stubs(); 7.6 void emit_static_call_stub(); 7.7 - void emit_code_stub(CodeStub* op); 7.8 + void append_code_stub(CodeStub* op); 7.9 void add_call_info_here(CodeEmitInfo* info) { add_call_info(code_offset(), info); } 7.10 7.11 // code patterns
8.1 --- a/src/share/vm/c1/c1_LinearScan.cpp Tue Jun 03 21:36:53 2014 -0700 8.2 +++ b/src/share/vm/c1/c1_LinearScan.cpp Wed Jun 04 07:07:31 2014 -0700 8.3 @@ -2382,16 +2382,6 @@ 8.4 int arg_count = frame_map()->oop_map_arg_count(); 8.5 OopMap* map = new OopMap(frame_size, arg_count); 8.6 8.7 - // Check if this is a patch site. 8.8 - bool is_patch_info = false; 8.9 - if (op->code() == lir_move) { 8.10 - assert(!is_call_site, "move must not be a call site"); 8.11 - assert(op->as_Op1() != NULL, "move must be LIR_Op1"); 8.12 - LIR_Op1* move = (LIR_Op1*)op; 8.13 - 8.14 - is_patch_info = move->patch_code() != lir_patch_none; 8.15 - } 8.16 - 8.17 // Iterate through active intervals 8.18 for (Interval* interval = iw->active_first(fixedKind); interval != Interval::end(); interval = interval->next()) { 8.19 int assigned_reg = interval->assigned_reg(); 8.20 @@ -2406,7 +2396,7 @@ 8.21 // moves, any intervals which end at this instruction are included 8.22 // in the oop map since we may safepoint while doing the patch 8.23 // before we've consumed the inputs. 8.24 - if (is_patch_info || op->id() < interval->current_to()) { 8.25 + if (op->is_patching() || op->id() < interval->current_to()) { 8.26 8.27 // caller-save registers must not be included into oop-maps at calls 8.28 assert(!is_call_site || assigned_reg >= nof_regs || !is_caller_save(assigned_reg), "interval is in a caller-save register at a call -> register will be overwritten");
9.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp Tue Jun 03 21:36:53 2014 -0700 9.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp Wed Jun 04 07:07:31 2014 -0700 9.3 @@ -819,7 +819,7 @@ 9.4 // false before we start remark. At this point we should also be 9.5 // in a STW phase. 9.6 assert(!concurrent_marking_in_progress(), "invariant"); 9.7 - assert(_finger == _heap_end, 9.8 + assert(out_of_regions(), 9.9 err_msg("only way to get here: _finger: "PTR_FORMAT", _heap_end: "PTR_FORMAT, 9.10 p2i(_finger), p2i(_heap_end))); 9.11 update_g1_committed(true); 9.12 @@ -978,7 +978,9 @@ 9.13 if (concurrent()) { 9.14 ConcurrentGCThread::stsLeave(); 9.15 } 9.16 - _first_overflow_barrier_sync.enter(); 9.17 + 9.18 + bool barrier_aborted = !_first_overflow_barrier_sync.enter(); 9.19 + 9.20 if (concurrent()) { 9.21 ConcurrentGCThread::stsJoin(); 9.22 } 9.23 @@ -986,7 +988,17 @@ 9.24 // more work 9.25 9.26 if (verbose_low()) { 9.27 - gclog_or_tty->print_cr("[%u] leaving first barrier", worker_id); 9.28 + if (barrier_aborted) { 9.29 + gclog_or_tty->print_cr("[%u] aborted first barrier", worker_id); 9.30 + } else { 9.31 + gclog_or_tty->print_cr("[%u] leaving first barrier", worker_id); 9.32 + } 9.33 + } 9.34 + 9.35 + if (barrier_aborted) { 9.36 + // If the barrier aborted we ignore the overflow condition and 9.37 + // just abort the whole marking phase as quickly as possible. 9.38 + return; 9.39 } 9.40 9.41 // If we're executing the concurrent phase of marking, reset the marking 9.42 @@ -1026,14 +1038,20 @@ 9.43 if (concurrent()) { 9.44 ConcurrentGCThread::stsLeave(); 9.45 } 9.46 - _second_overflow_barrier_sync.enter(); 9.47 + 9.48 + bool barrier_aborted = !_second_overflow_barrier_sync.enter(); 9.49 + 9.50 if (concurrent()) { 9.51 ConcurrentGCThread::stsJoin(); 9.52 } 9.53 // at this point everything should be re-initialized and ready to go 9.54 9.55 if (verbose_low()) { 9.56 - gclog_or_tty->print_cr("[%u] leaving second barrier", worker_id); 9.57 + if (barrier_aborted) { 9.58 + gclog_or_tty->print_cr("[%u] aborted second barrier", worker_id); 9.59 + } else { 9.60 + gclog_or_tty->print_cr("[%u] leaving second barrier", worker_id); 9.61 + } 9.62 } 9.63 } 9.64 9.65 @@ -3232,6 +3250,8 @@ 9.66 for (uint i = 0; i < _max_worker_id; ++i) { 9.67 _tasks[i]->clear_region_fields(); 9.68 } 9.69 + _first_overflow_barrier_sync.abort(); 9.70 + _second_overflow_barrier_sync.abort(); 9.71 _has_aborted = true; 9.72 9.73 SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
10.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.hpp Tue Jun 03 21:36:53 2014 -0700 10.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.hpp Wed Jun 04 07:07:31 2014 -0700 10.3 @@ -542,8 +542,12 @@ 10.4 // frequently. 10.5 HeapRegion* claim_region(uint worker_id); 10.6 10.7 - // It determines whether we've run out of regions to scan. 10.8 - bool out_of_regions() { return _finger == _heap_end; } 10.9 + // It determines whether we've run out of regions to scan. Note that 10.10 + // the finger can point past the heap end in case the heap was expanded 10.11 + // to satisfy an allocation without doing a GC. This is fine, because all 10.12 + // objects in those regions will be considered live anyway because of 10.13 + // SATB guarantees (i.e. their TAMS will be equal to bottom). 10.14 + bool out_of_regions() { return _finger >= _heap_end; } 10.15 10.16 // Returns the task with the given id 10.17 CMTask* task(int id) {
11.1 --- a/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Tue Jun 03 21:36:53 2014 -0700 11.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Wed Jun 04 07:07:31 2014 -0700 11.3 @@ -89,6 +89,10 @@ 11.4 while (!_should_terminate) { 11.5 // wait until started is set. 11.6 sleepBeforeNextCycle(); 11.7 + if (_should_terminate) { 11.8 + break; 11.9 + } 11.10 + 11.11 { 11.12 ResourceMark rm; 11.13 HandleMark hm; 11.14 @@ -303,11 +307,21 @@ 11.15 } 11.16 11.17 void ConcurrentMarkThread::stop() { 11.18 - // it is ok to take late safepoints here, if needed 11.19 - MutexLockerEx mu(Terminator_lock); 11.20 - _should_terminate = true; 11.21 - while (!_has_terminated) { 11.22 - Terminator_lock->wait(); 11.23 + { 11.24 + MutexLockerEx ml(Terminator_lock); 11.25 + _should_terminate = true; 11.26 + } 11.27 + 11.28 + { 11.29 + MutexLockerEx ml(CGC_lock, Mutex::_no_safepoint_check_flag); 11.30 + CGC_lock->notify_all(); 11.31 + } 11.32 + 11.33 + { 11.34 + MutexLockerEx ml(Terminator_lock); 11.35 + while (!_has_terminated) { 11.36 + Terminator_lock->wait(); 11.37 + } 11.38 } 11.39 } 11.40 11.41 @@ -327,11 +341,14 @@ 11.42 assert(!in_progress(), "should have been cleared"); 11.43 11.44 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag); 11.45 - while (!started()) { 11.46 + while (!started() && !_should_terminate) { 11.47 CGC_lock->wait(Mutex::_no_safepoint_check_flag); 11.48 } 11.49 - set_in_progress(); 11.50 - clear_started(); 11.51 + 11.52 + if (started()) { 11.53 + set_in_progress(); 11.54 + clear_started(); 11.55 + } 11.56 } 11.57 11.58 // Note: As is the case with CMS - this method, although exported
12.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Tue Jun 03 21:36:53 2014 -0700 12.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Jun 04 07:07:31 2014 -0700 12.3 @@ -435,6 +435,9 @@ 12.4 void G1CollectedHeap::stop_conc_gc_threads() { 12.5 _cg1r->stop(); 12.6 _cmThread->stop(); 12.7 + if (G1StringDedup::is_enabled()) { 12.8 + G1StringDedup::stop(); 12.9 + } 12.10 } 12.11 12.12 #ifdef ASSERT 12.13 @@ -2182,6 +2185,23 @@ 12.14 return JNI_OK; 12.15 } 12.16 12.17 +void G1CollectedHeap::stop() { 12.18 +#if 0 12.19 + // Stopping concurrent worker threads is currently disabled until 12.20 + // some bugs in concurrent mark has been resolve. Without fixing 12.21 + // those bugs first we risk haning during VM exit when trying to 12.22 + // stop these threads. 12.23 + 12.24 + // Abort any ongoing concurrent root region scanning and stop all 12.25 + // concurrent threads. We do this to make sure these threads do 12.26 + // not continue to execute and access resources (e.g. gclog_or_tty) 12.27 + // that are destroyed during shutdown. 12.28 + _cm->root_regions()->abort(); 12.29 + _cm->root_regions()->wait_until_scan_finished(); 12.30 + stop_conc_gc_threads(); 12.31 +#endif 12.32 +} 12.33 + 12.34 size_t G1CollectedHeap::conservative_max_heap_alignment() { 12.35 return HeapRegion::max_region_size(); 12.36 }
13.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Tue Jun 03 21:36:53 2014 -0700 13.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Wed Jun 04 07:07:31 2014 -0700 13.3 @@ -1082,6 +1082,8 @@ 13.4 // specified by the policy object. 13.5 jint initialize(); 13.6 13.7 + virtual void stop(); 13.8 + 13.9 // Return the (conservative) maximum heap alignment for any G1 heap 13.10 static size_t conservative_max_heap_alignment(); 13.11
14.1 --- a/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp Tue Jun 03 21:36:53 2014 -0700 14.2 +++ b/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp Wed Jun 04 07:07:31 2014 -0700 14.3 @@ -95,7 +95,15 @@ 14.4 jbyte *const first = byte_for(mr.start()); 14.5 jbyte *const last = byte_after(mr.last()); 14.6 14.7 - memset(first, g1_young_gen, last - first); 14.8 + // Below we may use an explicit loop instead of memset() because on 14.9 + // certain platforms memset() can give concurrent readers phantom zeros. 14.10 + if (UseMemSetInBOT) { 14.11 + memset(first, g1_young_gen, last - first); 14.12 + } else { 14.13 + for (jbyte* i = first; i < last; i++) { 14.14 + *i = g1_young_gen; 14.15 + } 14.16 + } 14.17 } 14.18 14.19 #ifndef PRODUCT
15.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedup.cpp Tue Jun 03 21:36:53 2014 -0700 15.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedup.cpp Wed Jun 04 07:07:31 2014 -0700 15.3 @@ -44,6 +44,11 @@ 15.4 } 15.5 } 15.6 15.7 +void G1StringDedup::stop() { 15.8 + assert(is_enabled(), "String deduplication not enabled"); 15.9 + G1StringDedupThread::stop(); 15.10 +} 15.11 + 15.12 bool G1StringDedup::is_candidate_from_mark(oop obj) { 15.13 if (java_lang_String::is_instance(obj)) { 15.14 bool from_young = G1CollectedHeap::heap()->heap_region_containing_raw(obj)->is_young();
16.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedup.hpp Tue Jun 03 21:36:53 2014 -0700 16.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedup.hpp Wed Jun 04 07:07:31 2014 -0700 16.3 @@ -110,8 +110,12 @@ 16.4 return _enabled; 16.5 } 16.6 16.7 + // Initialize string deduplication. 16.8 static void initialize(); 16.9 16.10 + // Stop the deduplication thread. 16.11 + static void stop(); 16.12 + 16.13 // Immediately deduplicates the given String object, bypassing the 16.14 // the deduplication queue. 16.15 static void deduplicate(oop java_string);
17.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedupQueue.cpp Tue Jun 03 21:36:53 2014 -0700 17.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedupQueue.cpp Wed Jun 04 07:07:31 2014 -0700 17.3 @@ -35,6 +35,7 @@ 17.4 17.5 G1StringDedupQueue::G1StringDedupQueue() : 17.6 _cursor(0), 17.7 + _cancel(false), 17.8 _empty(true), 17.9 _dropped(0) { 17.10 _nqueues = MAX2(ParallelGCThreads, (size_t)1); 17.11 @@ -55,11 +56,17 @@ 17.12 17.13 void G1StringDedupQueue::wait() { 17.14 MonitorLockerEx ml(StringDedupQueue_lock, Mutex::_no_safepoint_check_flag); 17.15 - while (_queue->_empty) { 17.16 + while (_queue->_empty && !_queue->_cancel) { 17.17 ml.wait(Mutex::_no_safepoint_check_flag); 17.18 } 17.19 } 17.20 17.21 +void G1StringDedupQueue::cancel_wait() { 17.22 + MonitorLockerEx ml(StringDedupQueue_lock, Mutex::_no_safepoint_check_flag); 17.23 + _queue->_cancel = true; 17.24 + ml.notify(); 17.25 +} 17.26 + 17.27 void G1StringDedupQueue::push(uint worker_id, oop java_string) { 17.28 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint"); 17.29 assert(worker_id < _queue->_nqueues, "Invalid queue");
18.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedupQueue.hpp Tue Jun 03 21:36:53 2014 -0700 18.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedupQueue.hpp Wed Jun 04 07:07:31 2014 -0700 18.3 @@ -65,6 +65,7 @@ 18.4 G1StringDedupWorkerQueue* _queues; 18.5 size_t _nqueues; 18.6 size_t _cursor; 18.7 + bool _cancel; 18.8 volatile bool _empty; 18.9 18.10 // Statistics counter, only used for logging. 18.11 @@ -81,6 +82,9 @@ 18.12 // Blocks and waits for the queue to become non-empty. 18.13 static void wait(); 18.14 18.15 + // Wakes up any thread blocked waiting for the queue to become non-empty. 18.16 + static void cancel_wait(); 18.17 + 18.18 // Pushes a deduplication candidate onto a specific GC worker queue. 18.19 static void push(uint worker_id, oop java_string); 18.20
19.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp Tue Jun 03 21:36:53 2014 -0700 19.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp Wed Jun 04 07:07:31 2014 -0700 19.3 @@ -73,6 +73,9 @@ 19.4 19.5 // Wait for the queue to become non-empty 19.6 G1StringDedupQueue::wait(); 19.7 + if (_should_terminate) { 19.8 + break; 19.9 + } 19.10 19.11 // Include this thread in safepoints 19.12 stsJoin(); 19.13 @@ -108,7 +111,23 @@ 19.14 stsLeave(); 19.15 } 19.16 19.17 - ShouldNotReachHere(); 19.18 + terminate(); 19.19 +} 19.20 + 19.21 +void G1StringDedupThread::stop() { 19.22 + { 19.23 + MonitorLockerEx ml(Terminator_lock); 19.24 + _thread->_should_terminate = true; 19.25 + } 19.26 + 19.27 + G1StringDedupQueue::cancel_wait(); 19.28 + 19.29 + { 19.30 + MonitorLockerEx ml(Terminator_lock); 19.31 + while (!_thread->_has_terminated) { 19.32 + ml.wait(); 19.33 + } 19.34 + } 19.35 } 19.36 19.37 void G1StringDedupThread::print(outputStream* st, const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {
20.1 --- a/src/share/vm/gc_implementation/g1/g1StringDedupThread.hpp Tue Jun 03 21:36:53 2014 -0700 20.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedupThread.hpp Wed Jun 04 07:07:31 2014 -0700 20.3 @@ -47,6 +47,8 @@ 20.4 20.5 public: 20.6 static void create(); 20.7 + static void stop(); 20.8 + 20.9 static G1StringDedupThread* thread(); 20.10 20.11 virtual void run();
21.1 --- a/src/share/vm/gc_interface/collectedHeap.hpp Tue Jun 03 21:36:53 2014 -0700 21.2 +++ b/src/share/vm/gc_interface/collectedHeap.hpp Wed Jun 04 07:07:31 2014 -0700 21.3 @@ -208,6 +208,9 @@ 21.4 // This is the correct place to place such initialization methods. 21.5 virtual void post_initialize() = 0; 21.6 21.7 + // Stop any onging concurrent work and prepare for exit. 21.8 + virtual void stop() {} 21.9 + 21.10 MemRegion reserved_region() const { return _reserved; } 21.11 address base() const { return (address)reserved_region().start(); } 21.12
22.1 --- a/src/share/vm/memory/allocation.cpp Tue Jun 03 21:36:53 2014 -0700 22.2 +++ b/src/share/vm/memory/allocation.cpp Wed Jun 04 07:07:31 2014 -0700 22.3 @@ -561,6 +561,7 @@ 22.4 _chunk = new (alloc_failmode, len) Chunk(len); 22.5 22.6 if (_chunk == NULL) { 22.7 + _chunk = k; // restore the previous value of _chunk 22.8 return NULL; 22.9 } 22.10 if (k) k->set_next(_chunk); // Append new chunk to end of linked list
23.1 --- a/src/share/vm/prims/jvmtiEnv.cpp Tue Jun 03 21:36:53 2014 -0700 23.2 +++ b/src/share/vm/prims/jvmtiEnv.cpp Wed Jun 04 07:07:31 2014 -0700 23.3 @@ -307,9 +307,9 @@ 23.4 !java_lang_Class::is_primitive(mirror)) { 23.5 Klass* k = java_lang_Class::as_Klass(mirror); 23.6 assert(k != NULL, "class for non-primitive mirror must exist"); 23.7 - *size_ptr = k->size() * wordSize; 23.8 + *size_ptr = (jlong)k->size() * wordSize; 23.9 } else { 23.10 - *size_ptr = mirror->size() * wordSize; 23.11 + *size_ptr = (jlong)mirror->size() * wordSize; 23.12 } 23.13 return JVMTI_ERROR_NONE; 23.14 } /* end GetObjectSize */
24.1 --- a/src/share/vm/runtime/java.cpp Tue Jun 03 21:36:53 2014 -0700 24.2 +++ b/src/share/vm/runtime/java.cpp Wed Jun 04 07:07:31 2014 -0700 24.3 @@ -497,6 +497,9 @@ 24.4 os::infinite_sleep(); 24.5 } 24.6 24.7 + // Stop any ongoing concurrent GC work 24.8 + Universe::heap()->stop(); 24.9 + 24.10 // Terminate watcher thread - must before disenrolling any periodic task 24.11 if (PeriodicTask::num_tasks() > 0) 24.12 WatcherThread::stop();
25.1 --- a/src/share/vm/utilities/workgroup.cpp Tue Jun 03 21:36:53 2014 -0700 25.2 +++ b/src/share/vm/utilities/workgroup.cpp Wed Jun 04 07:07:31 2014 -0700 25.3 @@ -378,21 +378,22 @@ 25.4 25.5 WorkGangBarrierSync::WorkGangBarrierSync() 25.6 : _monitor(Mutex::safepoint, "work gang barrier sync", true), 25.7 - _n_workers(0), _n_completed(0), _should_reset(false) { 25.8 + _n_workers(0), _n_completed(0), _should_reset(false), _aborted(false) { 25.9 } 25.10 25.11 WorkGangBarrierSync::WorkGangBarrierSync(uint n_workers, const char* name) 25.12 : _monitor(Mutex::safepoint, name, true), 25.13 - _n_workers(n_workers), _n_completed(0), _should_reset(false) { 25.14 + _n_workers(n_workers), _n_completed(0), _should_reset(false), _aborted(false) { 25.15 } 25.16 25.17 void WorkGangBarrierSync::set_n_workers(uint n_workers) { 25.18 - _n_workers = n_workers; 25.19 - _n_completed = 0; 25.20 + _n_workers = n_workers; 25.21 + _n_completed = 0; 25.22 _should_reset = false; 25.23 + _aborted = false; 25.24 } 25.25 25.26 -void WorkGangBarrierSync::enter() { 25.27 +bool WorkGangBarrierSync::enter() { 25.28 MutexLockerEx x(monitor(), Mutex::_no_safepoint_check_flag); 25.29 if (should_reset()) { 25.30 // The should_reset() was set and we are the first worker to enter 25.31 @@ -415,10 +416,17 @@ 25.32 set_should_reset(true); 25.33 monitor()->notify_all(); 25.34 } else { 25.35 - while (n_completed() != n_workers()) { 25.36 + while (n_completed() != n_workers() && !aborted()) { 25.37 monitor()->wait(/* no_safepoint_check */ true); 25.38 } 25.39 } 25.40 + return !aborted(); 25.41 +} 25.42 + 25.43 +void WorkGangBarrierSync::abort() { 25.44 + MutexLockerEx x(monitor(), Mutex::_no_safepoint_check_flag); 25.45 + set_aborted(); 25.46 + monitor()->notify_all(); 25.47 } 25.48 25.49 // SubTasksDone functions.
26.1 --- a/src/share/vm/utilities/workgroup.hpp Tue Jun 03 21:36:53 2014 -0700 26.2 +++ b/src/share/vm/utilities/workgroup.hpp Wed Jun 04 07:07:31 2014 -0700 26.3 @@ -359,18 +359,20 @@ 26.4 class WorkGangBarrierSync : public StackObj { 26.5 protected: 26.6 Monitor _monitor; 26.7 - uint _n_workers; 26.8 - uint _n_completed; 26.9 + uint _n_workers; 26.10 + uint _n_completed; 26.11 bool _should_reset; 26.12 + bool _aborted; 26.13 26.14 Monitor* monitor() { return &_monitor; } 26.15 uint n_workers() { return _n_workers; } 26.16 uint n_completed() { return _n_completed; } 26.17 bool should_reset() { return _should_reset; } 26.18 + bool aborted() { return _aborted; } 26.19 26.20 void zero_completed() { _n_completed = 0; } 26.21 void inc_completed() { _n_completed++; } 26.22 - 26.23 + void set_aborted() { _aborted = true; } 26.24 void set_should_reset(bool v) { _should_reset = v; } 26.25 26.26 public: 26.27 @@ -383,8 +385,14 @@ 26.28 26.29 // Enter the barrier. A worker that enters the barrier will 26.30 // not be allowed to leave until all other threads have 26.31 - // also entered the barrier. 26.32 - void enter(); 26.33 + // also entered the barrier or the barrier is aborted. 26.34 + // Returns false if the barrier was aborted. 26.35 + bool enter(); 26.36 + 26.37 + // Aborts the barrier and wakes up any threads waiting for 26.38 + // the barrier to complete. The barrier will remain in the 26.39 + // aborted state until the next call to set_n_workers(). 26.40 + void abort(); 26.41 }; 26.42 26.43 // A class to manage claiming of subtasks within a group of tasks. The
27.1 --- a/test/TEST.groups Tue Jun 03 21:36:53 2014 -0700 27.2 +++ b/test/TEST.groups Wed Jun 04 07:07:31 2014 -0700 27.3 @@ -134,6 +134,8 @@ 27.4 gc/arguments/TestDynMaxHeapFreeRatio.java \ 27.5 runtime/InternalApi/ThreadCpuTimesDeadlock.java \ 27.6 serviceability/threads/TestFalseDeadLock.java \ 27.7 + serviceability/jvmti/GetObjectSizeOverflow.java \ 27.8 + serviceability/jvmti/TestRedefineWithUnresolvedClass.java \ 27.9 compiler/tiered/NonTieredLevelsTest.java \ 27.10 compiler/tiered/TieredLevelsTest.java \ 27.11 compiler/intrinsics/bmi/verifycode
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/test/serviceability/jvmti/GetObjectSizeOverflow.java Wed Jun 04 07:07:31 2014 -0700 28.3 @@ -0,0 +1,64 @@ 28.4 +/* 28.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 28.7 + * 28.8 + * This code is free software; you can redistribute it and/or modify it 28.9 + * under the terms of the GNU General Public License version 2 only, as 28.10 + * published by the Free Software Foundation. 28.11 + * 28.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 28.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 28.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 28.15 + * version 2 for more details (a copy is included in the LICENSE file that 28.16 + * accompanied this code). 28.17 + * 28.18 + * You should have received a copy of the GNU General Public License version 28.19 + * 2 along with this work; if not, write to the Free Software Foundation, 28.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 28.21 + * 28.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 28.23 + * or visit www.oracle.com if you need additional information or have any 28.24 + * questions. 28.25 + */ 28.26 +import java.io.PrintWriter; 28.27 +import com.oracle.java.testlibrary.*; 28.28 + 28.29 +/* 28.30 + * Test to verify GetObjectSize does not overflow on a 600M element int[] 28.31 + * 28.32 + * @test 28.33 + * @bug 8027230 28.34 + * @library /testlibrary 28.35 + * @build GetObjectSizeOverflowAgent 28.36 + * @run main ClassFileInstaller GetObjectSizeOverflowAgent 28.37 + * @run main GetObjectSizeOverflow 28.38 + */ 28.39 +public class GetObjectSizeOverflow { 28.40 + public static void main(String[] args) throws Exception { 28.41 + 28.42 + if (!Platform.is64bit()) { 28.43 + System.out.println("Test needs a 4GB heap and can only be run as a 64bit process, skipping."); 28.44 + return; 28.45 + } 28.46 + 28.47 + PrintWriter pw = new PrintWriter("MANIFEST.MF"); 28.48 + pw.println("Premain-Class: GetObjectSizeOverflowAgent"); 28.49 + pw.close(); 28.50 + 28.51 + ProcessBuilder pb = new ProcessBuilder(); 28.52 + pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "GetObjectSizeOverflowAgent.class"}); 28.53 + pb.start().waitFor(); 28.54 + 28.55 + ProcessBuilder pt = ProcessTools.createJavaProcessBuilder(true, "-Xmx4000m", "-javaagent:agent.jar", "GetObjectSizeOverflowAgent"); 28.56 + OutputAnalyzer output = new OutputAnalyzer(pt.start()); 28.57 + 28.58 + if (output.getStdout().contains("Could not reserve enough space") || output.getStderr().contains("java.lang.OutOfMemoryError")) { 28.59 + System.out.println("stdout: " + output.getStdout()); 28.60 + System.out.println("stderr: " + output.getStderr()); 28.61 + System.out.println("Test could not reserve or allocate enough space, skipping"); 28.62 + return; 28.63 + } 28.64 + 28.65 + output.stdoutShouldContain("GetObjectSizeOverflow passed"); 28.66 + } 28.67 +}
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/test/serviceability/jvmti/GetObjectSizeOverflowAgent.java Wed Jun 04 07:07:31 2014 -0700 29.3 @@ -0,0 +1,43 @@ 29.4 +/* 29.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.7 + * 29.8 + * This code is free software; you can redistribute it and/or modify it 29.9 + * under the terms of the GNU General Public License version 2 only, as 29.10 + * published by the Free Software Foundation. 29.11 + * 29.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 29.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 29.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 29.15 + * version 2 for more details (a copy is included in the LICENSE file that 29.16 + * accompanied this code). 29.17 + * 29.18 + * You should have received a copy of the GNU General Public License version 29.19 + * 2 along with this work; if not, write to the Free Software Foundation, 29.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 29.21 + * 29.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 29.23 + * or visit www.oracle.com if you need additional information or have any 29.24 + * questions. 29.25 + */ 29.26 +import java.lang.instrument.*; 29.27 + 29.28 +public class GetObjectSizeOverflowAgent { 29.29 + 29.30 + static Instrumentation instrumentation; 29.31 + 29.32 + public static void premain(String agentArgs, Instrumentation instrumentation) { 29.33 + GetObjectSizeOverflowAgent.instrumentation = instrumentation; 29.34 + } 29.35 + 29.36 + public static void main(String[] args) throws Exception { 29.37 + int[] a = new int[600_000_000]; 29.38 + long size = instrumentation.getObjectSize(a); 29.39 + 29.40 + if (size < 2_400_000_000L) { 29.41 + throw new RuntimeException("Invalid size of array, expected >= 2400000000, got " + size); 29.42 + } 29.43 + 29.44 + System.out.println("GetObjectSizeOverflow passed"); 29.45 + } 29.46 +}