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 "gc/cms/cmsLockVerifier.hpp"
27 #include "gc/cms/compactibleFreeListSpace.hpp"
28 #include "gc/cms/concurrentMarkSweepGeneration.inline.hpp"
29 #include "gc/cms/concurrentMarkSweepThread.hpp"
30 #include "gc/shared/blockOffsetTable.inline.hpp"
31 #include "gc/shared/collectedHeap.inline.hpp"
32 #include "gc/shared/genCollectedHeap.hpp"
33 #include "gc/shared/liveRange.hpp"
34 #include "gc/shared/space.inline.hpp"
35 #include "gc/shared/spaceDecorator.hpp"
36 #include "memory/allocation.inline.hpp"
37 #include "memory/resourceArea.hpp"
38 #include "memory/universe.inline.hpp"
39 #include "oops/oop.inline.hpp"
40 #include "runtime/globals.hpp"
41 #include "runtime/handles.inline.hpp"
42 #include "runtime/init.hpp"
43 #include "runtime/java.hpp"
44 #include "runtime/orderAccess.inline.hpp"
45 #include "runtime/vmThread.hpp"
46 #include "utilities/copy.hpp"
47
48 /////////////////////////////////////////////////////////////////////////
49 //// CompactibleFreeListSpace
50 /////////////////////////////////////////////////////////////////////////
51
52 // highest ranked free list lock rank
53 int CompactibleFreeListSpace::_lockRank = Mutex::leaf + 3;
54
55 // Defaults are 0 so things will break badly if incorrectly initialized.
1914 void CompactibleFreeListSpace::refillLinearAllocBlocksIfNeeded() {
1915 assert_locked();
1916 if (_smallLinearAllocBlock._ptr == NULL) {
1917 assert(_smallLinearAllocBlock._word_size == 0,
1918 "Size of linAB should be zero if the ptr is NULL");
1919 // Reset the linAB refill and allocation size limit.
1920 _smallLinearAllocBlock.set(0, 0, 1024*SmallForLinearAlloc, SmallForLinearAlloc);
1921 }
1922 refillLinearAllocBlockIfNeeded(&_smallLinearAllocBlock);
1923 }
1924
1925 void
1926 CompactibleFreeListSpace::refillLinearAllocBlockIfNeeded(LinearAllocBlock* blk) {
1927 assert_locked();
1928 assert((blk->_ptr == NULL && blk->_word_size == 0) ||
1929 (blk->_ptr != NULL && blk->_word_size >= MinChunkSize),
1930 "blk invariant");
1931 if (blk->_ptr == NULL) {
1932 refillLinearAllocBlock(blk);
1933 }
1934 if (PrintMiscellaneous && Verbose) {
1935 if (blk->_word_size == 0) {
1936 warning("CompactibleFreeListSpace(prologue):: Linear allocation failure");
1937 }
1938 }
1939 }
1940
1941 void
1942 CompactibleFreeListSpace::refillLinearAllocBlock(LinearAllocBlock* blk) {
1943 assert_locked();
1944 assert(blk->_word_size == 0 && blk->_ptr == NULL,
1945 "linear allocation block should be empty");
1946 FreeChunk* fc;
1947 if (blk->_refillSize < SmallForDictionary &&
1948 (fc = getChunkFromIndexedFreeList(blk->_refillSize)) != NULL) {
1949 // A linAB's strategy might be to use small sizes to reduce
1950 // fragmentation but still get the benefits of allocation from a
1951 // linAB.
1952 } else {
1953 fc = getChunkFromDictionary(blk->_refillSize);
1954 }
1955 if (fc != NULL) {
1956 blk->_ptr = (HeapWord*)fc;
1957 blk->_word_size = fc->size();
|
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 "gc/cms/cmsLockVerifier.hpp"
27 #include "gc/cms/compactibleFreeListSpace.hpp"
28 #include "gc/cms/concurrentMarkSweepGeneration.inline.hpp"
29 #include "gc/cms/concurrentMarkSweepThread.hpp"
30 #include "gc/shared/blockOffsetTable.inline.hpp"
31 #include "gc/shared/collectedHeap.inline.hpp"
32 #include "gc/shared/genCollectedHeap.hpp"
33 #include "gc/shared/liveRange.hpp"
34 #include "gc/shared/space.inline.hpp"
35 #include "gc/shared/spaceDecorator.hpp"
36 #include "logging/log.hpp"
37 #include "memory/allocation.inline.hpp"
38 #include "memory/resourceArea.hpp"
39 #include "memory/universe.inline.hpp"
40 #include "oops/oop.inline.hpp"
41 #include "runtime/globals.hpp"
42 #include "runtime/handles.inline.hpp"
43 #include "runtime/init.hpp"
44 #include "runtime/java.hpp"
45 #include "runtime/orderAccess.inline.hpp"
46 #include "runtime/vmThread.hpp"
47 #include "utilities/copy.hpp"
48
49 /////////////////////////////////////////////////////////////////////////
50 //// CompactibleFreeListSpace
51 /////////////////////////////////////////////////////////////////////////
52
53 // highest ranked free list lock rank
54 int CompactibleFreeListSpace::_lockRank = Mutex::leaf + 3;
55
56 // Defaults are 0 so things will break badly if incorrectly initialized.
1915 void CompactibleFreeListSpace::refillLinearAllocBlocksIfNeeded() {
1916 assert_locked();
1917 if (_smallLinearAllocBlock._ptr == NULL) {
1918 assert(_smallLinearAllocBlock._word_size == 0,
1919 "Size of linAB should be zero if the ptr is NULL");
1920 // Reset the linAB refill and allocation size limit.
1921 _smallLinearAllocBlock.set(0, 0, 1024*SmallForLinearAlloc, SmallForLinearAlloc);
1922 }
1923 refillLinearAllocBlockIfNeeded(&_smallLinearAllocBlock);
1924 }
1925
1926 void
1927 CompactibleFreeListSpace::refillLinearAllocBlockIfNeeded(LinearAllocBlock* blk) {
1928 assert_locked();
1929 assert((blk->_ptr == NULL && blk->_word_size == 0) ||
1930 (blk->_ptr != NULL && blk->_word_size >= MinChunkSize),
1931 "blk invariant");
1932 if (blk->_ptr == NULL) {
1933 refillLinearAllocBlock(blk);
1934 }
1935 if (blk->_word_size == 0) {
1936 log_debug(gc, freelist)("CompactibleFreeListSpace:: Linear allocation failure");
1937 }
1938 }
1939
1940 void
1941 CompactibleFreeListSpace::refillLinearAllocBlock(LinearAllocBlock* blk) {
1942 assert_locked();
1943 assert(blk->_word_size == 0 && blk->_ptr == NULL,
1944 "linear allocation block should be empty");
1945 FreeChunk* fc;
1946 if (blk->_refillSize < SmallForDictionary &&
1947 (fc = getChunkFromIndexedFreeList(blk->_refillSize)) != NULL) {
1948 // A linAB's strategy might be to use small sizes to reduce
1949 // fragmentation but still get the benefits of allocation from a
1950 // linAB.
1951 } else {
1952 fc = getChunkFromDictionary(blk->_refillSize);
1953 }
1954 if (fc != NULL) {
1955 blk->_ptr = (HeapWord*)fc;
1956 blk->_word_size = fc->size();
|