Fri, 07 Jan 2011 15:54:32 -0800
Merge
1.1 --- a/src/cpu/sparc/vm/assembler_sparc.cpp Fri Jan 07 03:41:07 2011 -0800 1.2 +++ b/src/cpu/sparc/vm/assembler_sparc.cpp Fri Jan 07 15:54:32 2011 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -4102,11 +4102,15 @@ 1.11 store_klass(t2, top); 1.12 verify_oop(top); 1.13 1.14 + ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t1); 1.15 + sub(top, t1, t1); // size of tlab's allocated portion 1.16 + incr_allocated_bytes(t1, 0, t2); 1.17 + 1.18 // refill the tlab with an eden allocation 1.19 bind(do_refill); 1.20 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_size_offset()), t1); 1.21 sll_ptr(t1, LogHeapWordSize, t1); 1.22 - // add object_size ?? 1.23 + // allocate new tlab, address returned in top 1.24 eden_allocate(top, t1, 0, t2, t3, slow_case); 1.25 1.26 st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_start_offset())); 1.27 @@ -4134,6 +4138,22 @@ 1.28 delayed()->nop(); 1.29 } 1.30 1.31 +void MacroAssembler::incr_allocated_bytes(Register var_size_in_bytes, 1.32 + int con_size_in_bytes, 1.33 + Register t1) { 1.34 + // Bump total bytes allocated by this thread 1.35 + assert(t1->is_global(), "must be global reg"); // so all 64 bits are saved on a context switch 1.36 + assert_different_registers(var_size_in_bytes, t1); 1.37 + // v8 support has gone the way of the dodo 1.38 + ldx(G2_thread, in_bytes(JavaThread::allocated_bytes_offset()), t1); 1.39 + if (var_size_in_bytes->is_valid()) { 1.40 + add(t1, var_size_in_bytes, t1); 1.41 + } else { 1.42 + add(t1, con_size_in_bytes, t1); 1.43 + } 1.44 + stx(t1, G2_thread, in_bytes(JavaThread::allocated_bytes_offset())); 1.45 +} 1.46 + 1.47 Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) { 1.48 switch (cond) { 1.49 // Note some conditions are synonyms for others
2.1 --- a/src/cpu/sparc/vm/assembler_sparc.hpp Fri Jan 07 03:41:07 2011 -0800 2.2 +++ b/src/cpu/sparc/vm/assembler_sparc.hpp Fri Jan 07 15:54:32 2011 -0800 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 1997, 2011, 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 @@ -2389,6 +2389,7 @@ 2.11 Label& slow_case // continuation point if fast allocation fails 2.12 ); 2.13 void tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case); 2.14 + void incr_allocated_bytes(Register var_size_in_bytes, int con_size_in_bytes, Register t1); 2.15 2.16 // interface method calling 2.17 void lookup_interface_method(Register recv_klass,
3.1 --- a/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp Fri Jan 07 03:41:07 2011 -0800 3.2 +++ b/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp Fri Jan 07 15:54:32 2011 -0800 3.3 @@ -166,7 +166,7 @@ 3.4 Register obj, // result: pointer to object after successful allocation 3.5 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise 3.6 int con_size_in_bytes, // object size in bytes if known at compile time 3.7 - Register t1, // temp register 3.8 + Register t1, // temp register, must be global register for incr_allocated_bytes 3.9 Register t2, // temp register 3.10 Label& slow_case // continuation point if fast allocation fails 3.11 ) { 3.12 @@ -174,6 +174,7 @@ 3.13 tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case); 3.14 } else { 3.15 eden_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case); 3.16 + incr_allocated_bytes(var_size_in_bytes, con_size_in_bytes, t1); 3.17 } 3.18 } 3.19 3.20 @@ -214,7 +215,7 @@ 3.21 void C1_MacroAssembler::allocate_object( 3.22 Register obj, // result: pointer to object after successful allocation 3.23 Register t1, // temp register 3.24 - Register t2, // temp register 3.25 + Register t2, // temp register, must be a global register for try_allocate 3.26 Register t3, // temp register 3.27 int hdr_size, // object header size in words 3.28 int obj_size, // object size in words
4.1 --- a/src/cpu/sparc/vm/c1_MacroAssembler_sparc.hpp Fri Jan 07 03:41:07 2011 -0800 4.2 +++ b/src/cpu/sparc/vm/c1_MacroAssembler_sparc.hpp Fri Jan 07 15:54:32 2011 -0800 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it
5.1 --- a/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp Fri Jan 07 03:41:07 2011 -0800 5.2 +++ b/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp Fri Jan 07 15:54:32 2011 -0800 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -448,7 +448,9 @@ 5.11 5.12 // get the instance size 5.13 __ ld(G5_klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes(), G1_obj_size); 5.14 + 5.15 __ tlab_allocate(O0_obj, G1_obj_size, 0, G3_t1, slow_path); 5.16 + 5.17 __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2); 5.18 __ verify_oop(O0_obj); 5.19 __ mov(O0, I0); 5.20 @@ -459,6 +461,8 @@ 5.21 // get the instance size 5.22 __ ld(G5_klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes(), G1_obj_size); 5.23 __ eden_allocate(O0_obj, G1_obj_size, 0, G3_t1, G4_t2, slow_path); 5.24 + __ incr_allocated_bytes(G1_obj_size, 0, G3_t1); 5.25 + 5.26 __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2); 5.27 __ verify_oop(O0_obj); 5.28 __ mov(O0, I0); 5.29 @@ -573,6 +577,7 @@ 5.30 __ and3(G1_arr_size, ~MinObjAlignmentInBytesMask, G1_arr_size); 5.31 5.32 __ eden_allocate(O0_obj, G1_arr_size, 0, G3_t1, O1_t2, slow_path); // preserves G1_arr_size 5.33 + __ incr_allocated_bytes(G1_arr_size, 0, G3_t1); 5.34 5.35 __ initialize_header(O0_obj, G5_klass, G4_length, G3_t1, O1_t2); 5.36 __ ldub(klass_lh, G3_t1, klass_lh_header_size_offset);
6.1 --- a/src/cpu/sparc/vm/templateTable_sparc.cpp Fri Jan 07 03:41:07 2011 -0800 6.2 +++ b/src/cpu/sparc/vm/templateTable_sparc.cpp Fri Jan 07 15:54:32 2011 -0800 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -3393,21 +3393,21 @@ 6.11 __ delayed()->st_ptr(RnewTopValue, G2_thread, in_bytes(JavaThread::tlab_top_offset())); 6.12 6.13 if (allow_shared_alloc) { 6.14 - // Check if tlab should be discarded (refill_waste_limit >= free) 6.15 - __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), RtlabWasteLimitValue); 6.16 - __ sub(RendValue, RoldTopValue, RfreeValue); 6.17 + // Check if tlab should be discarded (refill_waste_limit >= free) 6.18 + __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), RtlabWasteLimitValue); 6.19 + __ sub(RendValue, RoldTopValue, RfreeValue); 6.20 #ifdef _LP64 6.21 - __ srlx(RfreeValue, LogHeapWordSize, RfreeValue); 6.22 + __ srlx(RfreeValue, LogHeapWordSize, RfreeValue); 6.23 #else 6.24 - __ srl(RfreeValue, LogHeapWordSize, RfreeValue); 6.25 + __ srl(RfreeValue, LogHeapWordSize, RfreeValue); 6.26 #endif 6.27 - __ cmp(RtlabWasteLimitValue, RfreeValue); 6.28 - __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, slow_case); // tlab waste is small 6.29 - __ delayed()->nop(); 6.30 - 6.31 - // increment waste limit to prevent getting stuck on this slow path 6.32 - __ add(RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment(), RtlabWasteLimitValue); 6.33 - __ st_ptr(RtlabWasteLimitValue, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset())); 6.34 + __ cmp(RtlabWasteLimitValue, RfreeValue); 6.35 + __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, slow_case); // tlab waste is small 6.36 + __ delayed()->nop(); 6.37 + 6.38 + // increment waste limit to prevent getting stuck on this slow path 6.39 + __ add(RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment(), RtlabWasteLimitValue); 6.40 + __ st_ptr(RtlabWasteLimitValue, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset())); 6.41 } else { 6.42 // No allocation in the shared eden. 6.43 __ br(Assembler::always, false, Assembler::pt, slow_case); 6.44 @@ -3445,6 +3445,9 @@ 6.45 __ cmp(RoldTopValue, RnewTopValue); 6.46 __ brx(Assembler::notEqual, false, Assembler::pn, retry); 6.47 __ delayed()->nop(); 6.48 + 6.49 + // bump total bytes allocated by this thread 6.50 + __ incr_allocated_bytes(Roffset, 0, G1_scratch); 6.51 } 6.52 6.53 if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) {
7.1 --- a/src/cpu/x86/vm/assembler_x86.cpp Fri Jan 07 03:41:07 2011 -0800 7.2 +++ b/src/cpu/x86/vm/assembler_x86.cpp Fri Jan 07 15:54:32 2011 -0800 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 1997, 2011, 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 @@ -820,7 +820,20 @@ 7.11 } 7.12 7.13 7.14 -// Now the Assembler instruction (identical for 32/64 bits) 7.15 +// Now the Assembler instructions (identical for 32/64 bits) 7.16 + 7.17 +void Assembler::adcl(Address dst, int32_t imm32) { 7.18 + InstructionMark im(this); 7.19 + prefix(dst); 7.20 + emit_arith_operand(0x81, rdx, dst, imm32); 7.21 +} 7.22 + 7.23 +void Assembler::adcl(Address dst, Register src) { 7.24 + InstructionMark im(this); 7.25 + prefix(dst, src); 7.26 + emit_byte(0x11); 7.27 + emit_operand(src, dst); 7.28 +} 7.29 7.30 void Assembler::adcl(Register dst, int32_t imm32) { 7.31 prefix(dst); 7.32 @@ -2195,9 +2208,7 @@ 7.33 void Assembler::orl(Address dst, int32_t imm32) { 7.34 InstructionMark im(this); 7.35 prefix(dst); 7.36 - emit_byte(0x81); 7.37 - emit_operand(rcx, dst, 4); 7.38 - emit_long(imm32); 7.39 + emit_arith_operand(0x81, rcx, dst, imm32); 7.40 } 7.41 7.42 void Assembler::orl(Register dst, int32_t imm32) { 7.43 @@ -2205,7 +2216,6 @@ 7.44 emit_arith(0x81, 0xC8, dst, imm32); 7.45 } 7.46 7.47 - 7.48 void Assembler::orl(Register dst, Address src) { 7.49 InstructionMark im(this); 7.50 prefix(src, dst); 7.51 @@ -2213,7 +2223,6 @@ 7.52 emit_operand(dst, src); 7.53 } 7.54 7.55 - 7.56 void Assembler::orl(Register dst, Register src) { 7.57 (void) prefix_and_encode(dst->encoding(), src->encoding()); 7.58 emit_arith(0x0B, 0xC0, dst, src); 7.59 @@ -2692,15 +2701,14 @@ 7.60 void Assembler::subl(Address dst, int32_t imm32) { 7.61 InstructionMark im(this); 7.62 prefix(dst); 7.63 - if (is8bit(imm32)) { 7.64 - emit_byte(0x83); 7.65 - emit_operand(rbp, dst, 1); 7.66 - emit_byte(imm32 & 0xFF); 7.67 - } else { 7.68 - emit_byte(0x81); 7.69 - emit_operand(rbp, dst, 4); 7.70 - emit_long(imm32); 7.71 - } 7.72 + emit_arith_operand(0x81, rbp, dst, imm32); 7.73 +} 7.74 + 7.75 +void Assembler::subl(Address dst, Register src) { 7.76 + InstructionMark im(this); 7.77 + prefix(dst, src); 7.78 + emit_byte(0x29); 7.79 + emit_operand(src, dst); 7.80 } 7.81 7.82 void Assembler::subl(Register dst, int32_t imm32) { 7.83 @@ -2708,13 +2716,6 @@ 7.84 emit_arith(0x81, 0xE8, dst, imm32); 7.85 } 7.86 7.87 -void Assembler::subl(Address dst, Register src) { 7.88 - InstructionMark im(this); 7.89 - prefix(dst, src); 7.90 - emit_byte(0x29); 7.91 - emit_operand(src, dst); 7.92 -} 7.93 - 7.94 void Assembler::subl(Register dst, Address src) { 7.95 InstructionMark im(this); 7.96 prefix(src, dst); 7.97 @@ -4333,6 +4334,7 @@ 7.98 emit_byte(0xD3); 7.99 emit_byte(0xF8 | encode); 7.100 } 7.101 + 7.102 void Assembler::sbbq(Address dst, int32_t imm32) { 7.103 InstructionMark im(this); 7.104 prefixq(dst); 7.105 @@ -4392,15 +4394,14 @@ 7.106 void Assembler::subq(Address dst, int32_t imm32) { 7.107 InstructionMark im(this); 7.108 prefixq(dst); 7.109 - if (is8bit(imm32)) { 7.110 - emit_byte(0x83); 7.111 - emit_operand(rbp, dst, 1); 7.112 - emit_byte(imm32 & 0xFF); 7.113 - } else { 7.114 - emit_byte(0x81); 7.115 - emit_operand(rbp, dst, 4); 7.116 - emit_long(imm32); 7.117 - } 7.118 + emit_arith_operand(0x81, rbp, dst, imm32); 7.119 +} 7.120 + 7.121 +void Assembler::subq(Address dst, Register src) { 7.122 + InstructionMark im(this); 7.123 + prefixq(dst, src); 7.124 + emit_byte(0x29); 7.125 + emit_operand(src, dst); 7.126 } 7.127 7.128 void Assembler::subq(Register dst, int32_t imm32) { 7.129 @@ -4408,13 +4409,6 @@ 7.130 emit_arith(0x81, 0xE8, dst, imm32); 7.131 } 7.132 7.133 -void Assembler::subq(Address dst, Register src) { 7.134 - InstructionMark im(this); 7.135 - prefixq(dst, src); 7.136 - emit_byte(0x29); 7.137 - emit_operand(src, dst); 7.138 -} 7.139 - 7.140 void Assembler::subq(Register dst, Address src) { 7.141 InstructionMark im(this); 7.142 prefixq(src, dst); 7.143 @@ -7136,9 +7130,9 @@ 7.144 } 7.145 7.146 // Preserves rbx, and rdx. 7.147 -void MacroAssembler::tlab_refill(Label& retry, 7.148 - Label& try_eden, 7.149 - Label& slow_case) { 7.150 +Register MacroAssembler::tlab_refill(Label& retry, 7.151 + Label& try_eden, 7.152 + Label& slow_case) { 7.153 Register top = rax; 7.154 Register t1 = rcx; 7.155 Register t2 = rsi; 7.156 @@ -7185,7 +7179,7 @@ 7.157 7.158 // if tlab is currently allocated (top or end != null) then 7.159 // fill [top, end + alignment_reserve) with array object 7.160 - testptr (top, top); 7.161 + testptr(top, top); 7.162 jcc(Assembler::zero, do_refill); 7.163 7.164 // set up the mark word 7.165 @@ -7197,16 +7191,20 @@ 7.166 movl(Address(top, arrayOopDesc::length_offset_in_bytes()), t1); 7.167 // set klass to intArrayKlass 7.168 // dubious reloc why not an oop reloc? 7.169 - movptr(t1, ExternalAddress((address) Universe::intArrayKlassObj_addr())); 7.170 + movptr(t1, ExternalAddress((address)Universe::intArrayKlassObj_addr())); 7.171 // store klass last. concurrent gcs assumes klass length is valid if 7.172 // klass field is not null. 7.173 store_klass(top, t1); 7.174 7.175 + movptr(t1, top); 7.176 + subptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_start_offset()))); 7.177 + incr_allocated_bytes(thread_reg, t1, 0); 7.178 + 7.179 // refill the tlab with an eden allocation 7.180 bind(do_refill); 7.181 movptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_size_offset()))); 7.182 shlptr(t1, LogHeapWordSize); 7.183 - // add object_size ?? 7.184 + // allocate new tlab, address returned in top 7.185 eden_allocate(top, t1, 0, t2, slow_case); 7.186 7.187 // Check that t1 was preserved in eden_allocate. 7.188 @@ -7234,6 +7232,34 @@ 7.189 movptr(Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())), top); 7.190 verify_tlab(); 7.191 jmp(retry); 7.192 + 7.193 + return thread_reg; // for use by caller 7.194 +} 7.195 + 7.196 +void MacroAssembler::incr_allocated_bytes(Register thread, 7.197 + Register var_size_in_bytes, 7.198 + int con_size_in_bytes, 7.199 + Register t1) { 7.200 +#ifdef _LP64 7.201 + if (var_size_in_bytes->is_valid()) { 7.202 + addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes); 7.203 + } else { 7.204 + addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes); 7.205 + } 7.206 +#else 7.207 + if (!thread->is_valid()) { 7.208 + assert(t1->is_valid(), "need temp reg"); 7.209 + thread = t1; 7.210 + get_thread(thread); 7.211 + } 7.212 + 7.213 + if (var_size_in_bytes->is_valid()) { 7.214 + addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes); 7.215 + } else { 7.216 + addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes); 7.217 + } 7.218 + adcl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())+4), 0); 7.219 +#endif 7.220 } 7.221 7.222 static const double pi_4 = 0.7853981633974483;
8.1 --- a/src/cpu/x86/vm/assembler_x86.hpp Fri Jan 07 03:41:07 2011 -0800 8.2 +++ b/src/cpu/x86/vm/assembler_x86.hpp Fri Jan 07 15:54:32 2011 -0800 8.3 @@ -1,5 +1,5 @@ 8.4 /* 8.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 8.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 8.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.8 * 8.9 * This code is free software; you can redistribute it and/or modify it 8.10 @@ -674,12 +674,14 @@ 8.11 // Utilities 8.12 8.13 #ifdef _LP64 8.14 - static bool is_simm(int64_t x, int nbits) { return -( CONST64(1) << (nbits-1) ) <= x && x < ( CONST64(1) << (nbits-1) ); } 8.15 + static bool is_simm(int64_t x, int nbits) { return -(CONST64(1) << (nbits-1)) <= x && 8.16 + x < (CONST64(1) << (nbits-1)); } 8.17 static bool is_simm32(int64_t x) { return x == (int64_t)(int32_t)x; } 8.18 #else 8.19 - static bool is_simm(int32_t x, int nbits) { return -( 1 << (nbits-1) ) <= x && x < ( 1 << (nbits-1) ); } 8.20 + static bool is_simm(int32_t x, int nbits) { return -(1 << (nbits-1)) <= x && 8.21 + x < (1 << (nbits-1)); } 8.22 static bool is_simm32(int32_t x) { return true; } 8.23 -#endif // LP64 8.24 +#endif // _LP64 8.25 8.26 // Generic instructions 8.27 // Does 32bit or 64bit as needed for the platform. In some sense these 8.28 @@ -705,7 +707,6 @@ 8.29 void push(void* v); 8.30 void pop(void* v); 8.31 8.32 - 8.33 // These do register sized moves/scans 8.34 void rep_mov(); 8.35 void rep_set(); 8.36 @@ -716,6 +717,8 @@ 8.37 8.38 // Vanilla instructions in lexical order 8.39 8.40 + void adcl(Address dst, int32_t imm32); 8.41 + void adcl(Address dst, Register src); 8.42 void adcl(Register dst, int32_t imm32); 8.43 void adcl(Register dst, Address src); 8.44 void adcl(Register dst, Register src); 8.45 @@ -724,7 +727,6 @@ 8.46 void adcq(Register dst, Address src); 8.47 void adcq(Register dst, Register src); 8.48 8.49 - 8.50 void addl(Address dst, int32_t imm32); 8.51 void addl(Address dst, Register src); 8.52 void addl(Register dst, int32_t imm32); 8.53 @@ -737,7 +739,6 @@ 8.54 void addq(Register dst, Address src); 8.55 void addq(Register dst, Register src); 8.56 8.57 - 8.58 void addr_nop_4(); 8.59 void addr_nop_5(); 8.60 void addr_nop_7(); 8.61 @@ -759,7 +760,6 @@ 8.62 void andq(Register dst, Address src); 8.63 void andq(Register dst, Register src); 8.64 8.65 - 8.66 // Bitwise Logical AND of Packed Double-Precision Floating-Point Values 8.67 void andpd(XMMRegister dst, Address src); 8.68 void andpd(XMMRegister dst, XMMRegister src); 8.69 @@ -1151,7 +1151,7 @@ 8.70 #ifdef _LP64 8.71 void movq(Register dst, Register src); 8.72 void movq(Register dst, Address src); 8.73 - void movq(Address dst, Register src); 8.74 + void movq(Address dst, Register src); 8.75 #endif 8.76 8.77 void movq(Address dst, MMXRegister src ); 8.78 @@ -1177,7 +1177,7 @@ 8.79 void movsbq(Register dst, Register src); 8.80 8.81 // Move signed 32bit immediate to 64bit extending sign 8.82 - void movslq(Address dst, int32_t imm64); 8.83 + void movslq(Address dst, int32_t imm64); 8.84 void movslq(Register dst, int32_t imm64); 8.85 8.86 void movslq(Register dst, Address src); 8.87 @@ -1857,7 +1857,10 @@ 8.88 Register t2, // temp register 8.89 Label& slow_case // continuation point if fast allocation fails 8.90 ); 8.91 - void tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case); 8.92 + Register tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case); // returns TLS address 8.93 + void incr_allocated_bytes(Register thread, 8.94 + Register var_size_in_bytes, int con_size_in_bytes, 8.95 + Register t1 = noreg); 8.96 8.97 // interface method calling 8.98 void lookup_interface_method(Register recv_klass, 8.99 @@ -2180,9 +2183,9 @@ 8.100 void divss(XMMRegister dst, Address src) { Assembler::divss(dst, src); } 8.101 void divss(XMMRegister dst, AddressLiteral src) { Assembler::divss(dst, as_Address(src)); } 8.102 8.103 - void movsd(XMMRegister dst, XMMRegister src) { Assembler::movsd(dst, src); } 8.104 - void movsd(Address dst, XMMRegister src) { Assembler::movsd(dst, src); } 8.105 - void movsd(XMMRegister dst, Address src) { Assembler::movsd(dst, src); } 8.106 + void movsd(XMMRegister dst, XMMRegister src) { Assembler::movsd(dst, src); } 8.107 + void movsd(Address dst, XMMRegister src) { Assembler::movsd(dst, src); } 8.108 + void movsd(XMMRegister dst, Address src) { Assembler::movsd(dst, src); } 8.109 void movsd(XMMRegister dst, AddressLiteral src) { Assembler::movsd(dst, as_Address(src)); } 8.110 8.111 void mulsd(XMMRegister dst, XMMRegister src) { Assembler::mulsd(dst, src); }
9.1 --- a/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Fri Jan 07 03:41:07 2011 -0800 9.2 +++ b/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Fri Jan 07 15:54:32 2011 -0800 9.3 @@ -1,5 +1,5 @@ 9.4 /* 9.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 9.6 + * Copyright (c) 1999, 2011, 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 @@ -141,6 +141,7 @@ 9.11 tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case); 9.12 } else { 9.13 eden_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case); 9.14 + incr_allocated_bytes(noreg, var_size_in_bytes, con_size_in_bytes, t1); 9.15 } 9.16 } 9.17 9.18 @@ -234,7 +235,7 @@ 9.19 9.20 void C1_MacroAssembler::allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case) { 9.21 assert(obj == rax, "obj must be in rax, for cmpxchg"); 9.22 - assert(obj != t1 && obj != t2 && t1 != t2, "registers must be different"); // XXX really? 9.23 + assert_different_registers(obj, t1, t2); // XXX really? 9.24 assert(header_size >= 0 && object_size >= header_size, "illegal sizes"); 9.25 9.26 try_allocate(obj, noreg, object_size * BytesPerWord, t1, t2, slow_case);
10.1 --- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp Fri Jan 07 03:41:07 2011 -0800 10.2 +++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp Fri Jan 07 15:54:32 2011 -0800 10.3 @@ -1,5 +1,5 @@ 10.4 /* 10.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 10.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 10.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.8 * 10.9 * This code is free software; you can redistribute it and/or modify it 10.10 @@ -977,7 +977,6 @@ 10.11 // verify that that there is really a valid exception in rax, 10.12 __ verify_not_null_oop(exception_oop); 10.13 10.14 - 10.15 oop_maps = new OopMapSet(); 10.16 OopMap* oop_map = generate_oop_map(sasm, 1); 10.17 generate_handle_exception(sasm, oop_maps, oop_map); 10.18 @@ -1037,13 +1036,16 @@ 10.19 // if we got here then the TLAB allocation failed, so try 10.20 // refilling the TLAB or allocating directly from eden. 10.21 Label retry_tlab, try_eden; 10.22 - __ tlab_refill(retry_tlab, try_eden, slow_path); // does not destroy rdx (klass) 10.23 + const Register thread = 10.24 + __ tlab_refill(retry_tlab, try_eden, slow_path); // does not destroy rdx (klass), returns rdi 10.25 10.26 __ bind(retry_tlab); 10.27 10.28 // get the instance size (size is postive so movl is fine for 64bit) 10.29 __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); 10.30 + 10.31 __ tlab_allocate(obj, obj_size, 0, t1, t2, slow_path); 10.32 + 10.33 __ initialize_object(obj, klass, obj_size, 0, t1, t2); 10.34 __ verify_oop(obj); 10.35 __ pop(rbx); 10.36 @@ -1053,7 +1055,10 @@ 10.37 __ bind(try_eden); 10.38 // get the instance size (size is postive so movl is fine for 64bit) 10.39 __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); 10.40 + 10.41 __ eden_allocate(obj, obj_size, 0, t1, slow_path); 10.42 + __ incr_allocated_bytes(thread, obj_size, 0); 10.43 + 10.44 __ initialize_object(obj, klass, obj_size, 0, t1, t2); 10.45 __ verify_oop(obj); 10.46 __ pop(rbx); 10.47 @@ -1143,12 +1148,13 @@ 10.48 // if we got here then the TLAB allocation failed, so try 10.49 // refilling the TLAB or allocating directly from eden. 10.50 Label retry_tlab, try_eden; 10.51 - __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves rbx, & rdx 10.52 + const Register thread = 10.53 + __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves rbx & rdx, returns rdi 10.54 10.55 __ bind(retry_tlab); 10.56 10.57 // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F)) 10.58 - // since size is postive movl does right thing on 64bit 10.59 + // since size is positive movl does right thing on 64bit 10.60 __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); 10.61 // since size is postive movl does right thing on 64bit 10.62 __ movl(arr_size, length); 10.63 @@ -1175,7 +1181,7 @@ 10.64 10.65 __ bind(try_eden); 10.66 // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F)) 10.67 - // since size is postive movl does right thing on 64bit 10.68 + // since size is positive movl does right thing on 64bit 10.69 __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); 10.70 // since size is postive movl does right thing on 64bit 10.71 __ movl(arr_size, length); 10.72 @@ -1188,6 +1194,7 @@ 10.73 __ andptr(arr_size, ~MinObjAlignmentInBytesMask); 10.74 10.75 __ eden_allocate(obj, arr_size, 0, t1, slow_path); // preserves arr_size 10.76 + __ incr_allocated_bytes(thread, arr_size, 0); 10.77 10.78 __ initialize_header(obj, klass, length, t1, t2); 10.79 __ movb(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes() + (Klass::_lh_header_size_shift / BitsPerByte)));
11.1 --- a/src/cpu/x86/vm/templateTable_x86_32.cpp Fri Jan 07 03:41:07 2011 -0800 11.2 +++ b/src/cpu/x86/vm/templateTable_x86_32.cpp Fri Jan 07 15:54:32 2011 -0800 11.3 @@ -1,5 +1,5 @@ 11.4 /* 11.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 11.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 11.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.8 * 11.9 * This code is free software; you can redistribute it and/or modify it 11.10 @@ -3203,10 +3203,12 @@ 11.11 const bool allow_shared_alloc = 11.12 Universe::heap()->supports_inline_contig_alloc() && !CMSIncrementalMode; 11.13 11.14 + const Register thread = rcx; 11.15 + if (UseTLAB || allow_shared_alloc) { 11.16 + __ get_thread(thread); 11.17 + } 11.18 + 11.19 if (UseTLAB) { 11.20 - const Register thread = rcx; 11.21 - 11.22 - __ get_thread(thread); 11.23 __ movptr(rax, Address(thread, in_bytes(JavaThread::tlab_top_offset()))); 11.24 __ lea(rbx, Address(rax, rdx, Address::times_1)); 11.25 __ cmpptr(rbx, Address(thread, in_bytes(JavaThread::tlab_end_offset()))); 11.26 @@ -3247,6 +3249,8 @@ 11.27 11.28 // if someone beat us on the allocation, try again, otherwise continue 11.29 __ jcc(Assembler::notEqual, retry); 11.30 + 11.31 + __ incr_allocated_bytes(thread, rdx, 0); 11.32 } 11.33 11.34 if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) { 11.35 @@ -3256,12 +3260,12 @@ 11.36 __ decrement(rdx, sizeof(oopDesc)); 11.37 __ jcc(Assembler::zero, initialize_header); 11.38 11.39 - // Initialize topmost object field, divide rdx by 8, check if odd and 11.40 - // test if zero. 11.41 + // Initialize topmost object field, divide rdx by 8, check if odd and 11.42 + // test if zero. 11.43 __ xorl(rcx, rcx); // use zero reg to clear memory (shorter code) 11.44 __ shrl(rdx, LogBytesPerLong); // divide by 2*oopSize and set carry flag if odd 11.45 11.46 - // rdx must have been multiple of 8 11.47 + // rdx must have been multiple of 8 11.48 #ifdef ASSERT 11.49 // make sure rdx was multiple of 8 11.50 Label L;
12.1 --- a/src/cpu/x86/vm/templateTable_x86_64.cpp Fri Jan 07 03:41:07 2011 -0800 12.2 +++ b/src/cpu/x86/vm/templateTable_x86_64.cpp Fri Jan 07 15:54:32 2011 -0800 12.3 @@ -1,5 +1,5 @@ 12.4 /* 12.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 12.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 12.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.8 * 12.9 * This code is free software; you can redistribute it and/or modify it 12.10 @@ -3266,6 +3266,8 @@ 12.11 12.12 // if someone beat us on the allocation, try again, otherwise continue 12.13 __ jcc(Assembler::notEqual, retry); 12.14 + 12.15 + __ incr_allocated_bytes(r15_thread, rdx, 0); 12.16 } 12.17 12.18 if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) {
13.1 --- a/src/os/solaris/vm/os_solaris.cpp Fri Jan 07 03:41:07 2011 -0800 13.2 +++ b/src/os/solaris/vm/os_solaris.cpp Fri Jan 07 15:54:32 2011 -0800 13.3 @@ -1,5 +1,5 @@ 13.4 /* 13.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 13.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 13.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.8 * 13.9 * This code is free software; you can redistribute it and/or modify it 13.10 @@ -283,7 +283,7 @@ 13.11 is_error_reported(), 13.12 "sp must be inside of selected thread stack"); 13.13 13.14 - thread->_self_raw_id = raw_id; // mark for quick retrieval 13.15 + thread->set_self_raw_id(raw_id); // mark for quick retrieval 13.16 _get_thread_cache[ index ] = thread; 13.17 } 13.18 return thread; 13.19 @@ -5197,7 +5197,7 @@ 13.20 int o_delete = (oflag & O_DELETE); 13.21 oflag = oflag & ~O_DELETE; 13.22 13.23 - fd = ::open(path, oflag, mode); 13.24 + fd = ::open64(path, oflag, mode); 13.25 if (fd == -1) return -1; 13.26 13.27 //If the open succeeded, the file might still be a directory
14.1 --- a/src/os/solaris/vm/thread_solaris.inline.hpp Fri Jan 07 03:41:07 2011 -0800 14.2 +++ b/src/os/solaris/vm/thread_solaris.inline.hpp Fri Jan 07 15:54:32 2011 -0800 14.3 @@ -1,5 +1,5 @@ 14.4 /* 14.5 - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 14.6 + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 14.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.8 * 14.9 * This code is free software; you can redistribute it and/or modify it 14.10 @@ -53,10 +53,10 @@ 14.11 14.12 uintptr_t raw = pd_raw_thread_id(); 14.13 int ix = pd_cache_index(raw); 14.14 - Thread *Candidate = ThreadLocalStorage::_get_thread_cache[ix]; 14.15 - if (Candidate->_self_raw_id == raw) { 14.16 + Thread* candidate = ThreadLocalStorage::_get_thread_cache[ix]; 14.17 + if (candidate->self_raw_id() == raw) { 14.18 // hit 14.19 - return Candidate; 14.20 + return candidate; 14.21 } else { 14.22 return ThreadLocalStorage::get_thread_via_cache_slowly(raw, ix); 14.23 }
15.1 --- a/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Fri Jan 07 03:41:07 2011 -0800 15.2 +++ b/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Fri Jan 07 15:54:32 2011 -0800 15.3 @@ -585,6 +585,13 @@ 15.4 sigaddset(&newset, sig); 15.5 sigprocmask(SIG_UNBLOCK, &newset, NULL); 15.6 15.7 + // Determine which sort of error to throw. Out of swap may signal 15.8 + // on the thread stack, which could get a mapping error when touched. 15.9 + address addr = (address) info->si_addr; 15.10 + if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) { 15.11 + vm_exit_out_of_memory(0, "Out of swap space to map in thread stack."); 15.12 + } 15.13 + 15.14 VMError err(t, sig, pc, info, ucVoid); 15.15 err.report_and_die(); 15.16
16.1 --- a/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Fri Jan 07 03:41:07 2011 -0800 16.2 +++ b/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Fri Jan 07 15:54:32 2011 -0800 16.3 @@ -742,6 +742,13 @@ 16.4 sigaddset(&newset, sig); 16.5 sigprocmask(SIG_UNBLOCK, &newset, NULL); 16.6 16.7 + // Determine which sort of error to throw. Out of swap may signal 16.8 + // on the thread stack, which could get a mapping error when touched. 16.9 + address addr = (address) info->si_addr; 16.10 + if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) { 16.11 + vm_exit_out_of_memory(0, "Out of swap space to map in thread stack."); 16.12 + } 16.13 + 16.14 VMError err(t, sig, pc, info, ucVoid); 16.15 err.report_and_die(); 16.16
17.1 --- a/src/share/vm/c1/c1_Compilation.cpp Fri Jan 07 03:41:07 2011 -0800 17.2 +++ b/src/share/vm/c1/c1_Compilation.cpp Fri Jan 07 15:54:32 2011 -0800 17.3 @@ -245,7 +245,7 @@ 17.4 } 17.5 17.6 17.7 -void Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) { 17.8 +bool Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) { 17.9 // Preinitialize the consts section to some large size: 17.10 int locs_buffer_size = 20 * (relocInfo::length_limit + sizeof(relocInfo)); 17.11 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); 17.12 @@ -253,15 +253,20 @@ 17.13 locs_buffer_size / sizeof(relocInfo)); 17.14 code->initialize_consts_size(Compilation::desired_max_constant_size()); 17.15 // Call stubs + two deopt handlers (regular and MH) + exception handler 17.16 - code->initialize_stubs_size((call_stub_estimate * LIR_Assembler::call_stub_size) + 17.17 - LIR_Assembler::exception_handler_size + 17.18 - 2 * LIR_Assembler::deopt_handler_size); 17.19 + int stub_size = (call_stub_estimate * LIR_Assembler::call_stub_size) + 17.20 + LIR_Assembler::exception_handler_size + 17.21 + (2 * LIR_Assembler::deopt_handler_size); 17.22 + if (stub_size >= code->insts_capacity()) return false; 17.23 + code->initialize_stubs_size(stub_size); 17.24 + return true; 17.25 } 17.26 17.27 17.28 int Compilation::emit_code_body() { 17.29 // emit code 17.30 - setup_code_buffer(code(), allocator()->num_calls()); 17.31 + if (!setup_code_buffer(code(), allocator()->num_calls())) { 17.32 + BAILOUT_("size requested greater than avail code buffer size", 0); 17.33 + } 17.34 code()->initialize_oop_recorder(env()->oop_recorder()); 17.35 17.36 _masm = new C1_MacroAssembler(code());
18.1 --- a/src/share/vm/c1/c1_Compilation.hpp Fri Jan 07 03:41:07 2011 -0800 18.2 +++ b/src/share/vm/c1/c1_Compilation.hpp Fri Jan 07 15:54:32 2011 -0800 18.3 @@ -192,7 +192,7 @@ 18.4 return desired_max_code_buffer_size() / 10; 18.5 } 18.6 18.7 - static void setup_code_buffer(CodeBuffer* cb, int call_stub_estimate); 18.8 + static bool setup_code_buffer(CodeBuffer* cb, int call_stub_estimate); 18.9 18.10 // timers 18.11 static void print_timers();
19.1 --- a/src/share/vm/gc_interface/collectedHeap.inline.hpp Fri Jan 07 03:41:07 2011 -0800 19.2 +++ b/src/share/vm/gc_interface/collectedHeap.inline.hpp Fri Jan 07 15:54:32 2011 -0800 19.3 @@ -1,5 +1,5 @@ 19.4 /* 19.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 19.6 + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 19.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.8 * 19.9 * This code is free software; you can redistribute it and/or modify it 19.10 @@ -153,6 +153,7 @@ 19.11 check_for_non_bad_heap_word_value(result, size)); 19.12 assert(!HAS_PENDING_EXCEPTION, 19.13 "Unexpected exception, will result in uninitialized storage"); 19.14 + THREAD->incr_allocated_bytes(size * HeapWordSize); 19.15 return result; 19.16 } 19.17
20.1 --- a/src/share/vm/memory/threadLocalAllocBuffer.cpp Fri Jan 07 03:41:07 2011 -0800 20.2 +++ b/src/share/vm/memory/threadLocalAllocBuffer.cpp Fri Jan 07 15:54:32 2011 -0800 20.3 @@ -1,5 +1,5 @@ 20.4 /* 20.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 20.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 20.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.8 * 20.9 * This code is free software; you can redistribute it and/or modify it 20.10 @@ -114,6 +114,11 @@ 20.11 void ThreadLocalAllocBuffer::make_parsable(bool retire) { 20.12 if (end() != NULL) { 20.13 invariants(); 20.14 + 20.15 + if (retire) { 20.16 + myThread()->incr_allocated_bytes(used_bytes()); 20.17 + } 20.18 + 20.19 CollectedHeap::fill_with_object(top(), hard_end(), retire); 20.20 20.21 if (retire || ZeroTLAB) { // "Reset" the TLAB
21.1 --- a/src/share/vm/memory/threadLocalAllocBuffer.hpp Fri Jan 07 03:41:07 2011 -0800 21.2 +++ b/src/share/vm/memory/threadLocalAllocBuffer.hpp Fri Jan 07 15:54:32 2011 -0800 21.3 @@ -1,5 +1,5 @@ 21.4 /* 21.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 21.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 21.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.8 * 21.9 * This code is free software; you can redistribute it and/or modify it 21.10 @@ -112,6 +112,8 @@ 21.11 HeapWord* top() const { return _top; } 21.12 HeapWord* pf_top() const { return _pf_top; } 21.13 size_t desired_size() const { return _desired_size; } 21.14 + size_t used() const { return pointer_delta(top(), start()); } 21.15 + size_t used_bytes() const { return pointer_delta(top(), start(), 1); } 21.16 size_t free() const { return pointer_delta(end(), top()); } 21.17 // Don't discard tlab if remaining space is larger than this. 21.18 size_t refill_waste_limit() const { return _refill_waste_limit; }
22.1 --- a/src/share/vm/opto/macro.cpp Fri Jan 07 03:41:07 2011 -0800 22.2 +++ b/src/share/vm/opto/macro.cpp Fri Jan 07 15:54:32 2011 -0800 22.3 @@ -1,5 +1,5 @@ 22.4 /* 22.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 22.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 22.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.8 * 22.9 * This code is free software; you can redistribute it and/or modify it 22.10 @@ -1158,7 +1158,7 @@ 22.11 // Note: We set the control input on "eden_end" and "old_eden_top" when using 22.12 // a TLAB to work around a bug where these values were being moved across 22.13 // a safepoint. These are not oops, so they cannot be include in the oop 22.14 - // map, but the can be changed by a GC. The proper way to fix this would 22.15 + // map, but they can be changed by a GC. The proper way to fix this would 22.16 // be to set the raw memory state when generating a SafepointNode. However 22.17 // this will require extensive changes to the loop optimization in order to 22.18 // prevent a degradation of the optimization. 22.19 @@ -1167,24 +1167,24 @@ 22.20 22.21 // allocate the Region and Phi nodes for the result 22.22 result_region = new (C, 3) RegionNode(3); 22.23 - result_phi_rawmem = new (C, 3) PhiNode( result_region, Type::MEMORY, TypeRawPtr::BOTTOM ); 22.24 - result_phi_rawoop = new (C, 3) PhiNode( result_region, TypeRawPtr::BOTTOM ); 22.25 - result_phi_i_o = new (C, 3) PhiNode( result_region, Type::ABIO ); // I/O is used for Prefetch 22.26 + result_phi_rawmem = new (C, 3) PhiNode(result_region, Type::MEMORY, TypeRawPtr::BOTTOM); 22.27 + result_phi_rawoop = new (C, 3) PhiNode(result_region, TypeRawPtr::BOTTOM); 22.28 + result_phi_i_o = new (C, 3) PhiNode(result_region, Type::ABIO); // I/O is used for Prefetch 22.29 22.30 // We need a Region for the loop-back contended case. 22.31 enum { fall_in_path = 1, contended_loopback_path = 2 }; 22.32 Node *contended_region; 22.33 Node *contended_phi_rawmem; 22.34 - if( UseTLAB ) { 22.35 + if (UseTLAB) { 22.36 contended_region = toobig_false; 22.37 contended_phi_rawmem = mem; 22.38 } else { 22.39 contended_region = new (C, 3) RegionNode(3); 22.40 - contended_phi_rawmem = new (C, 3) PhiNode( contended_region, Type::MEMORY, TypeRawPtr::BOTTOM); 22.41 + contended_phi_rawmem = new (C, 3) PhiNode(contended_region, Type::MEMORY, TypeRawPtr::BOTTOM); 22.42 // Now handle the passing-too-big test. We fall into the contended 22.43 // loop-back merge point. 22.44 - contended_region ->init_req( fall_in_path, toobig_false ); 22.45 - contended_phi_rawmem->init_req( fall_in_path, mem ); 22.46 + contended_region ->init_req(fall_in_path, toobig_false); 22.47 + contended_phi_rawmem->init_req(fall_in_path, mem); 22.48 transform_later(contended_region); 22.49 transform_later(contended_phi_rawmem); 22.50 } 22.51 @@ -1192,78 +1192,101 @@ 22.52 // Load(-locked) the heap top. 22.53 // See note above concerning the control input when using a TLAB 22.54 Node *old_eden_top = UseTLAB 22.55 - ? new (C, 3) LoadPNode ( ctrl, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM ) 22.56 - : new (C, 3) LoadPLockedNode( contended_region, contended_phi_rawmem, eden_top_adr ); 22.57 + ? new (C, 3) LoadPNode (ctrl, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM) 22.58 + : new (C, 3) LoadPLockedNode(contended_region, contended_phi_rawmem, eden_top_adr); 22.59 22.60 transform_later(old_eden_top); 22.61 // Add to heap top to get a new heap top 22.62 - Node *new_eden_top = new (C, 4) AddPNode( top(), old_eden_top, size_in_bytes ); 22.63 + Node *new_eden_top = new (C, 4) AddPNode(top(), old_eden_top, size_in_bytes); 22.64 transform_later(new_eden_top); 22.65 // Check for needing a GC; compare against heap end 22.66 - Node *needgc_cmp = new (C, 3) CmpPNode( new_eden_top, eden_end ); 22.67 + Node *needgc_cmp = new (C, 3) CmpPNode(new_eden_top, eden_end); 22.68 transform_later(needgc_cmp); 22.69 - Node *needgc_bol = new (C, 2) BoolNode( needgc_cmp, BoolTest::ge ); 22.70 + Node *needgc_bol = new (C, 2) BoolNode(needgc_cmp, BoolTest::ge); 22.71 transform_later(needgc_bol); 22.72 - IfNode *needgc_iff = new (C, 2) IfNode(contended_region, needgc_bol, PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN ); 22.73 + IfNode *needgc_iff = new (C, 2) IfNode(contended_region, needgc_bol, PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN); 22.74 transform_later(needgc_iff); 22.75 22.76 // Plug the failing-heap-space-need-gc test into the slow-path region 22.77 - Node *needgc_true = new (C, 1) IfTrueNode( needgc_iff ); 22.78 + Node *needgc_true = new (C, 1) IfTrueNode(needgc_iff); 22.79 transform_later(needgc_true); 22.80 - if( initial_slow_test ) { 22.81 - slow_region ->init_req( need_gc_path, needgc_true ); 22.82 + if (initial_slow_test) { 22.83 + slow_region->init_req(need_gc_path, needgc_true); 22.84 // This completes all paths into the slow merge point 22.85 transform_later(slow_region); 22.86 } else { // No initial slow path needed! 22.87 // Just fall from the need-GC path straight into the VM call. 22.88 - slow_region = needgc_true; 22.89 + slow_region = needgc_true; 22.90 } 22.91 // No need for a GC. Setup for the Store-Conditional 22.92 - Node *needgc_false = new (C, 1) IfFalseNode( needgc_iff ); 22.93 + Node *needgc_false = new (C, 1) IfFalseNode(needgc_iff); 22.94 transform_later(needgc_false); 22.95 22.96 // Grab regular I/O before optional prefetch may change it. 22.97 // Slow-path does no I/O so just set it to the original I/O. 22.98 - result_phi_i_o->init_req( slow_result_path, i_o ); 22.99 + result_phi_i_o->init_req(slow_result_path, i_o); 22.100 22.101 i_o = prefetch_allocation(i_o, needgc_false, contended_phi_rawmem, 22.102 old_eden_top, new_eden_top, length); 22.103 22.104 + // Name successful fast-path variables 22.105 + Node* fast_oop = old_eden_top; 22.106 + Node* fast_oop_ctrl; 22.107 + Node* fast_oop_rawmem; 22.108 + 22.109 // Store (-conditional) the modified eden top back down. 22.110 // StorePConditional produces flags for a test PLUS a modified raw 22.111 // memory state. 22.112 - Node *store_eden_top; 22.113 - Node *fast_oop_ctrl; 22.114 - if( UseTLAB ) { 22.115 - store_eden_top = new (C, 4) StorePNode( needgc_false, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, new_eden_top ); 22.116 + if (UseTLAB) { 22.117 + Node* store_eden_top = 22.118 + new (C, 4) StorePNode(needgc_false, contended_phi_rawmem, eden_top_adr, 22.119 + TypeRawPtr::BOTTOM, new_eden_top); 22.120 transform_later(store_eden_top); 22.121 fast_oop_ctrl = needgc_false; // No contention, so this is the fast path 22.122 + fast_oop_rawmem = store_eden_top; 22.123 } else { 22.124 - store_eden_top = new (C, 5) StorePConditionalNode( needgc_false, contended_phi_rawmem, eden_top_adr, new_eden_top, old_eden_top ); 22.125 + Node* store_eden_top = 22.126 + new (C, 5) StorePConditionalNode(needgc_false, contended_phi_rawmem, eden_top_adr, 22.127 + new_eden_top, fast_oop/*old_eden_top*/); 22.128 transform_later(store_eden_top); 22.129 - Node *contention_check = new (C, 2) BoolNode( store_eden_top, BoolTest::ne ); 22.130 + Node *contention_check = new (C, 2) BoolNode(store_eden_top, BoolTest::ne); 22.131 transform_later(contention_check); 22.132 store_eden_top = new (C, 1) SCMemProjNode(store_eden_top); 22.133 transform_later(store_eden_top); 22.134 22.135 // If not using TLABs, check to see if there was contention. 22.136 - IfNode *contention_iff = new (C, 2) IfNode ( needgc_false, contention_check, PROB_MIN, COUNT_UNKNOWN ); 22.137 + IfNode *contention_iff = new (C, 2) IfNode (needgc_false, contention_check, PROB_MIN, COUNT_UNKNOWN); 22.138 transform_later(contention_iff); 22.139 - Node *contention_true = new (C, 1) IfTrueNode( contention_iff ); 22.140 + Node *contention_true = new (C, 1) IfTrueNode(contention_iff); 22.141 transform_later(contention_true); 22.142 // If contention, loopback and try again. 22.143 - contended_region->init_req( contended_loopback_path, contention_true ); 22.144 - contended_phi_rawmem->init_req( contended_loopback_path, store_eden_top ); 22.145 + contended_region->init_req(contended_loopback_path, contention_true); 22.146 + contended_phi_rawmem->init_req(contended_loopback_path, store_eden_top); 22.147 22.148 // Fast-path succeeded with no contention! 22.149 - Node *contention_false = new (C, 1) IfFalseNode( contention_iff ); 22.150 + Node *contention_false = new (C, 1) IfFalseNode(contention_iff); 22.151 transform_later(contention_false); 22.152 fast_oop_ctrl = contention_false; 22.153 + 22.154 + // Bump total allocated bytes for this thread 22.155 + Node* thread = new (C, 1) ThreadLocalNode(); 22.156 + transform_later(thread); 22.157 + Node* alloc_bytes_adr = basic_plus_adr(top()/*not oop*/, thread, 22.158 + in_bytes(JavaThread::allocated_bytes_offset())); 22.159 + Node* alloc_bytes = make_load(fast_oop_ctrl, store_eden_top, alloc_bytes_adr, 22.160 + 0, TypeLong::LONG, T_LONG); 22.161 +#ifdef _LP64 22.162 + Node* alloc_size = size_in_bytes; 22.163 +#else 22.164 + Node* alloc_size = new (C, 2) ConvI2LNode(size_in_bytes); 22.165 + transform_later(alloc_size); 22.166 +#endif 22.167 + Node* new_alloc_bytes = new (C, 3) AddLNode(alloc_bytes, alloc_size); 22.168 + transform_later(new_alloc_bytes); 22.169 + fast_oop_rawmem = make_store(fast_oop_ctrl, store_eden_top, alloc_bytes_adr, 22.170 + 0, new_alloc_bytes, T_LONG); 22.171 } 22.172 22.173 - // Rename successful fast-path variables to make meaning more obvious 22.174 - Node* fast_oop = old_eden_top; 22.175 - Node* fast_oop_rawmem = store_eden_top; 22.176 fast_oop_rawmem = initialize_object(alloc, 22.177 fast_oop_ctrl, fast_oop_rawmem, fast_oop, 22.178 klass_node, length, size_in_bytes); 22.179 @@ -1282,11 +1305,11 @@ 22.180 22.181 call->init_req(TypeFunc::Parms+0, thread); 22.182 call->init_req(TypeFunc::Parms+1, fast_oop); 22.183 - call->init_req( TypeFunc::Control, fast_oop_ctrl ); 22.184 - call->init_req( TypeFunc::I_O , top() ) ; // does no i/o 22.185 - call->init_req( TypeFunc::Memory , fast_oop_rawmem ); 22.186 - call->init_req( TypeFunc::ReturnAdr, alloc->in(TypeFunc::ReturnAdr) ); 22.187 - call->init_req( TypeFunc::FramePtr, alloc->in(TypeFunc::FramePtr) ); 22.188 + call->init_req(TypeFunc::Control, fast_oop_ctrl); 22.189 + call->init_req(TypeFunc::I_O , top()); // does no i/o 22.190 + call->init_req(TypeFunc::Memory , fast_oop_rawmem); 22.191 + call->init_req(TypeFunc::ReturnAdr, alloc->in(TypeFunc::ReturnAdr)); 22.192 + call->init_req(TypeFunc::FramePtr, alloc->in(TypeFunc::FramePtr)); 22.193 transform_later(call); 22.194 fast_oop_ctrl = new (C, 1) ProjNode(call,TypeFunc::Control); 22.195 transform_later(fast_oop_ctrl); 22.196 @@ -1295,10 +1318,10 @@ 22.197 } 22.198 22.199 // Plug in the successful fast-path into the result merge point 22.200 - result_region ->init_req( fast_result_path, fast_oop_ctrl ); 22.201 - result_phi_rawoop->init_req( fast_result_path, fast_oop ); 22.202 - result_phi_i_o ->init_req( fast_result_path, i_o ); 22.203 - result_phi_rawmem->init_req( fast_result_path, fast_oop_rawmem ); 22.204 + result_region ->init_req(fast_result_path, fast_oop_ctrl); 22.205 + result_phi_rawoop->init_req(fast_result_path, fast_oop); 22.206 + result_phi_i_o ->init_req(fast_result_path, i_o); 22.207 + result_phi_rawmem->init_req(fast_result_path, fast_oop_rawmem); 22.208 } else { 22.209 slow_region = ctrl; 22.210 }
23.1 --- a/src/share/vm/prims/jvmti.xml Fri Jan 07 03:41:07 2011 -0800 23.2 +++ b/src/share/vm/prims/jvmti.xml Fri Jan 07 15:54:32 2011 -0800 23.3 @@ -1,7 +1,7 @@ 23.4 <?xml version="1.0" encoding="ISO-8859-1"?> 23.5 <?xml-stylesheet type="text/xsl" href="jvmti.xsl"?> 23.6 <!-- 23.7 - Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 23.8 + Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 23.9 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 23.10 23.11 This code is free software; you can redistribute it and/or modify it 23.12 @@ -10697,7 +10697,7 @@ 23.13 <internallink id="mUTF">modified UTF-8</internallink> string. 23.14 </description> 23.15 </param> 23.16 - <param id="value"> 23.17 + <param id="value_ptr"> 23.18 <inbuf> 23.19 <char/> 23.20 <nullok>
24.1 --- a/src/share/vm/prims/jvmtiEnv.cpp Fri Jan 07 03:41:07 2011 -0800 24.2 +++ b/src/share/vm/prims/jvmtiEnv.cpp Fri Jan 07 15:54:32 2011 -0800 24.3 @@ -1,5 +1,5 @@ 24.4 /* 24.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 24.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 24.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 24.8 * 24.9 * This code is free software; you can redistribute it and/or modify it 24.10 @@ -1802,7 +1802,7 @@ 24.11 // depth - pre-checked as non-negative 24.12 // value - pre-checked for NULL 24.13 jvmtiError 24.14 -JvmtiEnv::GetLocalInstance(JavaThread* java_thread, jint depth, jobject* value){ 24.15 +JvmtiEnv::GetLocalInstance(JavaThread* java_thread, jint depth, jobject* value_ptr){ 24.16 JavaThread* current_thread = JavaThread::current(); 24.17 // rm object is created to clean up the javaVFrame created in 24.18 // doit_prologue(), but after doit() is finished with it. 24.19 @@ -1814,7 +1814,7 @@ 24.20 if (err != JVMTI_ERROR_NONE) { 24.21 return err; 24.22 } else { 24.23 - *value = op.value().l; 24.24 + *value_ptr = op.value().l; 24.25 return JVMTI_ERROR_NONE; 24.26 } 24.27 } /* end GetLocalInstance */ 24.28 @@ -3440,12 +3440,12 @@ 24.29 // property - pre-checked for NULL 24.30 // value - NULL is a valid value, must be checked 24.31 jvmtiError 24.32 -JvmtiEnv::SetSystemProperty(const char* property, const char* value) { 24.33 +JvmtiEnv::SetSystemProperty(const char* property, const char* value_ptr) { 24.34 jvmtiError err =JVMTI_ERROR_NOT_AVAILABLE; 24.35 24.36 for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) { 24.37 if (strcmp(property, p->key()) == 0) { 24.38 - if (p->set_value((char *)value)) { 24.39 + if (p->set_value((char *)value_ptr)) { 24.40 err = JVMTI_ERROR_NONE; 24.41 } 24.42 }
25.1 --- a/src/share/vm/runtime/arguments.cpp Fri Jan 07 03:41:07 2011 -0800 25.2 +++ b/src/share/vm/runtime/arguments.cpp Fri Jan 07 15:54:32 2011 -0800 25.3 @@ -2297,14 +2297,15 @@ 25.4 } else if (match_option(option, "-Xoss", &tail)) { 25.5 // HotSpot does not have separate native and Java stacks, ignore silently for compatibility 25.6 // -Xmaxjitcodesize 25.7 - } else if (match_option(option, "-Xmaxjitcodesize", &tail)) { 25.8 + } else if (match_option(option, "-Xmaxjitcodesize", &tail) || 25.9 + match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) { 25.10 julong long_ReservedCodeCacheSize = 0; 25.11 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 25.12 (size_t)InitialCodeCacheSize); 25.13 if (errcode != arg_in_range) { 25.14 jio_fprintf(defaultStream::error_stream(), 25.15 - "Invalid maximum code cache size: %s\n", 25.16 - option->optionString); 25.17 + "Invalid maximum code cache size: %s. Should be greater than InitialCodeCacheSize=%dK\n", 25.18 + option->optionString, InitialCodeCacheSize/K); 25.19 describe_range_error(errcode); 25.20 return JNI_EINVAL; 25.21 }
26.1 --- a/src/share/vm/runtime/java.cpp Fri Jan 07 03:41:07 2011 -0800 26.2 +++ b/src/share/vm/runtime/java.cpp Fri Jan 07 15:54:32 2011 -0800 26.3 @@ -515,8 +515,8 @@ 26.4 } 26.5 26.6 void vm_exit(int code) { 26.7 - Thread* thread = ThreadLocalStorage::thread_index() == -1 ? NULL 26.8 - : ThreadLocalStorage::get_thread_slow(); 26.9 + Thread* thread = ThreadLocalStorage::is_initialized() ? 26.10 + ThreadLocalStorage::get_thread_slow() : NULL; 26.11 if (thread == NULL) { 26.12 // we have serious problems -- just exit 26.13 vm_direct_exit(code); 26.14 @@ -553,8 +553,9 @@ 26.15 // Calling 'exit_globals()' will disable thread-local-storage and cause all 26.16 // kinds of assertions to trigger in debug mode. 26.17 if (is_init_completed()) { 26.18 - Thread* thread = Thread::current(); 26.19 - if (thread->is_Java_thread()) { 26.20 + Thread* thread = ThreadLocalStorage::is_initialized() ? 26.21 + ThreadLocalStorage::get_thread_slow() : NULL; 26.22 + if (thread != NULL && thread->is_Java_thread()) { 26.23 // We are leaving the VM, set state to native (in case any OS exit 26.24 // handlers call back to the VM) 26.25 JavaThread* jt = (JavaThread*)thread;
27.1 --- a/src/share/vm/runtime/thread.cpp Fri Jan 07 03:41:07 2011 -0800 27.2 +++ b/src/share/vm/runtime/thread.cpp Fri Jan 07 15:54:32 2011 -0800 27.3 @@ -1,5 +1,5 @@ 27.4 /* 27.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 27.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 27.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 27.8 * 27.9 * This code is free software; you can redistribute it and/or modify it 27.10 @@ -177,20 +177,19 @@ 27.11 27.12 27.13 Thread::Thread() { 27.14 - // stack 27.15 - _stack_base = NULL; 27.16 - _stack_size = 0; 27.17 - _self_raw_id = 0; 27.18 - _lgrp_id = -1; 27.19 - _osthread = NULL; 27.20 + // stack and get_thread 27.21 + set_stack_base(NULL); 27.22 + set_stack_size(0); 27.23 + set_self_raw_id(0); 27.24 + set_lgrp_id(-1); 27.25 27.26 // allocated data structures 27.27 + set_osthread(NULL); 27.28 set_resource_area(new ResourceArea()); 27.29 set_handle_area(new HandleArea(NULL)); 27.30 set_active_handles(NULL); 27.31 set_free_handle_block(NULL); 27.32 set_last_handle_mark(NULL); 27.33 - set_osthread(NULL); 27.34 27.35 // This initial value ==> never claimed. 27.36 _oops_do_parity = 0; 27.37 @@ -205,6 +204,7 @@ 27.38 NOT_PRODUCT(_skip_gcalot = false;) 27.39 CHECK_UNHANDLED_OOPS_ONLY(_gc_locked_out_count = 0;) 27.40 _jvmti_env_iteration_count = 0; 27.41 + set_allocated_bytes(0); 27.42 _vm_operation_started_count = 0; 27.43 _vm_operation_completed_count = 0; 27.44 _current_pending_monitor = NULL; 27.45 @@ -3231,7 +3231,7 @@ 27.46 warning("java.lang.ArithmeticException has not been initialized"); 27.47 warning("java.lang.StackOverflowError has not been initialized"); 27.48 } 27.49 - } 27.50 + } 27.51 27.52 // See : bugid 4211085. 27.53 // Background : the static initializer of java.lang.Compiler tries to read
28.1 --- a/src/share/vm/runtime/thread.hpp Fri Jan 07 03:41:07 2011 -0800 28.2 +++ b/src/share/vm/runtime/thread.hpp Fri Jan 07 15:54:32 2011 -0800 28.3 @@ -1,5 +1,5 @@ 28.4 /* 28.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 28.6 + * Copyright (c) 1997, 2011, 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 @@ -60,7 +60,7 @@ 28.11 class JvmtiGetLoadedClassesClosure; 28.12 class ThreadStatistics; 28.13 class ConcurrentLocksDump; 28.14 -class ParkEvent ; 28.15 +class ParkEvent; 28.16 class Parker; 28.17 28.18 class ciEnv; 28.19 @@ -170,7 +170,7 @@ 28.20 // 28.21 28.22 // suspend/resume lock: used for self-suspend 28.23 - Monitor* _SR_lock; 28.24 + Monitor* _SR_lock; 28.25 28.26 protected: 28.27 enum SuspendFlags { 28.28 @@ -194,7 +194,7 @@ 28.29 public: 28.30 void enter_signal_handler() { _num_nested_signal++; } 28.31 void leave_signal_handler() { _num_nested_signal--; } 28.32 - bool is_inside_signal_handler() const { return _num_nested_signal > 0; } 28.33 + bool is_inside_signal_handler() const { return _num_nested_signal > 0; } 28.34 28.35 private: 28.36 // Debug tracing 28.37 @@ -215,7 +215,7 @@ 28.38 28.39 public: 28.40 void set_last_handle_mark(HandleMark* mark) { _last_handle_mark = mark; } 28.41 - HandleMark* last_handle_mark() const { return _last_handle_mark; } 28.42 + HandleMark* last_handle_mark() const { return _last_handle_mark; } 28.43 private: 28.44 28.45 // debug support for checking if code does allow safepoints or not 28.46 @@ -227,11 +227,11 @@ 28.47 // 28.48 // The two classes No_Safepoint_Verifier and No_Allocation_Verifier are used to set these counters. 28.49 // 28.50 - NOT_PRODUCT(int _allow_safepoint_count;) // If 0, thread allow a safepoint to happen 28.51 - debug_only (int _allow_allocation_count;) // If 0, the thread is allowed to allocate oops. 28.52 + NOT_PRODUCT(int _allow_safepoint_count;) // If 0, thread allow a safepoint to happen 28.53 + debug_only (int _allow_allocation_count;) // If 0, the thread is allowed to allocate oops. 28.54 28.55 // Used by SkipGCALot class. 28.56 - NOT_PRODUCT(bool _skip_gcalot;) // Should we elide gc-a-lot? 28.57 + NOT_PRODUCT(bool _skip_gcalot;) // Should we elide gc-a-lot? 28.58 28.59 // Record when GC is locked out via the GC_locker mechanism 28.60 CHECK_UNHANDLED_OOPS_ONLY(int _gc_locked_out_count;) 28.61 @@ -242,24 +242,26 @@ 28.62 friend class ThreadLocalStorage; 28.63 friend class GC_locker; 28.64 28.65 - ThreadLocalAllocBuffer _tlab; // Thread-local eden 28.66 + ThreadLocalAllocBuffer _tlab; // Thread-local eden 28.67 + jlong _allocated_bytes; // Cumulative number of bytes allocated on 28.68 + // the Java heap 28.69 28.70 - int _vm_operation_started_count; // VM_Operation support 28.71 - int _vm_operation_completed_count; // VM_Operation support 28.72 + int _vm_operation_started_count; // VM_Operation support 28.73 + int _vm_operation_completed_count; // VM_Operation support 28.74 28.75 - ObjectMonitor* _current_pending_monitor; // ObjectMonitor this thread 28.76 - // is waiting to lock 28.77 - bool _current_pending_monitor_is_from_java; // locking is from Java code 28.78 + ObjectMonitor* _current_pending_monitor; // ObjectMonitor this thread 28.79 + // is waiting to lock 28.80 + bool _current_pending_monitor_is_from_java; // locking is from Java code 28.81 28.82 // ObjectMonitor on which this thread called Object.wait() 28.83 ObjectMonitor* _current_waiting_monitor; 28.84 28.85 // Private thread-local objectmonitor list - a simple cache organized as a SLL. 28.86 public: 28.87 - ObjectMonitor * omFreeList ; 28.88 - int omFreeCount ; // length of omFreeList 28.89 - int omFreeProvision ; // reload chunk size 28.90 - ObjectMonitor * omInUseList; // SLL to track monitors in circulation 28.91 + ObjectMonitor* omFreeList; 28.92 + int omFreeCount; // length of omFreeList 28.93 + int omFreeProvision; // reload chunk size 28.94 + ObjectMonitor* omInUseList; // SLL to track monitors in circulation 28.95 int omInUseCount; // length of omInUseList 28.96 28.97 public: 28.98 @@ -280,7 +282,6 @@ 28.99 // Testers 28.100 virtual bool is_VM_thread() const { return false; } 28.101 virtual bool is_Java_thread() const { return false; } 28.102 - // Remove this ifdef when C1 is ported to the compiler interface. 28.103 virtual bool is_Compiler_thread() const { return false; } 28.104 virtual bool is_hidden_from_external_view() const { return false; } 28.105 virtual bool is_jvmti_agent_thread() const { return false; } 28.106 @@ -344,15 +345,15 @@ 28.107 // Support for Unhandled Oop detection 28.108 #ifdef CHECK_UNHANDLED_OOPS 28.109 private: 28.110 - UnhandledOops *_unhandled_oops; 28.111 + UnhandledOops* _unhandled_oops; 28.112 public: 28.113 - UnhandledOops* unhandled_oops() { return _unhandled_oops; } 28.114 + UnhandledOops* unhandled_oops() { return _unhandled_oops; } 28.115 // Mark oop safe for gc. It may be stack allocated but won't move. 28.116 - void allow_unhandled_oop(oop *op) { 28.117 + void allow_unhandled_oop(oop *op) { 28.118 if (CheckUnhandledOops) unhandled_oops()->allow_unhandled_oop(op); 28.119 } 28.120 // Clear oops at safepoint so crashes point to unhandled oop violator 28.121 - void clear_unhandled_oops() { 28.122 + void clear_unhandled_oops() { 28.123 if (CheckUnhandledOops) unhandled_oops()->clear_unhandled_oops(); 28.124 } 28.125 bool is_gc_locked_out() { return _gc_locked_out_count > 0; } 28.126 @@ -392,6 +393,22 @@ 28.127 } 28.128 } 28.129 28.130 + jlong allocated_bytes() { return _allocated_bytes; } 28.131 + void set_allocated_bytes(jlong value) { _allocated_bytes = value; } 28.132 + void incr_allocated_bytes(jlong size) { _allocated_bytes += size; } 28.133 + jlong cooked_allocated_bytes() { 28.134 + jlong allocated_bytes = OrderAccess::load_acquire(&_allocated_bytes); 28.135 + if (UseTLAB) { 28.136 + size_t used_bytes = tlab().used_bytes(); 28.137 + if ((ssize_t)used_bytes > 0) { 28.138 + // More-or-less valid tlab. The load_acquire above should ensure 28.139 + // that the result of the add is <= the instantaneous value 28.140 + return allocated_bytes + used_bytes; 28.141 + } 28.142 + } 28.143 + return allocated_bytes; 28.144 + } 28.145 + 28.146 // VM operation support 28.147 int vm_operation_ticket() { return ++_vm_operation_started_count; } 28.148 int vm_operation_completed_count() { return _vm_operation_completed_count; } 28.149 @@ -489,8 +506,11 @@ 28.150 return (_stack_base >= adr && adr >= (_stack_base - _stack_size)); 28.151 } 28.152 28.153 - int lgrp_id() const { return _lgrp_id; } 28.154 - void set_lgrp_id(int value) { _lgrp_id = value; } 28.155 + uintptr_t self_raw_id() { return _self_raw_id; } 28.156 + void set_self_raw_id(uintptr_t value) { _self_raw_id = value; } 28.157 + 28.158 + int lgrp_id() const { return _lgrp_id; } 28.159 + void set_lgrp_id(int value) { _lgrp_id = value; } 28.160 28.161 // Printing 28.162 void print_on(outputStream* st) const; 28.163 @@ -502,7 +522,7 @@ 28.164 #ifdef ASSERT 28.165 private: 28.166 // Deadlock detection support for Mutex locks. List of locks own by thread. 28.167 - Monitor *_owned_locks; 28.168 + Monitor* _owned_locks; 28.169 // Mutex::set_owner_implementation is the only place where _owned_locks is modified, 28.170 // thus the friendship 28.171 friend class Mutex; 28.172 @@ -511,7 +531,7 @@ 28.173 public: 28.174 void print_owned_locks_on(outputStream* st) const; 28.175 void print_owned_locks() const { print_owned_locks_on(tty); } 28.176 - Monitor * owned_locks() const { return _owned_locks; } 28.177 + Monitor* owned_locks() const { return _owned_locks; } 28.178 bool owns_locks() const { return owned_locks() != NULL; } 28.179 bool owns_locks_but_compiled_lock() const; 28.180 28.181 @@ -538,7 +558,7 @@ 28.182 static ByteSize stack_size_offset() { return byte_offset_of(Thread, _stack_size ); } 28.183 28.184 #define TLAB_FIELD_OFFSET(name) \ 28.185 - static ByteSize tlab_##name##_offset() { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::name##_offset(); } 28.186 + static ByteSize tlab_##name##_offset() { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::name##_offset(); } 28.187 28.188 TLAB_FIELD_OFFSET(start) 28.189 TLAB_FIELD_OFFSET(end) 28.190 @@ -552,6 +572,8 @@ 28.191 28.192 #undef TLAB_FIELD_OFFSET 28.193 28.194 + static ByteSize allocated_bytes_offset() { return byte_offset_of(Thread, _allocated_bytes ); } 28.195 + 28.196 public: 28.197 volatile intptr_t _Stalled ; 28.198 volatile int _TypeTag ;
29.1 --- a/src/share/vm/services/jmm.h Fri Jan 07 03:41:07 2011 -0800 29.2 +++ b/src/share/vm/services/jmm.h Fri Jan 07 15:54:32 2011 -0800 29.3 @@ -1,5 +1,5 @@ 29.4 /* 29.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 29.6 + * Copyright (c) 2003, 2011, 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 @@ -60,7 +60,8 @@ 29.11 unsigned int isBootClassPathSupported : 1; 29.12 unsigned int isObjectMonitorUsageSupported : 1; 29.13 unsigned int isSynchronizerUsageSupported : 1; 29.14 - unsigned int : 24; 29.15 + unsigned int isThreadAllocatedMemorySupported : 1; 29.16 + unsigned int : 23; 29.17 } jmmOptionalSupport; 29.18 29.19 typedef enum { 29.20 @@ -105,7 +106,8 @@ 29.21 JMM_VERBOSE_GC = 21, 29.22 JMM_VERBOSE_CLASS = 22, 29.23 JMM_THREAD_CONTENTION_MONITORING = 23, 29.24 - JMM_THREAD_CPU_TIME = 24 29.25 + JMM_THREAD_CPU_TIME = 24, 29.26 + JMM_THREAD_ALLOCATED_MEMORY = 25 29.27 } jmmBoolAttribute; 29.28 29.29 29.30 @@ -213,7 +215,10 @@ 29.31 jobject (JNICALL *GetMemoryPoolUsage) (JNIEnv* env, jobject pool); 29.32 jobject (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool); 29.33 29.34 - void* reserved4; 29.35 + void (JNICALL *GetThreadAllocatedMemory) 29.36 + (JNIEnv *env, 29.37 + jlongArray ids, 29.38 + jlongArray sizeArray); 29.39 29.40 jobject (JNICALL *GetMemoryUsage) (JNIEnv* env, jboolean heap); 29.41 29.42 @@ -228,6 +233,8 @@ 29.43 jlong* result); 29.44 29.45 jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env); 29.46 + 29.47 + // Not used in JDK 6 or JDK 7 29.48 jlong (JNICALL *GetThreadCpuTime) (JNIEnv *env, jlong thread_id); 29.49 29.50 jobjectArray (JNICALL *GetVMGlobalNames) (JNIEnv *env); 29.51 @@ -262,14 +269,22 @@ 29.52 void (JNICALL *GetLastGCStat) (JNIEnv *env, 29.53 jobject mgr, 29.54 jmmGCStat *gc_stat); 29.55 - jlong (JNICALL *GetThreadCpuTimeWithKind) (JNIEnv *env, 29.56 - jlong thread_id, 29.57 - jboolean user_sys_cpu_time); 29.58 - void* reserved5; 29.59 + 29.60 + jlong (JNICALL *GetThreadCpuTimeWithKind) 29.61 + (JNIEnv *env, 29.62 + jlong thread_id, 29.63 + jboolean user_sys_cpu_time); 29.64 + void (JNICALL *GetThreadCpuTimesWithKind) 29.65 + (JNIEnv *env, 29.66 + jlongArray ids, 29.67 + jlongArray timeArray, 29.68 + jboolean user_sys_cpu_time); 29.69 + 29.70 jint (JNICALL *DumpHeap0) (JNIEnv *env, 29.71 jstring outputfile, 29.72 jboolean live); 29.73 - jobjectArray (JNICALL *FindDeadlocks) (JNIEnv *env, jboolean object_monitors_only); 29.74 + jobjectArray (JNICALL *FindDeadlocks) (JNIEnv *env, 29.75 + jboolean object_monitors_only); 29.76 void (JNICALL *SetVMGlobal) (JNIEnv *env, 29.77 jstring flag_name, 29.78 jvalue new_value);
30.1 --- a/src/share/vm/services/management.cpp Fri Jan 07 03:41:07 2011 -0800 30.2 +++ b/src/share/vm/services/management.cpp Fri Jan 07 15:54:32 2011 -0800 30.3 @@ -1,5 +1,5 @@ 30.4 /* 30.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 30.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 30.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 30.8 * 30.9 * This code is free software; you can redistribute it and/or modify it 30.10 @@ -101,12 +101,14 @@ 30.11 _optional_support.isCurrentThreadCpuTimeSupported = 0; 30.12 _optional_support.isOtherThreadCpuTimeSupported = 0; 30.13 } 30.14 + 30.15 _optional_support.isBootClassPathSupported = 1; 30.16 _optional_support.isObjectMonitorUsageSupported = 1; 30.17 #ifndef SERVICES_KERNEL 30.18 // This depends on the heap inspector 30.19 _optional_support.isSynchronizerUsageSupported = 1; 30.20 #endif // SERVICES_KERNEL 30.21 + _optional_support.isThreadAllocatedMemorySupported = 1; 30.22 } 30.23 30.24 void Management::initialize(TRAPS) { 30.25 @@ -386,11 +388,6 @@ 30.26 30.27 static void validate_thread_id_array(typeArrayHandle ids_ah, TRAPS) { 30.28 int num_threads = ids_ah->length(); 30.29 - // should be non-empty array 30.30 - if (num_threads == 0) { 30.31 - THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), 30.32 - "Empty array of thread IDs"); 30.33 - } 30.34 30.35 // Validate input thread IDs 30.36 int i = 0; 30.37 @@ -402,11 +399,9 @@ 30.38 "Invalid thread ID entry"); 30.39 } 30.40 } 30.41 - 30.42 } 30.43 30.44 static void validate_thread_info_array(objArrayHandle infoArray_h, TRAPS) { 30.45 - 30.46 // check if the element of infoArray is of type ThreadInfo class 30.47 klassOop threadinfo_klass = Management::java_lang_management_ThreadInfo_klass(CHECK); 30.48 klassOop element_klass = objArrayKlass::cast(infoArray_h->klass())->element_klass(); 30.49 @@ -414,7 +409,6 @@ 30.50 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), 30.51 "infoArray element type is not ThreadInfo class"); 30.52 } 30.53 - 30.54 } 30.55 30.56 30.57 @@ -770,6 +764,45 @@ 30.58 return prev; 30.59 JVM_END 30.60 30.61 +// Gets an array containing the amount of memory allocated on the Java 30.62 +// heap for a set of threads (in bytes). Each element of the array is 30.63 +// the amount of memory allocated for the thread ID specified in the 30.64 +// corresponding entry in the given array of thread IDs; or -1 if the 30.65 +// thread does not exist or has terminated. 30.66 +JVM_ENTRY(void, jmm_GetThreadAllocatedMemory(JNIEnv *env, jlongArray ids, 30.67 + jlongArray sizeArray)) 30.68 + // Check if threads is null 30.69 + if (ids == NULL || sizeArray == NULL) { 30.70 + THROW(vmSymbols::java_lang_NullPointerException()); 30.71 + } 30.72 + 30.73 + ResourceMark rm(THREAD); 30.74 + typeArrayOop ta = typeArrayOop(JNIHandles::resolve_non_null(ids)); 30.75 + typeArrayHandle ids_ah(THREAD, ta); 30.76 + 30.77 + typeArrayOop sa = typeArrayOop(JNIHandles::resolve_non_null(sizeArray)); 30.78 + typeArrayHandle sizeArray_h(THREAD, sa); 30.79 + 30.80 + // validate the thread id array 30.81 + validate_thread_id_array(ids_ah, CHECK); 30.82 + 30.83 + // sizeArray must be of the same length as the given array of thread IDs 30.84 + int num_threads = ids_ah->length(); 30.85 + if (num_threads != sizeArray_h->length()) { 30.86 + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), 30.87 + "The length of the given long array does not match the length of " 30.88 + "the given array of thread IDs"); 30.89 + } 30.90 + 30.91 + MutexLockerEx ml(Threads_lock); 30.92 + for (int i = 0; i < num_threads; i++) { 30.93 + JavaThread* java_thread = find_java_thread_from_id(ids_ah->long_at(i)); 30.94 + if (java_thread != NULL) { 30.95 + sizeArray_h->long_at_put(i, java_thread->cooked_allocated_bytes()); 30.96 + } 30.97 + } 30.98 +JVM_END 30.99 + 30.100 // Returns a java/lang/management/MemoryUsage object representing 30.101 // the memory usage for the heap or non-heap memory. 30.102 JVM_ENTRY(jobject, jmm_GetMemoryUsage(JNIEnv* env, jboolean heap)) 30.103 @@ -834,6 +867,8 @@ 30.104 return ThreadService::is_thread_monitoring_contention(); 30.105 case JMM_THREAD_CPU_TIME: 30.106 return ThreadService::is_thread_cpu_time_enabled(); 30.107 + case JMM_THREAD_ALLOCATED_MEMORY: 30.108 + return ThreadService::is_thread_allocated_memory_enabled(); 30.109 default: 30.110 assert(0, "Unrecognized attribute"); 30.111 return false; 30.112 @@ -851,6 +886,8 @@ 30.113 return ThreadService::set_thread_monitoring_contention(flag != 0); 30.114 case JMM_THREAD_CPU_TIME: 30.115 return ThreadService::set_thread_cpu_time_enabled(flag != 0); 30.116 + case JMM_THREAD_ALLOCATED_MEMORY: 30.117 + return ThreadService::set_thread_allocated_memory_enabled(flag != 0); 30.118 default: 30.119 assert(0, "Unrecognized attribute"); 30.120 return false; 30.121 @@ -1096,6 +1133,7 @@ 30.122 // maxDepth == 0 requests no stack trace. 30.123 // infoArray - array of ThreadInfo objects 30.124 // 30.125 +// QQQ - Why does this method return a value instead of void? 30.126 JVM_ENTRY(jint, jmm_GetThreadInfo(JNIEnv *env, jlongArray ids, jint maxDepth, jobjectArray infoArray)) 30.127 // Check if threads is null 30.128 if (ids == NULL || infoArray == NULL) { 30.129 @@ -1159,7 +1197,6 @@ 30.130 } 30.131 } else { 30.132 // obtain thread dump with the specific list of threads with stack trace 30.133 - 30.134 do_thread_dump(&dump_result, 30.135 ids_ah, 30.136 num_threads, 30.137 @@ -1252,8 +1289,6 @@ 30.138 continue; 30.139 } 30.140 30.141 - 30.142 - 30.143 ThreadStackTrace* stacktrace = ts->get_stack_trace(); 30.144 assert(stacktrace != NULL, "Must have a stack trace dumped"); 30.145 30.146 @@ -1500,6 +1535,49 @@ 30.147 return -1; 30.148 JVM_END 30.149 30.150 +// Gets an array containing the CPU times consumed by a set of threads 30.151 +// (in nanoseconds). Each element of the array is the CPU time for the 30.152 +// thread ID specified in the corresponding entry in the given array 30.153 +// of thread IDs; or -1 if the thread does not exist or has terminated. 30.154 +// If user_sys_cpu_time = true, the sum of user level and system CPU time 30.155 +// for the given thread is returned; otherwise, only user level CPU time 30.156 +// is returned. 30.157 +JVM_ENTRY(void, jmm_GetThreadCpuTimesWithKind(JNIEnv *env, jlongArray ids, 30.158 + jlongArray timeArray, 30.159 + jboolean user_sys_cpu_time)) 30.160 + // Check if threads is null 30.161 + if (ids == NULL || timeArray == NULL) { 30.162 + THROW(vmSymbols::java_lang_NullPointerException()); 30.163 + } 30.164 + 30.165 + ResourceMark rm(THREAD); 30.166 + typeArrayOop ta = typeArrayOop(JNIHandles::resolve_non_null(ids)); 30.167 + typeArrayHandle ids_ah(THREAD, ta); 30.168 + 30.169 + typeArrayOop tia = typeArrayOop(JNIHandles::resolve_non_null(timeArray)); 30.170 + typeArrayHandle timeArray_h(THREAD, tia); 30.171 + 30.172 + // validate the thread id array 30.173 + validate_thread_id_array(ids_ah, CHECK); 30.174 + 30.175 + // timeArray must be of the same length as the given array of thread IDs 30.176 + int num_threads = ids_ah->length(); 30.177 + if (num_threads != timeArray_h->length()) { 30.178 + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), 30.179 + "The length of the given long array does not match the length of " 30.180 + "the given array of thread IDs"); 30.181 + } 30.182 + 30.183 + MutexLockerEx ml(Threads_lock); 30.184 + for (int i = 0; i < num_threads; i++) { 30.185 + JavaThread* java_thread = find_java_thread_from_id(ids_ah->long_at(i)); 30.186 + if (java_thread != NULL) { 30.187 + timeArray_h->long_at_put(i, os::thread_cpu_time((Thread*)java_thread, 30.188 + user_sys_cpu_time != 0)); 30.189 + } 30.190 + } 30.191 +JVM_END 30.192 + 30.193 // Returns a String array of all VM global flag names 30.194 JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env)) 30.195 // last flag entry is always NULL, so subtract 1 30.196 @@ -2020,7 +2098,7 @@ 30.197 jmm_GetMemoryManagers, 30.198 jmm_GetMemoryPoolUsage, 30.199 jmm_GetPeakMemoryPoolUsage, 30.200 - NULL, 30.201 + jmm_GetThreadAllocatedMemory, 30.202 jmm_GetMemoryUsage, 30.203 jmm_GetLongAttribute, 30.204 jmm_GetBoolAttribute, 30.205 @@ -2038,7 +2116,7 @@ 30.206 jmm_GetGCExtAttributeInfo, 30.207 jmm_GetLastGCStat, 30.208 jmm_GetThreadCpuTimeWithKind, 30.209 - NULL, 30.210 + jmm_GetThreadCpuTimesWithKind, 30.211 jmm_DumpHeap0, 30.212 jmm_FindDeadlockedThreads, 30.213 jmm_SetVMGlobal,
31.1 --- a/src/share/vm/services/threadService.cpp Fri Jan 07 03:41:07 2011 -0800 31.2 +++ b/src/share/vm/services/threadService.cpp Fri Jan 07 15:54:32 2011 -0800 31.3 @@ -1,5 +1,5 @@ 31.4 /* 31.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 31.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 31.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.8 * 31.9 * This code is free software; you can redistribute it and/or modify it 31.10 @@ -46,6 +46,7 @@ 31.11 // Default is disabled. 31.12 bool ThreadService::_thread_monitoring_contention_enabled = false; 31.13 bool ThreadService::_thread_cpu_time_enabled = false; 31.14 +bool ThreadService::_thread_allocated_memory_enabled = false; 31.15 31.16 PerfCounter* ThreadService::_total_threads_count = NULL; 31.17 PerfVariable* ThreadService::_live_threads_count = NULL; 31.18 @@ -84,6 +85,8 @@ 31.19 if (os::is_thread_cpu_time_supported()) { 31.20 _thread_cpu_time_enabled = true; 31.21 } 31.22 + 31.23 + _thread_allocated_memory_enabled = true; // Always on, so enable it 31.24 } 31.25 31.26 void ThreadService::reset_peak_thread_count() { 31.27 @@ -181,6 +184,15 @@ 31.28 return prev; 31.29 } 31.30 31.31 +bool ThreadService::set_thread_allocated_memory_enabled(bool flag) { 31.32 + MutexLocker m(Management_lock); 31.33 + 31.34 + bool prev = _thread_allocated_memory_enabled; 31.35 + _thread_allocated_memory_enabled = flag; 31.36 + 31.37 + return prev; 31.38 +} 31.39 + 31.40 // GC support 31.41 void ThreadService::oops_do(OopClosure* f) { 31.42 for (ThreadDumpResult* dump = _threaddump_list; dump != NULL; dump = dump->next()) {
32.1 --- a/src/share/vm/services/threadService.hpp Fri Jan 07 03:41:07 2011 -0800 32.2 +++ b/src/share/vm/services/threadService.hpp Fri Jan 07 15:54:32 2011 -0800 32.3 @@ -1,5 +1,5 @@ 32.4 /* 32.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 32.6 + * Copyright (c) 2003, 2011, 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 @@ -65,6 +65,7 @@ 32.11 32.12 static bool _thread_monitoring_contention_enabled; 32.13 static bool _thread_cpu_time_enabled; 32.14 + static bool _thread_allocated_memory_enabled; 32.15 32.16 // Need to keep the list of thread dump result that 32.17 // keep references to methodOop since thread dump can be 32.18 @@ -83,6 +84,9 @@ 32.19 static bool set_thread_cpu_time_enabled(bool flag); 32.20 static bool is_thread_cpu_time_enabled() { return _thread_cpu_time_enabled; } 32.21 32.22 + static bool set_thread_allocated_memory_enabled(bool flag); 32.23 + static bool is_thread_allocated_memory_enabled() { return _thread_cpu_time_enabled; } 32.24 + 32.25 static jlong get_total_thread_count() { return _total_threads_count->get_value(); } 32.26 static jlong get_peak_thread_count() { return _peak_threads_count->get_value(); } 32.27 static jlong get_live_thread_count() { return _live_threads_count->get_value() - _exiting_threads_count; }
33.1 --- a/src/share/vm/utilities/debug.cpp Fri Jan 07 03:41:07 2011 -0800 33.2 +++ b/src/share/vm/utilities/debug.cpp Fri Jan 07 15:54:32 2011 -0800 33.3 @@ -226,7 +226,7 @@ 33.4 33.5 void report_vm_out_of_memory(const char* file, int line, size_t size, 33.6 const char* message) { 33.7 - if (Debugging || error_is_suppressed(file, line)) return; 33.8 + if (Debugging) return; 33.9 33.10 // We try to gather additional information for the first out of memory 33.11 // error only; gathering additional data might cause an allocation and a
34.1 --- a/src/share/vm/utilities/vmError.cpp Fri Jan 07 03:41:07 2011 -0800 34.2 +++ b/src/share/vm/utilities/vmError.cpp Fri Jan 07 15:54:32 2011 -0800 34.3 @@ -67,7 +67,7 @@ 34.4 // threads are blocked forever inside report_and_die(). 34.5 34.6 // Constructor for crashes 34.7 -VMError::VMError(Thread* thread, int sig, address pc, void* siginfo, void* context) { 34.8 +VMError::VMError(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context) { 34.9 _thread = thread; 34.10 _id = sig; 34.11 _pc = pc; 34.12 @@ -322,29 +322,51 @@ 34.13 34.14 STEP(10, "(printing fatal error message)") 34.15 34.16 - st->print_cr("#"); 34.17 - st->print_cr("# A fatal error has been detected by the Java Runtime Environment:"); 34.18 + st->print_cr("#"); 34.19 + if (should_report_bug(_id)) { 34.20 + st->print_cr("# A fatal error has been detected by the Java Runtime Environment:"); 34.21 + } else { 34.22 + st->print_cr("# There is insufficient memory for the Java " 34.23 + "Runtime Environment to continue."); 34.24 + } 34.25 34.26 STEP(15, "(printing type of error)") 34.27 34.28 switch(_id) { 34.29 case oom_error: 34.30 - st->print_cr("#"); 34.31 - st->print("# java.lang.OutOfMemoryError: "); 34.32 if (_size) { 34.33 - st->print("requested "); 34.34 - sprintf(buf,SIZE_FORMAT,_size); 34.35 + st->print("# Native memory allocation (malloc) failed to allocate "); 34.36 + jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size); 34.37 st->print(buf); 34.38 st->print(" bytes"); 34.39 if (_message != NULL) { 34.40 st->print(" for "); 34.41 st->print(_message); 34.42 } 34.43 - st->print_cr(". Out of swap space?"); 34.44 + st->cr(); 34.45 } else { 34.46 if (_message != NULL) 34.47 + st->print("# "); 34.48 st->print_cr(_message); 34.49 } 34.50 + // In error file give some solutions 34.51 + if (_verbose) { 34.52 + st->print_cr("# Possible reasons:"); 34.53 + st->print_cr("# The system is out of physical RAM or swap space"); 34.54 + st->print_cr("# In 32 bit mode, the process size limit was hit"); 34.55 + st->print_cr("# Possible solutions:"); 34.56 + st->print_cr("# Reduce memory load on the system"); 34.57 + st->print_cr("# Increase physical memory or swap space"); 34.58 + st->print_cr("# Check if swap backing store is full"); 34.59 + st->print_cr("# Use 64 bit Java on a 64 bit OS"); 34.60 + st->print_cr("# Decrease Java heap size (-Xmx/-Xms)"); 34.61 + st->print_cr("# Decrease number of Java threads"); 34.62 + st->print_cr("# Decrease Java thread stack sizes (-Xss)"); 34.63 + st->print_cr("# Set larger code cache with -XX:ReservedCodeCacheSize="); 34.64 + st->print_cr("# This output file may be truncated or incomplete."); 34.65 + } else { 34.66 + return; // that's enough for the screen 34.67 + } 34.68 break; 34.69 case internal_error: 34.70 default: 34.71 @@ -361,7 +383,11 @@ 34.72 st->print(" (0x%x)", _id); // signal number 34.73 st->print(" at pc=" PTR_FORMAT, _pc); 34.74 } else { 34.75 - st->print("Internal Error"); 34.76 + if (should_report_bug(_id)) { 34.77 + st->print("Internal Error"); 34.78 + } else { 34.79 + st->print("Out of Memory Error"); 34.80 + } 34.81 if (_filename != NULL && _lineno > 0) { 34.82 #ifdef PRODUCT 34.83 // In product mode chop off pathname? 34.84 @@ -393,12 +419,14 @@ 34.85 34.86 STEP(40, "(printing error message)") 34.87 34.88 - // error message 34.89 - if (_detail_msg) { 34.90 - st->print_cr("# %s: %s", _message ? _message : "Error", _detail_msg); 34.91 - } else if (_message) { 34.92 - st->print_cr("# Error: %s", _message); 34.93 - } 34.94 + if (should_report_bug(_id)) { // already printed the message. 34.95 + // error message 34.96 + if (_detail_msg) { 34.97 + st->print_cr("# %s: %s", _message ? _message : "Error", _detail_msg); 34.98 + } else if (_message) { 34.99 + st->print_cr("# Error: %s", _message); 34.100 + } 34.101 + } 34.102 34.103 STEP(50, "(printing Java version string)") 34.104 34.105 @@ -428,7 +456,9 @@ 34.106 34.107 STEP(65, "(printing bug submit message)") 34.108 34.109 - if (_verbose) print_bug_submit_message(st, _thread); 34.110 + if (should_report_bug(_id) && _verbose) { 34.111 + print_bug_submit_message(st, _thread); 34.112 + } 34.113 34.114 STEP(70, "(printing thread)" ) 34.115 34.116 @@ -906,7 +936,7 @@ 34.117 OnError = NULL; 34.118 } 34.119 34.120 - static bool skip_bug_url = false; 34.121 + static bool skip_bug_url = !should_report_bug(first_error->_id); 34.122 if (!skip_bug_url) { 34.123 skip_bug_url = true; 34.124 34.125 @@ -919,7 +949,8 @@ 34.126 static bool skip_os_abort = false; 34.127 if (!skip_os_abort) { 34.128 skip_os_abort = true; 34.129 - os::abort(); 34.130 + bool dump_core = should_report_bug(first_error->_id); 34.131 + os::abort(dump_core); 34.132 } 34.133 34.134 // if os::abort() doesn't abort, try os::die();
35.1 --- a/src/share/vm/utilities/vmError.hpp Fri Jan 07 03:41:07 2011 -0800 35.2 +++ b/src/share/vm/utilities/vmError.hpp Fri Jan 07 15:54:32 2011 -0800 35.3 @@ -87,10 +87,12 @@ 35.4 // accessor 35.5 const char* message() const { return _message; } 35.6 const char* detail_msg() const { return _detail_msg; } 35.7 + bool should_report_bug(unsigned int id) { return id != oom_error; } 35.8 35.9 public: 35.10 // Constructor for crashes 35.11 - VMError(Thread* thread, int sig, address pc, void* siginfo, void* context); 35.12 + VMError(Thread* thread, unsigned int sig, address pc, void* siginfo, 35.13 + void* context); 35.14 // Constructor for VM internal errors 35.15 VMError(Thread* thread, const char* filename, int lineno, 35.16 const char* message, const char * detail_msg);