1.1 --- a/src/share/vm/gc_implementation/g1/heapRegion.cpp Thu Jan 06 23:50:02 2011 -0800 1.2 +++ b/src/share/vm/gc_implementation/g1/heapRegion.cpp Wed Jan 12 13:06:00 2011 -0500 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2001, 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 @@ -386,26 +386,27 @@ 1.11 } 1.12 // </PREDICTION> 1.13 1.14 -void HeapRegion::set_startsHumongous(HeapWord* new_end) { 1.15 +void HeapRegion::set_startsHumongous(HeapWord* new_top, HeapWord* new_end) { 1.16 assert(end() == _orig_end, 1.17 "Should be normal before the humongous object allocation"); 1.18 assert(top() == bottom(), "should be empty"); 1.19 + assert(bottom() <= new_top && new_top <= new_end, "pre-condition"); 1.20 1.21 _humongous_type = StartsHumongous; 1.22 _humongous_start_region = this; 1.23 1.24 set_end(new_end); 1.25 - _offsets.set_for_starts_humongous(new_end); 1.26 + _offsets.set_for_starts_humongous(new_top); 1.27 } 1.28 1.29 -void HeapRegion::set_continuesHumongous(HeapRegion* start) { 1.30 +void HeapRegion::set_continuesHumongous(HeapRegion* first_hr) { 1.31 assert(end() == _orig_end, 1.32 "Should be normal before the humongous object allocation"); 1.33 assert(top() == bottom(), "should be empty"); 1.34 - assert(start->startsHumongous(), "pre-condition"); 1.35 + assert(first_hr->startsHumongous(), "pre-condition"); 1.36 1.37 _humongous_type = ContinuesHumongous; 1.38 - _humongous_start_region = start; 1.39 + _humongous_start_region = first_hr; 1.40 } 1.41 1.42 bool HeapRegion::claimHeapRegion(jint claimValue) { 1.43 @@ -782,9 +783,6 @@ 1.44 verify(allow_dirty, /* use_prev_marking */ true, /* failures */ &dummy); 1.45 } 1.46 1.47 -#define OBJ_SAMPLE_INTERVAL 0 1.48 -#define BLOCK_SAMPLE_INTERVAL 100 1.49 - 1.50 // This really ought to be commoned up into OffsetTableContigSpace somehow. 1.51 // We would need a mechanism to make that code skip dead objects. 1.52 1.53 @@ -795,83 +793,125 @@ 1.54 *failures = false; 1.55 HeapWord* p = bottom(); 1.56 HeapWord* prev_p = NULL; 1.57 - int objs = 0; 1.58 - int blocks = 0; 1.59 VerifyLiveClosure vl_cl(g1, use_prev_marking); 1.60 bool is_humongous = isHumongous(); 1.61 + bool do_bot_verify = !is_young(); 1.62 size_t object_num = 0; 1.63 while (p < top()) { 1.64 - size_t size = oop(p)->size(); 1.65 - if (is_humongous != g1->isHumongous(size)) { 1.66 + oop obj = oop(p); 1.67 + size_t obj_size = obj->size(); 1.68 + object_num += 1; 1.69 + 1.70 + if (is_humongous != g1->isHumongous(obj_size)) { 1.71 gclog_or_tty->print_cr("obj "PTR_FORMAT" is of %shumongous size (" 1.72 SIZE_FORMAT" words) in a %shumongous region", 1.73 - p, g1->isHumongous(size) ? "" : "non-", 1.74 - size, is_humongous ? "" : "non-"); 1.75 + p, g1->isHumongous(obj_size) ? "" : "non-", 1.76 + obj_size, is_humongous ? "" : "non-"); 1.77 *failures = true; 1.78 + return; 1.79 } 1.80 - object_num += 1; 1.81 - if (blocks == BLOCK_SAMPLE_INTERVAL) { 1.82 - HeapWord* res = block_start_const(p + (size/2)); 1.83 - if (p != res) { 1.84 - gclog_or_tty->print_cr("offset computation 1 for "PTR_FORMAT" and " 1.85 - SIZE_FORMAT" returned "PTR_FORMAT, 1.86 - p, size, res); 1.87 + 1.88 + // If it returns false, verify_for_object() will output the 1.89 + // appropriate messasge. 1.90 + if (do_bot_verify && !_offsets.verify_for_object(p, obj_size)) { 1.91 + *failures = true; 1.92 + return; 1.93 + } 1.94 + 1.95 + if (!g1->is_obj_dead_cond(obj, this, use_prev_marking)) { 1.96 + if (obj->is_oop()) { 1.97 + klassOop klass = obj->klass(); 1.98 + if (!klass->is_perm()) { 1.99 + gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " 1.100 + "not in perm", klass, obj); 1.101 + *failures = true; 1.102 + return; 1.103 + } else if (!klass->is_klass()) { 1.104 + gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " 1.105 + "not a klass", klass, obj); 1.106 + *failures = true; 1.107 + return; 1.108 + } else { 1.109 + vl_cl.set_containing_obj(obj); 1.110 + obj->oop_iterate(&vl_cl); 1.111 + if (vl_cl.failures()) { 1.112 + *failures = true; 1.113 + } 1.114 + if (G1MaxVerifyFailures >= 0 && 1.115 + vl_cl.n_failures() >= G1MaxVerifyFailures) { 1.116 + return; 1.117 + } 1.118 + } 1.119 + } else { 1.120 + gclog_or_tty->print_cr(PTR_FORMAT" no an oop", obj); 1.121 *failures = true; 1.122 return; 1.123 } 1.124 - blocks = 0; 1.125 - } else { 1.126 - blocks++; 1.127 - } 1.128 - if (objs == OBJ_SAMPLE_INTERVAL) { 1.129 - oop obj = oop(p); 1.130 - if (!g1->is_obj_dead_cond(obj, this, use_prev_marking)) { 1.131 - if (obj->is_oop()) { 1.132 - klassOop klass = obj->klass(); 1.133 - if (!klass->is_perm()) { 1.134 - gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " 1.135 - "not in perm", klass, obj); 1.136 - *failures = true; 1.137 - return; 1.138 - } else if (!klass->is_klass()) { 1.139 - gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " 1.140 - "not a klass", klass, obj); 1.141 - *failures = true; 1.142 - return; 1.143 - } else { 1.144 - vl_cl.set_containing_obj(obj); 1.145 - obj->oop_iterate(&vl_cl); 1.146 - if (vl_cl.failures()) { 1.147 - *failures = true; 1.148 - } 1.149 - if (G1MaxVerifyFailures >= 0 && 1.150 - vl_cl.n_failures() >= G1MaxVerifyFailures) { 1.151 - return; 1.152 - } 1.153 - } 1.154 - } else { 1.155 - gclog_or_tty->print_cr(PTR_FORMAT" no an oop", obj); 1.156 - *failures = true; 1.157 - return; 1.158 - } 1.159 - } 1.160 - objs = 0; 1.161 - } else { 1.162 - objs++; 1.163 } 1.164 prev_p = p; 1.165 - p += size; 1.166 + p += obj_size; 1.167 } 1.168 - HeapWord* rend = end(); 1.169 - HeapWord* rtop = top(); 1.170 - if (rtop < rend) { 1.171 - HeapWord* res = block_start_const(rtop + (rend - rtop) / 2); 1.172 - if (res != rtop) { 1.173 - gclog_or_tty->print_cr("offset computation 2 for "PTR_FORMAT" and " 1.174 - PTR_FORMAT" returned "PTR_FORMAT, 1.175 - rtop, rend, res); 1.176 + 1.177 + if (p != top()) { 1.178 + gclog_or_tty->print_cr("end of last object "PTR_FORMAT" " 1.179 + "does not match top "PTR_FORMAT, p, top()); 1.180 + *failures = true; 1.181 + return; 1.182 + } 1.183 + 1.184 + HeapWord* the_end = end(); 1.185 + assert(p == top(), "it should still hold"); 1.186 + // Do some extra BOT consistency checking for addresses in the 1.187 + // range [top, end). BOT look-ups in this range should yield 1.188 + // top. No point in doing that if top == end (there's nothing there). 1.189 + if (p < the_end) { 1.190 + // Look up top 1.191 + HeapWord* addr_1 = p; 1.192 + HeapWord* b_start_1 = _offsets.block_start_const(addr_1); 1.193 + if (b_start_1 != p) { 1.194 + gclog_or_tty->print_cr("BOT look up for top: "PTR_FORMAT" " 1.195 + " yielded "PTR_FORMAT", expecting "PTR_FORMAT, 1.196 + addr_1, b_start_1, p); 1.197 + *failures = true; 1.198 + return; 1.199 + } 1.200 + 1.201 + // Look up top + 1 1.202 + HeapWord* addr_2 = p + 1; 1.203 + if (addr_2 < the_end) { 1.204 + HeapWord* b_start_2 = _offsets.block_start_const(addr_2); 1.205 + if (b_start_2 != p) { 1.206 + gclog_or_tty->print_cr("BOT look up for top + 1: "PTR_FORMAT" " 1.207 + " yielded "PTR_FORMAT", expecting "PTR_FORMAT, 1.208 + addr_2, b_start_2, p); 1.209 *failures = true; 1.210 return; 1.211 + } 1.212 + } 1.213 + 1.214 + // Look up an address between top and end 1.215 + size_t diff = pointer_delta(the_end, p) / 2; 1.216 + HeapWord* addr_3 = p + diff; 1.217 + if (addr_3 < the_end) { 1.218 + HeapWord* b_start_3 = _offsets.block_start_const(addr_3); 1.219 + if (b_start_3 != p) { 1.220 + gclog_or_tty->print_cr("BOT look up for top + diff: "PTR_FORMAT" " 1.221 + " yielded "PTR_FORMAT", expecting "PTR_FORMAT, 1.222 + addr_3, b_start_3, p); 1.223 + *failures = true; 1.224 + return; 1.225 + } 1.226 + } 1.227 + 1.228 + // Loook up end - 1 1.229 + HeapWord* addr_4 = the_end - 1; 1.230 + HeapWord* b_start_4 = _offsets.block_start_const(addr_4); 1.231 + if (b_start_4 != p) { 1.232 + gclog_or_tty->print_cr("BOT look up for end - 1: "PTR_FORMAT" " 1.233 + " yielded "PTR_FORMAT", expecting "PTR_FORMAT, 1.234 + addr_4, b_start_4, p); 1.235 + *failures = true; 1.236 + return; 1.237 } 1.238 } 1.239 1.240 @@ -880,12 +920,6 @@ 1.241 "but has "SIZE_FORMAT", objects", 1.242 bottom(), end(), object_num); 1.243 *failures = true; 1.244 - } 1.245 - 1.246 - if (p != top()) { 1.247 - gclog_or_tty->print_cr("end of last object "PTR_FORMAT" " 1.248 - "does not match top "PTR_FORMAT, p, top()); 1.249 - *failures = true; 1.250 return; 1.251 } 1.252 }