1 /* 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "classfile/systemDictionary.hpp" 27 #include "gc_implementation/shared/gcHeapSummary.hpp" 28 #include "gc_implementation/shared/gcTrace.hpp" 29 #include "gc_implementation/shared/gcTraceTime.hpp" 30 #include "gc_implementation/shared/gcWhen.hpp" 31 #include "gc_implementation/shared/vmGCOperations.hpp" 32 #include "gc_interface/allocTracer.hpp" 33 #include "gc_interface/collectedHeap.hpp" 34 #include "gc_interface/collectedHeap.inline.hpp" 35 #include "oops/oop.inline.hpp" 36 #include "oops/instanceMirrorKlass.hpp" 37 #include "runtime/init.hpp" 38 #include "services/heapDumper.hpp" 39 #ifdef TARGET_OS_FAMILY_linux 40 # include "thread_linux.inline.hpp" 41 #endif 42 #ifdef TARGET_OS_FAMILY_solaris 43 # include "thread_solaris.inline.hpp" 44 #endif 45 #ifdef TARGET_OS_FAMILY_windows 46 # include "thread_windows.inline.hpp" 47 #endif 48 #ifdef TARGET_OS_FAMILY_bsd 49 # include "thread_bsd.inline.hpp" 50 #endif 51 52 53 #ifdef ASSERT 54 int CollectedHeap::_fire_out_of_memory_count = 0; 55 #endif 56 57 size_t CollectedHeap::_filler_array_max_size = 0; 58 59 template <> 60 void EventLogBase<GCMessage>::print(outputStream* st, GCMessage& m) { 61 st->print_cr("GC heap %s", m.is_before ? "before" : "after"); 62 st->print_raw(m); 63 } 64 65 void GCHeapLog::log_heap(bool before) { 66 if (!should_log()) { 67 return; 68 } 69 70 double timestamp = fetch_timestamp(); 71 MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); 72 int index = compute_log_index(); 73 _records[index].thread = NULL; // Its the GC thread so it's not that interesting. 74 _records[index].timestamp = timestamp; 75 _records[index].data.is_before = before; 76 stringStream st(_records[index].data.buffer(), _records[index].data.size()); 77 if (before) { 78 Universe::print_heap_before_gc(&st, true); 79 } else { 80 Universe::print_heap_after_gc(&st, true); 81 } 82 } 83 84 VirtualSpaceSummary CollectedHeap::create_heap_space_summary() { 85 size_t capacity_in_words = capacity() / HeapWordSize; 86 87 return VirtualSpaceSummary( 88 reserved_region().start(), reserved_region().start() + capacity_in_words, reserved_region().end()); 89 } 90 91 GCHeapSummary CollectedHeap::create_heap_summary() { 92 VirtualSpaceSummary heap_space = create_heap_space_summary(); 93 return GCHeapSummary(heap_space, used()); 94 } 95 96 PermGenSummary CollectedHeap::create_perm_gen_summary() { 97 VirtualSpaceSummary perm_space = create_perm_gen_space_summary(); 98 SpaceSummary object_space(perm_space.start(), perm_space.committed_end(), permanent_used()); 99 100 return PermGenSummary(perm_space, object_space); 101 } 102 103 void CollectedHeap::print_heap_before_gc() { 104 if (PrintHeapAtGC) { 105 Universe::print_heap_before_gc(); 106 } 107 if (_gc_heap_log != NULL) { 108 _gc_heap_log->log_heap_before(); 109 } 110 } 111 112 void CollectedHeap::print_heap_after_gc() { 113 if (PrintHeapAtGC) { 114 Universe::print_heap_after_gc(); 115 } 116 if (_gc_heap_log != NULL) { 117 _gc_heap_log->log_heap_after(); 118 } 119 } 120 121 void CollectedHeap::trace_heap(GCWhen::Type when, GCTracer* gc_tracer) { 122 const GCHeapSummary& heap_summary = create_heap_summary(); 123 const PermGenSummary& perm_summary = create_perm_gen_summary(); 124 gc_tracer->report_gc_heap_summary(when, heap_summary, perm_summary); 125 } 126 127 void CollectedHeap::trace_heap_before_gc(GCTracer* gc_tracer) { 128 trace_heap(GCWhen::BeforeGC, gc_tracer); 129 } 130 131 void CollectedHeap::trace_heap_after_gc(GCTracer* gc_tracer) { 132 trace_heap(GCWhen::AfterGC, gc_tracer); 133 } 134 135 // Memory state functions. 136 137 138 CollectedHeap::CollectedHeap() : _n_par_threads(0) 139 { 140 const size_t max_len = size_t(arrayOopDesc::max_array_length(T_INT)); 141 const size_t elements_per_word = HeapWordSize / sizeof(jint); 142 _filler_array_max_size = align_object_size(filler_array_hdr_size() + 143 max_len / elements_per_word); 144 145 _barrier_set = NULL; 146 _is_gc_active = false; 147 _total_collections = _total_full_collections = 0; 148 _gc_cause = _gc_lastcause = GCCause::_no_gc; 149 NOT_PRODUCT(_promotion_failure_alot_count = 0;) 150 NOT_PRODUCT(_promotion_failure_alot_gc_number = 0;) 151 152 if (UsePerfData) { 153 EXCEPTION_MARK; 154 155 // create the gc cause jvmstat counters 156 _perf_gc_cause = PerfDataManager::create_string_variable(SUN_GC, "cause", 157 80, GCCause::to_string(_gc_cause), CHECK); 158 159 _perf_gc_lastcause = 160 PerfDataManager::create_string_variable(SUN_GC, "lastCause", 161 80, GCCause::to_string(_gc_lastcause), CHECK); 162 } 163 _defer_initial_card_mark = false; // strengthened by subclass in pre_initialize() below. 164 // Create the ring log 165 if (LogEvents) { 166 _gc_heap_log = new GCHeapLog(); 167 } else { 168 _gc_heap_log = NULL; 169 } 170 } 171 172 void CollectedHeap::pre_initialize() { 173 // Used for ReduceInitialCardMarks (when COMPILER2 is used); 174 // otherwise remains unused. 175 #ifdef COMPILER2 176 _defer_initial_card_mark = ReduceInitialCardMarks && can_elide_tlab_store_barriers() 177 && (DeferInitialCardMark || card_mark_must_follow_store()); 178 #else 179 assert(_defer_initial_card_mark == false, "Who would set it?"); 180 #endif 181 } 182 183 #ifndef PRODUCT 184 void CollectedHeap::check_for_bad_heap_word_value(HeapWord* addr, size_t size) { 185 if (CheckMemoryInitialization && ZapUnusedHeapArea) { 186 for (size_t slot = 0; slot < size; slot += 1) { 187 assert((*(intptr_t*) (addr + slot)) != ((intptr_t) badHeapWordVal), 188 "Found badHeapWordValue in post-allocation check"); 189 } 190 } 191 } 192 193 void CollectedHeap::check_for_non_bad_heap_word_value(HeapWord* addr, size_t size) { 194 if (CheckMemoryInitialization && ZapUnusedHeapArea) { 195 for (size_t slot = 0; slot < size; slot += 1) { 196 assert((*(intptr_t*) (addr + slot)) == ((intptr_t) badHeapWordVal), 197 "Found non badHeapWordValue in pre-allocation check"); 198 } 199 } 200 } 201 #endif // PRODUCT 202 203 #ifdef ASSERT 204 void CollectedHeap::check_for_valid_allocation_state() { 205 Thread *thread = Thread::current(); 206 // How to choose between a pending exception and a potential 207 // OutOfMemoryError? Don't allow pending exceptions. 208 // This is a VM policy failure, so how do we exhaustively test it? 209 assert(!thread->has_pending_exception(), 210 "shouldn't be allocating with pending exception"); 211 if (StrictSafepointChecks) { 212 assert(thread->allow_allocation(), 213 "Allocation done by thread for which allocation is blocked " 214 "by No_Allocation_Verifier!"); 215 // Allocation of an oop can always invoke a safepoint, 216 // hence, the true argument 217 thread->check_for_valid_safepoint_state(true); 218 } 219 } 220 #endif 221 222 HeapWord* CollectedHeap::allocate_from_tlab_slow(KlassHandle klass, Thread* thread, size_t size) { 223 224 // Retain tlab and allocate object in shared space if 225 // the amount free in the tlab is too large to discard. 226 if (thread->tlab().free() > thread->tlab().refill_waste_limit()) { 227 thread->tlab().record_slow_allocation(size); 228 return NULL; 229 } 230 231 // Discard tlab and allocate a new one. 232 // To minimize fragmentation, the last TLAB may be smaller than the rest. 233 size_t new_tlab_size = thread->tlab().compute_size(size); 234 235 thread->tlab().clear_before_allocation(); 236 237 if (new_tlab_size == 0) { 238 return NULL; 239 } 240 241 // Allocate a new TLAB... 242 HeapWord* obj = Universe::heap()->allocate_new_tlab(new_tlab_size); 243 if (obj == NULL) { 244 return NULL; 245 } 246 247 AllocTracer::send_allocation_in_new_tlab_event(klass, new_tlab_size * HeapWordSize, size * HeapWordSize); 248 249 if (ZeroTLAB) { 250 // ..and clear it. 251 Copy::zero_to_words(obj, new_tlab_size); 252 } else { 253 // ...and zap just allocated object. 254 #ifdef ASSERT 255 // Skip mangling the space corresponding to the object header to 256 // ensure that the returned space is not considered parsable by 257 // any concurrent GC thread. 258 size_t hdr_size = oopDesc::header_size(); 259 Copy::fill_to_words(obj + hdr_size, new_tlab_size - hdr_size, badHeapWordVal); 260 #endif // ASSERT 261 } 262 thread->tlab().fill(obj, obj + size, new_tlab_size); 263 return obj; 264 } 265 266 void CollectedHeap::flush_deferred_store_barrier(JavaThread* thread) { 267 MemRegion deferred = thread->deferred_card_mark(); 268 if (!deferred.is_empty()) { 269 assert(_defer_initial_card_mark, "Otherwise should be empty"); 270 { 271 // Verify that the storage points to a parsable object in heap 272 DEBUG_ONLY(oop old_obj = oop(deferred.start());) 273 assert(is_in(old_obj), "Not in allocated heap"); 274 assert(!can_elide_initializing_store_barrier(old_obj), 275 "Else should have been filtered in new_store_pre_barrier()"); 276 assert(!is_in_permanent(old_obj), "Sanity: not expected"); 277 assert(old_obj->is_oop(true), "Not an oop"); 278 assert(old_obj->is_parsable(), "Will not be concurrently parsable"); 279 assert(deferred.word_size() == (size_t)(old_obj->size()), 280 "Mismatch: multiple objects?"); 281 } 282 BarrierSet* bs = barrier_set(); 283 assert(bs->has_write_region_opt(), "No write_region() on BarrierSet"); 284 bs->write_region(deferred); 285 // "Clear" the deferred_card_mark field 286 thread->set_deferred_card_mark(MemRegion()); 287 } 288 assert(thread->deferred_card_mark().is_empty(), "invariant"); 289 } 290 291 // Helper for ReduceInitialCardMarks. For performance, 292 // compiled code may elide card-marks for initializing stores 293 // to a newly allocated object along the fast-path. We 294 // compensate for such elided card-marks as follows: 295 // (a) Generational, non-concurrent collectors, such as 296 // GenCollectedHeap(ParNew,DefNew,Tenured) and 297 // ParallelScavengeHeap(ParallelGC, ParallelOldGC) 298 // need the card-mark if and only if the region is 299 // in the old gen, and do not care if the card-mark 300 // succeeds or precedes the initializing stores themselves, 301 // so long as the card-mark is completed before the next 302 // scavenge. For all these cases, we can do a card mark 303 // at the point at which we do a slow path allocation 304 // in the old gen, i.e. in this call. 305 // (b) GenCollectedHeap(ConcurrentMarkSweepGeneration) requires 306 // in addition that the card-mark for an old gen allocated 307 // object strictly follow any associated initializing stores. 308 // In these cases, the memRegion remembered below is 309 // used to card-mark the entire region either just before the next 310 // slow-path allocation by this thread or just before the next scavenge or 311 // CMS-associated safepoint, whichever of these events happens first. 312 // (The implicit assumption is that the object has been fully 313 // initialized by this point, a fact that we assert when doing the 314 // card-mark.) 315 // (c) G1CollectedHeap(G1) uses two kinds of write barriers. When a 316 // G1 concurrent marking is in progress an SATB (pre-write-)barrier is 317 // is used to remember the pre-value of any store. Initializing 318 // stores will not need this barrier, so we need not worry about 319 // compensating for the missing pre-barrier here. Turning now 320 // to the post-barrier, we note that G1 needs a RS update barrier 321 // which simply enqueues a (sequence of) dirty cards which may 322 // optionally be refined by the concurrent update threads. Note 323 // that this barrier need only be applied to a non-young write, 324 // but, like in CMS, because of the presence of concurrent refinement 325 // (much like CMS' precleaning), must strictly follow the oop-store. 326 // Thus, using the same protocol for maintaining the intended 327 // invariants turns out, serendepitously, to be the same for both 328 // G1 and CMS. 329 // 330 // For any future collector, this code should be reexamined with 331 // that specific collector in mind, and the documentation above suitably 332 // extended and updated. 333 oop CollectedHeap::new_store_pre_barrier(JavaThread* thread, oop new_obj) { 334 // If a previous card-mark was deferred, flush it now. 335 flush_deferred_store_barrier(thread); 336 if (can_elide_initializing_store_barrier(new_obj)) { 337 // The deferred_card_mark region should be empty 338 // following the flush above. 339 assert(thread->deferred_card_mark().is_empty(), "Error"); 340 } else { 341 MemRegion mr((HeapWord*)new_obj, new_obj->size()); 342 assert(!mr.is_empty(), "Error"); 343 if (_defer_initial_card_mark) { 344 // Defer the card mark 345 thread->set_deferred_card_mark(mr); 346 } else { 347 // Do the card mark 348 BarrierSet* bs = barrier_set(); 349 assert(bs->has_write_region_opt(), "No write_region() on BarrierSet"); 350 bs->write_region(mr); 351 } 352 } 353 return new_obj; 354 } 355 356 size_t CollectedHeap::filler_array_hdr_size() { 357 return size_t(align_object_offset(arrayOopDesc::header_size(T_INT))); // align to Long 358 } 359 360 size_t CollectedHeap::filler_array_min_size() { 361 return align_object_size(filler_array_hdr_size()); // align to MinObjAlignment 362 } 363 364 #ifdef ASSERT 365 void CollectedHeap::fill_args_check(HeapWord* start, size_t words) 366 { 367 assert(words >= min_fill_size(), "too small to fill"); 368 assert(words % MinObjAlignment == 0, "unaligned size"); 369 assert(Universe::heap()->is_in_reserved(start), "not in heap"); 370 assert(Universe::heap()->is_in_reserved(start + words - 1), "not in heap"); 371 } 372 373 void CollectedHeap::zap_filler_array(HeapWord* start, size_t words, bool zap) 374 { 375 if (ZapFillerObjects && zap) { 376 Copy::fill_to_words(start + filler_array_hdr_size(), 377 words - filler_array_hdr_size(), 0XDEAFBABE); 378 } 379 } 380 #endif // ASSERT 381 382 void 383 CollectedHeap::fill_with_array(HeapWord* start, size_t words, bool zap) 384 { 385 assert(words >= filler_array_min_size(), "too small for an array"); 386 assert(words <= filler_array_max_size(), "too big for a single object"); 387 388 const size_t payload_size = words - filler_array_hdr_size(); 389 const size_t len = payload_size * HeapWordSize / sizeof(jint); 390 assert((int)len >= 0, err_msg("size too large " SIZE_FORMAT " becomes %d", words, (int)len)); 391 392 // Set the length first for concurrent GC. 393 ((arrayOop)start)->set_length((int)len); 394 post_allocation_setup_common(Universe::intArrayKlassObj(), start); 395 DEBUG_ONLY(zap_filler_array(start, words, zap);) 396 } 397 398 void 399 CollectedHeap::fill_with_object_impl(HeapWord* start, size_t words, bool zap) 400 { 401 assert(words <= filler_array_max_size(), "too big for a single object"); 402 403 if (words >= filler_array_min_size()) { 404 fill_with_array(start, words, zap); 405 } else if (words > 0) { 406 assert(words == min_fill_size(), "unaligned size"); 407 post_allocation_setup_common(SystemDictionary::Object_klass(), start); 408 } 409 } 410 411 void CollectedHeap::fill_with_object(HeapWord* start, size_t words, bool zap) 412 { 413 DEBUG_ONLY(fill_args_check(start, words);) 414 HandleMark hm; // Free handles before leaving. 415 fill_with_object_impl(start, words, zap); 416 } 417 418 void CollectedHeap::fill_with_objects(HeapWord* start, size_t words, bool zap) 419 { 420 DEBUG_ONLY(fill_args_check(start, words);) 421 HandleMark hm; // Free handles before leaving. 422 423 #ifdef _LP64 424 // A single array can fill ~8G, so multiple objects are needed only in 64-bit. 425 // First fill with arrays, ensuring that any remaining space is big enough to 426 // fill. The remainder is filled with a single object. 427 const size_t min = min_fill_size(); 428 const size_t max = filler_array_max_size(); 429 while (words > max) { 430 const size_t cur = words - max >= min ? max : max - min; 431 fill_with_array(start, cur, zap); 432 start += cur; 433 words -= cur; 434 } 435 #endif 436 437 fill_with_object_impl(start, words, zap); 438 } 439 440 HeapWord* CollectedHeap::allocate_new_tlab(size_t size) { 441 guarantee(false, "thread-local allocation buffers not supported"); 442 return NULL; 443 } 444 445 void CollectedHeap::ensure_parsability(bool retire_tlabs) { 446 // The second disjunct in the assertion below makes a concession 447 // for the start-up verification done while the VM is being 448 // created. Callers be careful that you know that mutators 449 // aren't going to interfere -- for instance, this is permissible 450 // if we are still single-threaded and have either not yet 451 // started allocating (nothing much to verify) or we have 452 // started allocating but are now a full-fledged JavaThread 453 // (and have thus made our TLAB's) available for filling. 454 assert(SafepointSynchronize::is_at_safepoint() || 455 !is_init_completed(), 456 "Should only be called at a safepoint or at start-up" 457 " otherwise concurrent mutator activity may make heap " 458 " unparsable again"); 459 const bool use_tlab = UseTLAB; 460 const bool deferred = _defer_initial_card_mark; 461 // The main thread starts allocating via a TLAB even before it 462 // has added itself to the threads list at vm boot-up. 463 assert(!use_tlab || Threads::first() != NULL, 464 "Attempt to fill tlabs before main thread has been added" 465 " to threads list is doomed to failure!"); 466 for (JavaThread *thread = Threads::first(); thread; thread = thread->next()) { 467 if (use_tlab) thread->tlab().make_parsable(retire_tlabs); 468 #ifdef COMPILER2 469 // The deferred store barriers must all have been flushed to the 470 // card-table (or other remembered set structure) before GC starts 471 // processing the card-table (or other remembered set). 472 if (deferred) flush_deferred_store_barrier(thread); 473 #else 474 assert(!deferred, "Should be false"); 475 assert(thread->deferred_card_mark().is_empty(), "Should be empty"); 476 #endif 477 } 478 } 479 480 void CollectedHeap::accumulate_statistics_all_tlabs() { 481 if (UseTLAB) { 482 assert(SafepointSynchronize::is_at_safepoint() || 483 !is_init_completed(), 484 "should only accumulate statistics on tlabs at safepoint"); 485 486 ThreadLocalAllocBuffer::accumulate_statistics_before_gc(); 487 } 488 } 489 490 void CollectedHeap::resize_all_tlabs() { 491 if (UseTLAB) { 492 assert(SafepointSynchronize::is_at_safepoint() || 493 !is_init_completed(), 494 "should only resize tlabs at safepoint"); 495 496 ThreadLocalAllocBuffer::resize_all_tlabs(); 497 } 498 } 499 500 void CollectedHeap::pre_full_gc_dump(GCTimer* timer) { 501 if (HeapDumpBeforeFullGC) { 502 GCTraceTime tt("Heap Dump (before full gc): ", PrintGCDetails, false, timer); 503 // We are doing a "major" collection and a heap dump before 504 // major collection has been requested. 505 HeapDumper::dump_heap(); 506 } 507 if (PrintClassHistogramBeforeFullGC) { 508 GCTraceTime tt("Class Histogram (before full gc): ", PrintGCDetails, true, timer); 509 VM_GC_HeapInspection inspector(gclog_or_tty, false /* ! full gc */, false /* ! prologue */); 510 inspector.doit(); 511 } 512 } 513 514 void CollectedHeap::post_full_gc_dump(GCTimer* timer) { 515 if (HeapDumpAfterFullGC) { 516 GCTraceTime tt("Heap Dump (after full gc): ", PrintGCDetails, false, timer); 517 HeapDumper::dump_heap(); 518 } 519 if (PrintClassHistogramAfterFullGC) { 520 GCTraceTime tt("Class Histogram (after full gc): ", PrintGCDetails, true, timer); 521 VM_GC_HeapInspection inspector(gclog_or_tty, false /* ! full gc */, false /* ! prologue */); 522 inspector.doit(); 523 } 524 } 525 526 oop CollectedHeap::Class_obj_allocate(KlassHandle klass, int size, KlassHandle real_klass, TRAPS) { 527 debug_only(check_for_valid_allocation_state()); 528 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); 529 assert(size >= 0, "int won't convert to size_t"); 530 HeapWord* obj; 531 if (JavaObjectsInPerm) { 532 obj = common_permanent_mem_allocate_init(size, CHECK_NULL); 533 } else { 534 assert(ScavengeRootsInCode > 0, "must be"); 535 obj = common_mem_allocate_init(real_klass, size, CHECK_NULL); 536 } 537 post_allocation_setup_common(klass, obj); 538 assert(Universe::is_bootstrapping() || 539 !((oop)obj)->blueprint()->oop_is_array(), "must not be an array"); 540 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); 541 oop mirror = (oop)obj; 542 543 java_lang_Class::set_oop_size(mirror, size); 544 545 // Setup indirections 546 if (!real_klass.is_null()) { 547 java_lang_Class::set_klass(mirror, real_klass()); 548 real_klass->set_java_mirror(mirror); 549 } 550 551 instanceMirrorKlass* mk = instanceMirrorKlass::cast(mirror->klass()); 552 assert(size == mk->instance_size(real_klass), "should have been set"); 553 554 // notify jvmti and dtrace 555 post_allocation_notify(klass, (oop)obj); 556 557 return mirror; 558 } 559 560 /////////////// Unit tests /////////////// 561 562 #ifndef PRODUCT 563 void CollectedHeap::test_is_in() { 564 CollectedHeap* heap = Universe::heap(); 565 566 uintptr_t epsilon = (uintptr_t) MinObjAlignment; 567 uintptr_t heap_start = (uintptr_t) heap->_reserved.start(); 568 uintptr_t heap_end = (uintptr_t) heap->_reserved.end(); 569 570 // Test that NULL is not in the heap. 571 assert(!heap->is_in(NULL), "NULL is unexpectedly in the heap"); 572 573 // Test that a pointer to before the heap start is reported as outside the heap. 574 assert(heap_start >= ((uintptr_t)NULL + epsilon), "sanity"); 575 void* before_heap = (void*)(heap_start - epsilon); 576 assert(!heap->is_in(before_heap), 577 err_msg("before_heap: " PTR_FORMAT " is unexpectedly in the heap", before_heap)); 578 579 // Test that a pointer to after the heap end is reported as outside the heap. 580 assert(heap_end <= ((uintptr_t)-1 - epsilon), "sanity"); 581 void* after_heap = (void*)(heap_end + epsilon); 582 assert(!heap->is_in(after_heap), 583 err_msg("after_heap: " PTR_FORMAT " is unexpectedly in the heap", after_heap)); 584 } 585 #endif