1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
34
34
35
35
class PSOldGen : public CHeapObj <mtGC> {
36
36
friend class VMStructs ;
37
- friend class PSPromotionManager ; // Uses the cas_allocate methods
38
- friend class ParallelScavengeHeap ;
39
- friend class AdjoiningGenerations ;
40
37
41
38
private:
42
39
MemRegion _reserved; // Used for simple containment tests
@@ -72,22 +69,8 @@ class PSOldGen : public CHeapObj<mtGC> {
72
69
}
73
70
#endif
74
71
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()!
89
72
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 );
91
74
HeapWord* res = object_space ()->cas_allocate (word_size);
92
75
if (res != NULL ) {
93
76
DEBUG_ONLY (assert_block_in_covered_region (MemRegion (res, word_size)));
@@ -96,13 +79,6 @@ class PSOldGen : public CHeapObj<mtGC> {
96
79
return res;
97
80
}
98
81
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);
106
82
HeapWord* expand_and_cas_allocate (size_t word_size);
107
83
void expand (size_t bytes);
108
84
bool expand_by (size_t bytes);
@@ -158,9 +134,10 @@ class PSOldGen : public CHeapObj<mtGC> {
158
134
// Calculating new sizes
159
135
void resize (size_t desired_free_space);
160
136
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
+ }
164
141
165
142
// Iteration.
166
143
void oop_iterate (OopIterateClosure* cl) { object_space ()->oop_iterate (cl); }
0 commit comments