Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/heapRegionSet.cpp @ 6010:720b6a76dd9d
7157073: G1: type change size_t -> uint for region counts / indexes
Summary: Change the type of fields / variables / etc. that represent region counts and indeces from size_t to uint.
Reviewed-by: iveresov, brutisso, jmasa, jwilhelm
author | tonyp |
---|---|
date | Wed, 18 Apr 2012 07:21:15 -0400 |
parents | 8aae2050e83e |
children | d42fe3c3001d |
comparison
equal
deleted
inserted
replaced
6009:dde53abda3d6 | 6010:720b6a76dd9d |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2011, 2012, 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. |
23 */ | 23 */ |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "gc_implementation/g1/heapRegionSet.inline.hpp" | 26 #include "gc_implementation/g1/heapRegionSet.inline.hpp" |
27 | 27 |
28 size_t HeapRegionSetBase::_unrealistically_long_length = 0; | 28 uint HeapRegionSetBase::_unrealistically_long_length = 0; |
29 HRSPhase HeapRegionSetBase::_phase = HRSPhaseNone; | 29 HRSPhase HeapRegionSetBase::_phase = HRSPhaseNone; |
30 | 30 |
31 //////////////////// HeapRegionSetBase //////////////////// | 31 //////////////////// HeapRegionSetBase //////////////////// |
32 | 32 |
33 void HeapRegionSetBase::set_unrealistically_long_length(size_t len) { | 33 void HeapRegionSetBase::set_unrealistically_long_length(uint len) { |
34 guarantee(_unrealistically_long_length == 0, "should only be set once"); | 34 guarantee(_unrealistically_long_length == 0, "should only be set once"); |
35 _unrealistically_long_length = len; | 35 _unrealistically_long_length = len; |
36 } | 36 } |
37 | 37 |
38 size_t HeapRegionSetBase::calculate_region_num(HeapRegion* hr) { | 38 uint HeapRegionSetBase::calculate_region_num(HeapRegion* hr) { |
39 assert(hr->startsHumongous(), "pre-condition"); | 39 assert(hr->startsHumongous(), "pre-condition"); |
40 assert(hr->capacity() % HeapRegion::GrainBytes == 0, "invariant"); | 40 assert(hr->capacity() % HeapRegion::GrainBytes == 0, "invariant"); |
41 size_t region_num = hr->capacity() >> HeapRegion::LogOfHRGrainBytes; | 41 uint region_num = (uint) (hr->capacity() >> HeapRegion::LogOfHRGrainBytes); |
42 assert(region_num > 0, "sanity"); | 42 assert(region_num > 0, "sanity"); |
43 return region_num; | 43 return region_num; |
44 } | 44 } |
45 | 45 |
46 void HeapRegionSetBase::fill_in_ext_msg(hrs_ext_msg* msg, const char* message) { | 46 void HeapRegionSetBase::fill_in_ext_msg(hrs_ext_msg* msg, const char* message) { |
47 msg->append("[%s] %s " | 47 msg->append("[%s] %s ln: %u rn: %u cy: "SIZE_FORMAT" ud: "SIZE_FORMAT, |
48 "ln: "SIZE_FORMAT" rn: "SIZE_FORMAT" " | |
49 "cy: "SIZE_FORMAT" ud: "SIZE_FORMAT, | |
50 name(), message, length(), region_num(), | 48 name(), message, length(), region_num(), |
51 total_capacity_bytes(), total_used_bytes()); | 49 total_capacity_bytes(), total_used_bytes()); |
52 fill_in_ext_msg_extra(msg); | 50 fill_in_ext_msg_extra(msg); |
53 } | 51 } |
54 | 52 |
168 hrs_assert_mt_safety_ok(this); | 166 hrs_assert_mt_safety_ok(this); |
169 assert(_verify_in_progress, | 167 assert(_verify_in_progress, |
170 hrs_ext_msg(this, "verification should be in progress")); | 168 hrs_ext_msg(this, "verification should be in progress")); |
171 | 169 |
172 guarantee(length() == _calc_length, | 170 guarantee(length() == _calc_length, |
173 hrs_err_msg("[%s] length: "SIZE_FORMAT" should be == " | 171 hrs_err_msg("[%s] length: %u should be == calc length: %u", |
174 "calc length: "SIZE_FORMAT, | |
175 name(), length(), _calc_length)); | 172 name(), length(), _calc_length)); |
176 | 173 |
177 guarantee(region_num() == _calc_region_num, | 174 guarantee(region_num() == _calc_region_num, |
178 hrs_err_msg("[%s] region num: "SIZE_FORMAT" should be == " | 175 hrs_err_msg("[%s] region num: %u should be == calc region num: %u", |
179 "calc region num: "SIZE_FORMAT, | |
180 name(), region_num(), _calc_region_num)); | 176 name(), region_num(), _calc_region_num)); |
181 | 177 |
182 guarantee(total_capacity_bytes() == _calc_total_capacity_bytes, | 178 guarantee(total_capacity_bytes() == _calc_total_capacity_bytes, |
183 hrs_err_msg("[%s] capacity bytes: "SIZE_FORMAT" should be == " | 179 hrs_err_msg("[%s] capacity bytes: "SIZE_FORMAT" should be == " |
184 "calc capacity bytes: "SIZE_FORMAT, | 180 "calc capacity bytes: "SIZE_FORMAT, |
209 out->print_cr("Set: %s ("PTR_FORMAT")", name(), this); | 205 out->print_cr("Set: %s ("PTR_FORMAT")", name(), this); |
210 out->print_cr(" Region Assumptions"); | 206 out->print_cr(" Region Assumptions"); |
211 out->print_cr(" humongous : %s", BOOL_TO_STR(regions_humongous())); | 207 out->print_cr(" humongous : %s", BOOL_TO_STR(regions_humongous())); |
212 out->print_cr(" empty : %s", BOOL_TO_STR(regions_empty())); | 208 out->print_cr(" empty : %s", BOOL_TO_STR(regions_empty())); |
213 out->print_cr(" Attributes"); | 209 out->print_cr(" Attributes"); |
214 out->print_cr(" length : "SIZE_FORMAT_W(14), length()); | 210 out->print_cr(" length : %14u", length()); |
215 out->print_cr(" region num : "SIZE_FORMAT_W(14), region_num()); | 211 out->print_cr(" region num : %14u", region_num()); |
216 out->print_cr(" total capacity : "SIZE_FORMAT_W(14)" bytes", | 212 out->print_cr(" total capacity : "SIZE_FORMAT_W(14)" bytes", |
217 total_capacity_bytes()); | 213 total_capacity_bytes()); |
218 out->print_cr(" total used : "SIZE_FORMAT_W(14)" bytes", | 214 out->print_cr(" total used : "SIZE_FORMAT_W(14)" bytes", |
219 total_used_bytes()); | 215 total_used_bytes()); |
220 } | 216 } |
241 proxy_set->verify_optional(); | 237 proxy_set->verify_optional(); |
242 | 238 |
243 if (proxy_set->is_empty()) return; | 239 if (proxy_set->is_empty()) return; |
244 | 240 |
245 assert(proxy_set->length() <= _length, | 241 assert(proxy_set->length() <= _length, |
246 hrs_err_msg("[%s] proxy set length: "SIZE_FORMAT" " | 242 hrs_err_msg("[%s] proxy set length: %u should be <= length: %u", |
247 "should be <= length: "SIZE_FORMAT, | |
248 name(), proxy_set->length(), _length)); | 243 name(), proxy_set->length(), _length)); |
249 _length -= proxy_set->length(); | 244 _length -= proxy_set->length(); |
250 | 245 |
251 assert(proxy_set->region_num() <= _region_num, | 246 assert(proxy_set->region_num() <= _region_num, |
252 hrs_err_msg("[%s] proxy set region num: "SIZE_FORMAT" " | 247 hrs_err_msg("[%s] proxy set region num: %u should be <= region num: %u", |
253 "should be <= region num: "SIZE_FORMAT, | |
254 name(), proxy_set->region_num(), _region_num)); | 248 name(), proxy_set->region_num(), _region_num)); |
255 _region_num -= proxy_set->region_num(); | 249 _region_num -= proxy_set->region_num(); |
256 | 250 |
257 assert(proxy_set->total_used_bytes() <= _total_used_bytes, | 251 assert(proxy_set->total_used_bytes() <= _total_used_bytes, |
258 hrs_err_msg("[%s] proxy set used bytes: "SIZE_FORMAT" " | 252 hrs_err_msg("[%s] proxy set used bytes: "SIZE_FORMAT" " |
367 clear(); | 361 clear(); |
368 | 362 |
369 verify_optional(); | 363 verify_optional(); |
370 } | 364 } |
371 | 365 |
372 void HeapRegionLinkedList::remove_all_pending(size_t target_count) { | 366 void HeapRegionLinkedList::remove_all_pending(uint target_count) { |
373 hrs_assert_mt_safety_ok(this); | 367 hrs_assert_mt_safety_ok(this); |
374 assert(target_count > 1, hrs_ext_msg(this, "pre-condition")); | 368 assert(target_count > 1, hrs_ext_msg(this, "pre-condition")); |
375 assert(!is_empty(), hrs_ext_msg(this, "pre-condition")); | 369 assert(!is_empty(), hrs_ext_msg(this, "pre-condition")); |
376 | 370 |
377 verify_optional(); | 371 verify_optional(); |
378 DEBUG_ONLY(size_t old_length = length();) | 372 DEBUG_ONLY(uint old_length = length();) |
379 | 373 |
380 HeapRegion* curr = _head; | 374 HeapRegion* curr = _head; |
381 HeapRegion* prev = NULL; | 375 HeapRegion* prev = NULL; |
382 size_t count = 0; | 376 uint count = 0; |
383 while (curr != NULL) { | 377 while (curr != NULL) { |
384 hrs_assert_region_ok(this, curr, this); | 378 hrs_assert_region_ok(this, curr, this); |
385 HeapRegion* next = curr->next(); | 379 HeapRegion* next = curr->next(); |
386 | 380 |
387 if (curr->pending_removal()) { | 381 if (curr->pending_removal()) { |
388 assert(count < target_count, | 382 assert(count < target_count, |
389 hrs_err_msg("[%s] should not come across more regions " | 383 hrs_err_msg("[%s] should not come across more regions " |
390 "pending for removal than target_count: "SIZE_FORMAT, | 384 "pending for removal than target_count: %u", |
391 name(), target_count)); | 385 name(), target_count)); |
392 | 386 |
393 if (prev == NULL) { | 387 if (prev == NULL) { |
394 assert(_head == curr, hrs_ext_msg(this, "invariant")); | 388 assert(_head == curr, hrs_ext_msg(this, "invariant")); |
395 _head = next; | 389 _head = next; |
420 } | 414 } |
421 curr = next; | 415 curr = next; |
422 } | 416 } |
423 | 417 |
424 assert(count == target_count, | 418 assert(count == target_count, |
425 hrs_err_msg("[%s] count: "SIZE_FORMAT" should be == " | 419 hrs_err_msg("[%s] count: %u should be == target_count: %u", |
426 "target_count: "SIZE_FORMAT, name(), count, target_count)); | 420 name(), count, target_count)); |
427 assert(length() + target_count == old_length, | 421 assert(length() + target_count == old_length, |
428 hrs_err_msg("[%s] new length should be consistent " | 422 hrs_err_msg("[%s] new length should be consistent " |
429 "new length: "SIZE_FORMAT" old length: "SIZE_FORMAT" " | 423 "new length: %u old length: %u target_count: %u", |
430 "target_count: "SIZE_FORMAT, | |
431 name(), length(), old_length, target_count)); | 424 name(), length(), old_length, target_count)); |
432 | 425 |
433 verify_optional(); | 426 verify_optional(); |
434 } | 427 } |
435 | 428 |
442 verify_start(); | 435 verify_start(); |
443 | 436 |
444 HeapRegion* curr = _head; | 437 HeapRegion* curr = _head; |
445 HeapRegion* prev1 = NULL; | 438 HeapRegion* prev1 = NULL; |
446 HeapRegion* prev0 = NULL; | 439 HeapRegion* prev0 = NULL; |
447 size_t count = 0; | 440 uint count = 0; |
448 while (curr != NULL) { | 441 while (curr != NULL) { |
449 verify_next_region(curr); | 442 verify_next_region(curr); |
450 | 443 |
451 count += 1; | 444 count += 1; |
452 guarantee(count < _unrealistically_long_length, | 445 guarantee(count < _unrealistically_long_length, |
453 hrs_err_msg("[%s] the calculated length: "SIZE_FORMAT" " | 446 hrs_err_msg("[%s] the calculated length: %u " |
454 "seems very long, is there maybe a cycle? " | 447 "seems very long, is there maybe a cycle? " |
455 "curr: "PTR_FORMAT" prev0: "PTR_FORMAT" " | 448 "curr: "PTR_FORMAT" prev0: "PTR_FORMAT" " |
456 "prev1: "PTR_FORMAT" length: "SIZE_FORMAT, | 449 "prev1: "PTR_FORMAT" length: %u", |
457 name(), count, curr, prev0, prev1, length())); | 450 name(), count, curr, prev0, prev1, length())); |
458 | 451 |
459 prev1 = prev0; | 452 prev1 = prev0; |
460 prev0 = curr; | 453 prev0 = curr; |
461 curr = curr->next(); | 454 curr = curr->next(); |