Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/concurrentMarkSweep/freeChunk.hpp @ 9693:d04944441454
cleaned up and simplified runtime call mechanisms
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 14 May 2013 21:33:37 +0200 |
parents | 685df3c6f84b |
children |
rev | line source |
---|---|
187 | 1 /* |
6842
b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
6028
diff
changeset
|
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
187 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1145
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1145
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1145
diff
changeset
|
21 * questions. |
187 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_FREECHUNK_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_FREECHUNK_HPP | |
27 | |
28 #include "memory/allocation.hpp" | |
29 #include "memory/memRegion.hpp" | |
30 #include "oops/markOop.hpp" | |
31 #include "runtime/mutex.hpp" | |
32 #include "utilities/debug.hpp" | |
33 #include "utilities/globalDefinitions.hpp" | |
34 #include "utilities/ostream.hpp" | |
35 | |
187 | 36 // |
37 // Free block maintenance for Concurrent Mark Sweep Generation | |
38 // | |
39 // The main data structure for free blocks are | |
40 // . an indexed array of small free blocks, and | |
41 // . a dictionary of large free blocks | |
42 // | |
43 | |
44 // No virtuals in FreeChunk (don't want any vtables). | |
45 | |
46 // A FreeChunk is merely a chunk that can be in a doubly linked list | |
47 // and has a size field. NOTE: FreeChunks are distinguished from allocated | |
48 // objects in two ways (by the sweeper), depending on whether the VM is 32 or | |
49 // 64 bits. | |
50 // In 32 bits or 64 bits without CompressedOops, the second word (prev) has the | |
51 // LSB set to indicate a free chunk; allocated objects' klass() pointers | |
52 // don't have their LSB set. The corresponding bit in the CMSBitMap is | |
53 // set when the chunk is allocated. There are also blocks that "look free" | |
54 // but are not part of the free list and should not be coalesced into larger | |
55 // free blocks. These free blocks have their two LSB's set. | |
56 | |
57 class FreeChunk VALUE_OBJ_CLASS_SPEC { | |
58 friend class VMStructs; | |
59 // For 64 bit compressed oops, the markOop encodes both the size and the | |
60 // indication that this is a FreeChunk and not an object. | |
61 volatile size_t _size; | |
62 FreeChunk* _prev; | |
63 FreeChunk* _next; | |
64 | |
65 markOop mark() const volatile { return (markOop)_size; } | |
66 void set_mark(markOop m) { _size = (size_t)m; } | |
67 | |
68 public: | |
69 NOT_PRODUCT(static const size_t header_size();) | |
70 | |
71 // Returns "true" if the address indicates that the block represents | |
72 // a free chunk. | |
73 static bool indicatesFreeChunk(const HeapWord* addr) { | |
74 // Force volatile read from addr because value might change between | |
75 // calls. We really want the read of _mark and _prev from this pointer | |
76 // to be volatile but making the fields volatile causes all sorts of | |
77 // compilation errors. | |
6028
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
78 return ((volatile FreeChunk*)addr)->is_free(); |
187 | 79 } |
80 | |
6028
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
81 bool is_free() const volatile { |
187 | 82 LP64_ONLY(if (UseCompressedOops) return mark()->is_cms_free_chunk(); else) |
83 return (((intptr_t)_prev) & 0x1) == 0x1; | |
84 } | |
85 bool cantCoalesce() const { | |
6028
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
86 assert(is_free(), "can't get coalesce bit on not free"); |
187 | 87 return (((intptr_t)_prev) & 0x2) == 0x2; |
88 } | |
89 void dontCoalesce() { | |
90 // the block should be free | |
6028
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
91 assert(is_free(), "Should look like a free block"); |
187 | 92 _prev = (FreeChunk*)(((intptr_t)_prev) | 0x2); |
93 } | |
94 FreeChunk* prev() const { | |
95 return (FreeChunk*)(((intptr_t)_prev) & ~(0x3)); | |
96 } | |
97 | |
98 debug_only(void* prev_addr() const { return (void*)&_prev; }) | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
187
diff
changeset
|
99 debug_only(void* next_addr() const { return (void*)&_next; }) |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
187
diff
changeset
|
100 debug_only(void* size_addr() const { return (void*)&_size; }) |
187 | 101 |
102 size_t size() const volatile { | |
103 LP64_ONLY(if (UseCompressedOops) return mark()->get_size(); else ) | |
104 return _size; | |
105 } | |
6028
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
106 void set_size(size_t sz) { |
187 | 107 LP64_ONLY(if (UseCompressedOops) set_mark(markOopDesc::set_size_and_free(sz)); else ) |
108 _size = sz; | |
109 } | |
110 | |
111 FreeChunk* next() const { return _next; } | |
112 | |
6028
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
113 void link_after(FreeChunk* ptr) { |
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
114 link_next(ptr); |
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
115 if (ptr != NULL) ptr->link_prev(this); |
187 | 116 } |
6028
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
117 void link_next(FreeChunk* ptr) { _next = ptr; } |
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
118 void link_prev(FreeChunk* ptr) { |
1716
be3f9c242c9d
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
1579
diff
changeset
|
119 LP64_ONLY(if (UseCompressedOops) _prev = ptr; else) |
be3f9c242c9d
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
1579
diff
changeset
|
120 _prev = (FreeChunk*)((intptr_t)ptr | 0x1); |
187 | 121 } |
6028
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
122 void clear_next() { _next = NULL; } |
187 | 123 void markNotFree() { |
1716
be3f9c242c9d
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
1579
diff
changeset
|
124 // Set _prev (klass) to null before (if) clearing the mark word below |
be3f9c242c9d
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
1579
diff
changeset
|
125 _prev = NULL; |
be3f9c242c9d
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
1579
diff
changeset
|
126 #ifdef _LP64 |
be3f9c242c9d
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
1579
diff
changeset
|
127 if (UseCompressedOops) { |
be3f9c242c9d
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
1579
diff
changeset
|
128 OrderAccess::storestore(); |
be3f9c242c9d
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
1579
diff
changeset
|
129 set_mark(markOopDesc::prototype()); |
be3f9c242c9d
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
1579
diff
changeset
|
130 } |
be3f9c242c9d
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
1579
diff
changeset
|
131 #endif |
6028
f69a5d43dc19
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
3761
diff
changeset
|
132 assert(!is_free(), "Error"); |
187 | 133 } |
134 | |
135 // Return the address past the end of this chunk | |
6885 | 136 uintptr_t* end() const { return ((uintptr_t*) this) + size(); } |
187 | 137 |
138 // debugging | |
139 void verify() const PRODUCT_RETURN; | |
140 void verifyList() const PRODUCT_RETURN; | |
141 void mangleAllocated(size_t size) PRODUCT_RETURN; | |
142 void mangleFreed(size_t size) PRODUCT_RETURN; | |
1145
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
269
diff
changeset
|
143 |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
269
diff
changeset
|
144 void print_on(outputStream* st); |
187 | 145 }; |
146 | |
1571
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
1145
diff
changeset
|
147 extern size_t MinChunkSize; |
187 | 148 |
1972 | 149 |
150 #endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_FREECHUNK_HPP |