comparison src/share/vm/gc_implementation/concurrentMarkSweep/freeChunk.hpp @ 1716:be3f9c242c9d

6948538: CMS: BOT walkers can fall into object allocation and initialization cracks Summary: GC workers now recognize an intermediate transient state of blocks which are allocated but have not yet completed initialization. blk_start() calls do not attempt to determine the size of a block in the transient state, rather waiting for the block to become initialized so that it is safe to query its size. Audited and ensured the order of initialization of object fields (klass, free bit and size) to respect block state transition protocol. Also included some new assertion checking code enabled in debug mode. Reviewed-by: chrisphi, johnc, poonam
author ysr
date Mon, 16 Aug 2010 15:58:42 -0700
parents e9ff18c4ace7
children f95d63e2154a
comparison
equal deleted inserted replaced
1713:7fcd5f39bd7a 1716:be3f9c242c9d
1 /* 1 /*
2 * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2010, 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.
108 linkNext(ptr); 108 linkNext(ptr);
109 ptr->linkPrev(this); 109 ptr->linkPrev(this);
110 } 110 }
111 void linkNext(FreeChunk* ptr) { _next = ptr; } 111 void linkNext(FreeChunk* ptr) { _next = ptr; }
112 void linkPrev(FreeChunk* ptr) { 112 void linkPrev(FreeChunk* ptr) {
113 LP64_ONLY(if (UseCompressedOops) _prev = ptr; else) 113 LP64_ONLY(if (UseCompressedOops) _prev = ptr; else)
114 _prev = (FreeChunk*)((intptr_t)ptr | 0x1); 114 _prev = (FreeChunk*)((intptr_t)ptr | 0x1);
115 } 115 }
116 void clearPrev() { _prev = NULL; } 116 void clearPrev() { _prev = NULL; }
117 void clearNext() { _next = NULL; } 117 void clearNext() { _next = NULL; }
118 void markNotFree() { 118 void markNotFree() {
119 LP64_ONLY(if (UseCompressedOops) set_mark(markOopDesc::prototype());) 119 // Set _prev (klass) to null before (if) clearing the mark word below
120 // Also set _prev to null 120 _prev = NULL;
121 _prev = NULL; 121 #ifdef _LP64
122 if (UseCompressedOops) {
123 OrderAccess::storestore();
124 set_mark(markOopDesc::prototype());
125 }
126 #endif
127 assert(!isFree(), "Error");
122 } 128 }
123 129
124 // Return the address past the end of this chunk 130 // Return the address past the end of this chunk
125 HeapWord* end() const { return ((HeapWord*) this) + size(); } 131 HeapWord* end() const { return ((HeapWord*) this) + size(); }
126 132