11/*
2- * Copyright (c) 2001, 2020 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2001, 2021 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
3434
3535class PSOldGen : public CHeapObj <mtGC> {
3636 friend class VMStructs ;
37- friend class PSPromotionManager ; // Uses the cas_allocate methods
38- friend class ParallelScavengeHeap ;
39- friend class AdjoiningGenerations ;
4037
4138 private:
4239 MemRegion _reserved; // Used for simple containment tests
@@ -72,22 +69,8 @@ class PSOldGen : public CHeapObj<mtGC> {
7269 }
7370#endif
7471
75- HeapWord* allocate_noexpand (size_t word_size) {
76- // We assume the heap lock is held here.
77- assert_locked_or_safepoint (Heap_lock);
78- HeapWord* res = object_space ()->allocate (word_size);
79- if (res != NULL ) {
80- DEBUG_ONLY (assert_block_in_covered_region (MemRegion (res, word_size)));
81- _start_array.allocate_block (res);
82- }
83- return res;
84- }
85-
86- // Support for MT garbage collection. CAS allocation is lower overhead than grabbing
87- // and releasing the heap lock, which is held during gc's anyway. This method is not
88- // safe for use at the same time as allocate_noexpand()!
8972 HeapWord* cas_allocate_noexpand (size_t word_size) {
90- assert ( SafepointSynchronize::is_at_safepoint (), " Must only be called at safepoint " );
73+ assert_locked_or_safepoint (Heap_lock );
9174 HeapWord* res = object_space ()->cas_allocate (word_size);
9275 if (res != NULL ) {
9376 DEBUG_ONLY (assert_block_in_covered_region (MemRegion (res, word_size)));
@@ -96,13 +79,6 @@ class PSOldGen : public CHeapObj<mtGC> {
9679 return res;
9780 }
9881
99- // Support for MT garbage collection. See above comment.
100- HeapWord* cas_allocate (size_t word_size) {
101- HeapWord* res = cas_allocate_noexpand (word_size);
102- return (res == NULL ) ? expand_and_cas_allocate (word_size) : res;
103- }
104-
105- HeapWord* expand_and_allocate (size_t word_size);
10682 HeapWord* expand_and_cas_allocate (size_t word_size);
10783 void expand (size_t bytes);
10884 bool expand_by (size_t bytes);
@@ -158,9 +134,10 @@ class PSOldGen : public CHeapObj<mtGC> {
158134 // Calculating new sizes
159135 void resize (size_t desired_free_space);
160136
161- // Allocation. We report all successful allocations to the size policy
162- // Note that the perm gen does not use this method, and should not!
163- HeapWord* allocate (size_t word_size);
137+ HeapWord* allocate (size_t word_size) {
138+ HeapWord* res = cas_allocate_noexpand (word_size);
139+ return (res == NULL ) ? expand_and_cas_allocate (word_size) : res;
140+ }
164141
165142 // Iteration.
166143 void oop_iterate (OopIterateClosure* cl) { object_space ()->oop_iterate (cl); }
0 commit comments