Skip to content

Commit 196d021

Browse files
committed
8297020: Rename GrowableArray::on_stack
Reviewed-by: stuefe, coleenp
1 parent 5f51dff commit 196d021

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/hotspot/share/utilities/growableArray.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ void GrowableArrayCHeapAllocator::deallocate(void* elements) {
5757

5858
#ifdef ASSERT
5959

60-
GrowableArrayNestingCheck::GrowableArrayNestingCheck(bool on_stack) :
61-
_nesting(on_stack ? Thread::current()->resource_area()->nesting() : 0) {
60+
GrowableArrayNestingCheck::GrowableArrayNestingCheck(bool on_resource_area) :
61+
_nesting(on_resource_area ? Thread::current()->resource_area()->nesting() : 0) {
6262
}
6363

64-
void GrowableArrayNestingCheck::on_stack_alloc() const {
64+
void GrowableArrayNestingCheck::on_resource_area_alloc() const {
6565
// Check for insidious allocation bug: if a GrowableArray overflows, the
6666
// grown array must be allocated under the same ResourceMark as the original.
6767
// Otherwise, the _data array will be deallocated too early.
@@ -79,14 +79,14 @@ void GrowableArrayMetadata::init_checks(const GrowableArrayBase* array) const {
7979
// Otherwise there's a strict one-to-one mapping
8080
assert(on_C_heap() == array->allocated_on_C_heap(),
8181
"growable array must be C heap allocated if elements are");
82-
assert(on_stack() == array->allocated_on_res_area(),
82+
assert(on_resource_area() == array->allocated_on_res_area(),
8383
"growable array must be resource allocated if elements are");
8484
assert(on_arena() == array->allocated_on_arena(),
8585
"growable array must be arena allocated if elements are");
8686
}
8787

88-
void GrowableArrayMetadata::on_stack_alloc_check() const {
89-
_nesting_check.on_stack_alloc();
88+
void GrowableArrayMetadata::on_resource_area_alloc_check() const {
89+
_nesting_check.on_resource_area_alloc();
9090
}
9191

9292
#endif // ASSERT

src/hotspot/share/utilities/growableArray.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,9 @@ class GrowableArrayNestingCheck {
584584
int _nesting;
585585

586586
public:
587-
GrowableArrayNestingCheck(bool on_stack);
587+
GrowableArrayNestingCheck(bool on_resource_area);
588588

589-
void on_stack_alloc() const;
589+
void on_resource_area_alloc() const;
590590
};
591591

592592
#endif // ASSERT
@@ -652,12 +652,12 @@ class GrowableArrayMetadata {
652652
}
653653

654654
void init_checks(const GrowableArrayBase* array) const;
655-
void on_stack_alloc_check() const;
655+
void on_resource_area_alloc_check() const;
656656
#endif // ASSERT
657657

658-
bool on_C_heap() const { return (_bits & 1) == 1; }
659-
bool on_stack () const { return _bits == 0; }
660-
bool on_arena () const { return (_bits & 1) == 0 && _bits != 0; }
658+
bool on_C_heap() const { return (_bits & 1) == 1; }
659+
bool on_resource_area() const { return _bits == 0; }
660+
bool on_arena() const { return (_bits & 1) == 0 && _bits != 0; }
661661

662662
Arena* arena() const { return (Arena*)_bits; }
663663
MEMFLAGS memflags() const { return MEMFLAGS(_bits >> 1); }
@@ -702,13 +702,13 @@ class GrowableArray : public GrowableArrayWithAllocator<E, GrowableArray<E> > {
702702
void init_checks() const { debug_only(_metadata.init_checks(this);) }
703703

704704
// Where are we going to allocate memory?
705-
bool on_C_heap() const { return _metadata.on_C_heap(); }
706-
bool on_stack () const { return _metadata.on_stack(); }
707-
bool on_arena () const { return _metadata.on_arena(); }
705+
bool on_C_heap() const { return _metadata.on_C_heap(); }
706+
bool on_resource_area() const { return _metadata.on_resource_area(); }
707+
bool on_arena() const { return _metadata.on_arena(); }
708708

709709
E* allocate() {
710-
if (on_stack()) {
711-
debug_only(_metadata.on_stack_alloc_check());
710+
if (on_resource_area()) {
711+
debug_only(_metadata.on_resource_area_alloc_check());
712712
return allocate(this->_capacity);
713713
}
714714

test/hotspot/gtest/utilities/test_growableArray.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class GrowableArrayTest : public ::testing::Test {
5050
return array->on_C_heap();
5151
}
5252
template <typename E>
53-
static bool elements_on_stack(const GrowableArray<E>* array) {
54-
return array->on_stack();
53+
static bool elements_on_resource_area(const GrowableArray<E>* array) {
54+
return array->on_resource_area();
5555
}
5656
template <typename E>
5757
static bool elements_on_arena(const GrowableArray<E>* array) {
@@ -471,7 +471,7 @@ TEST_VM_F(GrowableArrayTest, where) {
471471
ResourceMark rm;
472472
GrowableArray<int>* a = new GrowableArray<int>();
473473
ASSERT_TRUE(a->allocated_on_res_area());
474-
ASSERT_TRUE(elements_on_stack(a));
474+
ASSERT_TRUE(elements_on_resource_area(a));
475475
}
476476

477477
// Resource/CHeap allocated
@@ -499,7 +499,7 @@ TEST_VM_F(GrowableArrayTest, where) {
499499
ResourceMark rm;
500500
GrowableArray<int> a(0);
501501
ASSERT_TRUE(a.allocated_on_stack_or_embedded());
502-
ASSERT_TRUE(elements_on_stack(&a));
502+
ASSERT_TRUE(elements_on_resource_area(&a));
503503
}
504504

505505
// Stack/CHeap allocated
@@ -522,7 +522,7 @@ TEST_VM_F(GrowableArrayTest, where) {
522522
ResourceMark rm;
523523
WithEmbeddedArray w(0);
524524
ASSERT_TRUE(w._a.allocated_on_stack_or_embedded());
525-
ASSERT_TRUE(elements_on_stack(&w._a));
525+
ASSERT_TRUE(elements_on_resource_area(&w._a));
526526
}
527527

528528
// Embedded/CHeap allocated

0 commit comments

Comments
 (0)