comparison src/cpu/x86/vm/c1_Runtime1_x86.cpp @ 2100:b1a2afa37ec4

7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis Summary: Track allocated bytes in Thread's, update on TLAB retirement and direct allocation in Eden and tenured, add JNI methods for ThreadMXBean. Reviewed-by: coleenp, kvn, dholmes, ysr
author phh
date Fri, 07 Jan 2011 10:42:32 -0500
parents ac637b7220d1
children 91fe28b03d6a e4fee0bdaa85
comparison
equal deleted inserted replaced
2097:039eb4201e06 2100:b1a2afa37ec4
1 /* 1 /*
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
975 __ movptr(Address(thread, JavaThread::vm_result_2_offset()), NULL_WORD); 975 __ movptr(Address(thread, JavaThread::vm_result_2_offset()), NULL_WORD);
976 976
977 // verify that that there is really a valid exception in rax, 977 // verify that that there is really a valid exception in rax,
978 __ verify_not_null_oop(exception_oop); 978 __ verify_not_null_oop(exception_oop);
979 979
980
981 oop_maps = new OopMapSet(); 980 oop_maps = new OopMapSet();
982 OopMap* oop_map = generate_oop_map(sasm, 1); 981 OopMap* oop_map = generate_oop_map(sasm, 1);
983 generate_handle_exception(sasm, oop_maps, oop_map); 982 generate_handle_exception(sasm, oop_maps, oop_map);
984 __ stop("should not reach here"); 983 __ stop("should not reach here");
985 } 984 }
1035 #endif // ASSERT 1034 #endif // ASSERT
1036 1035
1037 // if we got here then the TLAB allocation failed, so try 1036 // if we got here then the TLAB allocation failed, so try
1038 // refilling the TLAB or allocating directly from eden. 1037 // refilling the TLAB or allocating directly from eden.
1039 Label retry_tlab, try_eden; 1038 Label retry_tlab, try_eden;
1040 __ tlab_refill(retry_tlab, try_eden, slow_path); // does not destroy rdx (klass) 1039 const Register thread =
1040 __ tlab_refill(retry_tlab, try_eden, slow_path); // does not destroy rdx (klass), returns rdi
1041 1041
1042 __ bind(retry_tlab); 1042 __ bind(retry_tlab);
1043 1043
1044 // get the instance size (size is postive so movl is fine for 64bit) 1044 // get the instance size (size is postive so movl is fine for 64bit)
1045 __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); 1045 __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
1046
1046 __ tlab_allocate(obj, obj_size, 0, t1, t2, slow_path); 1047 __ tlab_allocate(obj, obj_size, 0, t1, t2, slow_path);
1048
1047 __ initialize_object(obj, klass, obj_size, 0, t1, t2); 1049 __ initialize_object(obj, klass, obj_size, 0, t1, t2);
1048 __ verify_oop(obj); 1050 __ verify_oop(obj);
1049 __ pop(rbx); 1051 __ pop(rbx);
1050 __ pop(rdi); 1052 __ pop(rdi);
1051 __ ret(0); 1053 __ ret(0);
1052 1054
1053 __ bind(try_eden); 1055 __ bind(try_eden);
1054 // get the instance size (size is postive so movl is fine for 64bit) 1056 // get the instance size (size is postive so movl is fine for 64bit)
1055 __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); 1057 __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
1058
1056 __ eden_allocate(obj, obj_size, 0, t1, slow_path); 1059 __ eden_allocate(obj, obj_size, 0, t1, slow_path);
1060 __ incr_allocated_bytes(thread, obj_size, 0);
1061
1057 __ initialize_object(obj, klass, obj_size, 0, t1, t2); 1062 __ initialize_object(obj, klass, obj_size, 0, t1, t2);
1058 __ verify_oop(obj); 1063 __ verify_oop(obj);
1059 __ pop(rbx); 1064 __ pop(rbx);
1060 __ pop(rdi); 1065 __ pop(rdi);
1061 __ ret(0); 1066 __ ret(0);
1141 __ jcc(Assembler::above, slow_path); 1146 __ jcc(Assembler::above, slow_path);
1142 1147
1143 // if we got here then the TLAB allocation failed, so try 1148 // if we got here then the TLAB allocation failed, so try
1144 // refilling the TLAB or allocating directly from eden. 1149 // refilling the TLAB or allocating directly from eden.
1145 Label retry_tlab, try_eden; 1150 Label retry_tlab, try_eden;
1146 __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves rbx, & rdx 1151 const Register thread =
1152 __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves rbx & rdx, returns rdi
1147 1153
1148 __ bind(retry_tlab); 1154 __ bind(retry_tlab);
1149 1155
1150 // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F)) 1156 // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F))
1151 // since size is postive movl does right thing on 64bit 1157 // since size is positive movl does right thing on 64bit
1152 __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); 1158 __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
1153 // since size is postive movl does right thing on 64bit 1159 // since size is postive movl does right thing on 64bit
1154 __ movl(arr_size, length); 1160 __ movl(arr_size, length);
1155 assert(t1 == rcx, "fixed register usage"); 1161 assert(t1 == rcx, "fixed register usage");
1156 __ shlptr(arr_size /* by t1=rcx, mod 32 */); 1162 __ shlptr(arr_size /* by t1=rcx, mod 32 */);
1173 __ verify_oop(obj); 1179 __ verify_oop(obj);
1174 __ ret(0); 1180 __ ret(0);
1175 1181
1176 __ bind(try_eden); 1182 __ bind(try_eden);
1177 // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F)) 1183 // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F))
1178 // since size is postive movl does right thing on 64bit 1184 // since size is positive movl does right thing on 64bit
1179 __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); 1185 __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
1180 // since size is postive movl does right thing on 64bit 1186 // since size is postive movl does right thing on 64bit
1181 __ movl(arr_size, length); 1187 __ movl(arr_size, length);
1182 assert(t1 == rcx, "fixed register usage"); 1188 assert(t1 == rcx, "fixed register usage");
1183 __ shlptr(arr_size /* by t1=rcx, mod 32 */); 1189 __ shlptr(arr_size /* by t1=rcx, mod 32 */);
1186 __ addptr(arr_size, t1); 1192 __ addptr(arr_size, t1);
1187 __ addptr(arr_size, MinObjAlignmentInBytesMask); // align up 1193 __ addptr(arr_size, MinObjAlignmentInBytesMask); // align up
1188 __ andptr(arr_size, ~MinObjAlignmentInBytesMask); 1194 __ andptr(arr_size, ~MinObjAlignmentInBytesMask);
1189 1195
1190 __ eden_allocate(obj, arr_size, 0, t1, slow_path); // preserves arr_size 1196 __ eden_allocate(obj, arr_size, 0, t1, slow_path); // preserves arr_size
1197 __ incr_allocated_bytes(thread, arr_size, 0);
1191 1198
1192 __ initialize_header(obj, klass, length, t1, t2); 1199 __ initialize_header(obj, klass, length, t1, t2);
1193 __ movb(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes() + (Klass::_lh_header_size_shift / BitsPerByte))); 1200 __ movb(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes() + (Klass::_lh_header_size_shift / BitsPerByte)));
1194 assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise"); 1201 assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise");
1195 assert(Klass::_lh_header_size_mask <= 0xFF, "bytewise"); 1202 assert(Klass::_lh_header_size_mask <= 0xFF, "bytewise");