8296776: Stop using mtNone as marker for CHeap allocations in Growabl… · openjdk/jdk@8265491 (original) (raw)

`@@ -599,29 +599,40 @@ class GrowableArrayMetadata {

`

599

599

`// resource area nesting at creation

`

600

600

`debug_only(GrowableArrayNestingCheck _nesting_check;)

`

601

601

``

602

``

`-

uintptr_t bits(MEMFLAGS memflags) const {

`

603

``

`-

if (memflags == mtNone) {

`

604

``

`-

// Stack allocation

`

605

``

`-

return 0;

`

606

``

`-

}

`

``

602

`+

// Resource allocation

`

``

603

`+

static uintptr_t bits() {

`

``

604

`+

return 0;

`

``

605

`+

}

`

607

606

``

608

``

`-

// CHeap allocation

`

``

607

`+

// CHeap allocation

`

``

608

`+

static uintptr_t bits(MEMFLAGS memflags) {

`

``

609

`+

assert(memflags != mtNone, "Must provide a proper MEMFLAGS");

`

609

610

`return (uintptr_t(memflags) << 1) | 1;

`

610

611

` }

`

611

612

``

612

``

`-

uintptr_t bits(Arena* arena) const {

`

``

613

`+

// Arena allocation

`

``

614

`+

static uintptr_t bits(Arena* arena) {

`

``

615

`+

assert((uintptr_t(arena) & 1) == 0, "Required for on_C_heap() to work");

`

613

616

`return uintptr_t(arena);

`

614

617

` }

`

615

618

``

616

619

`public:

`

``

620

`+

// Resource allocation

`

``

621

`+

GrowableArrayMetadata() :

`

``

622

`+

_bits(bits())

`

``

623

`+

debug_only(COMMA _nesting_check(true)) {

`

``

624

`+

}

`

``

625

+

``

626

`+

// Arena allocation

`

617

627

`GrowableArrayMetadata(Arena* arena) :

`

618

628

` _bits(bits(arena))

`

619

``

`-

debug_only(COMMA _nesting_check(on_stack())) {

`

``

629

`+

debug_only(COMMA _nesting_check(false)) {

`

620

630

` }

`

621

631

``

``

632

`+

// CHeap allocation

`

622

633

`GrowableArrayMetadata(MEMFLAGS memflags) :

`

623

634

` _bits(bits(memflags))

`

624

``

`-

debug_only(COMMA _nesting_check(on_stack())) {

`

``

635

`+

debug_only(COMMA _nesting_check(false)) {

`

625

636

` }

`

626

637

``

627

638

`#ifdef ASSERT

`

`@@ -655,8 +666,8 @@ class GrowableArrayMetadata {

`

655

666

`// THE GrowableArray.

`

656

667

`//

`

657

668

`// Supports multiple allocation strategies:

`

658

``

`-

// - Resource stack allocation: if memflags == mtNone

`

659

``

`-

// - CHeap allocation: if memflags != mtNone

`

``

669

`+

// - Resource stack allocation: if no extra argument is provided

`

``

670

`+

// - CHeap allocation: if memflags is provided

`

660

671

`// - Arena allocation: if an arena is provided

`

661

672

`//

`

662

673

`// There are some drawbacks of using GrowableArray, that are removed in some

`

`@@ -679,11 +690,7 @@ class GrowableArray : public GrowableArrayWithAllocator<E, GrowableArray > {

`

679

690

` }

`

680

691

``

681

692

`static E* allocate(int max, MEMFLAGS memflags) {

`

682

``

`-

if (memflags != mtNone) {

`

683

``

`-

return (E*)GrowableArrayCHeapAllocator::allocate(max, sizeof(E), memflags);

`

684

``

`-

}

`

685

``

-

686

``

`-

return (E*)GrowableArrayResourceAllocator::allocate(max, sizeof(E));

`

``

693

`+

return (E*)GrowableArrayCHeapAllocator::allocate(max, sizeof(E), memflags);

`

687

694

` }

`

688

695

``

689

696

`static E* allocate(int max, Arena* arena) {

`

`@@ -720,15 +727,33 @@ class GrowableArray : public GrowableArrayWithAllocator<E, GrowableArray > {

`

720

727

` }

`

721

728

``

722

729

`public:

`

723

``

`-

GrowableArray(int initial_capacity = 2, MEMFLAGS memflags = mtNone) :

`

``

730

`+

GrowableArray() : GrowableArray(2 /* initial_capacity */) {}

`

``

731

+

``

732

`+

explicit GrowableArray(int initial_capacity) :

`

``

733

`+

GrowableArrayWithAllocator<E, GrowableArray >(

`

``

734

`+

allocate(initial_capacity),

`

``

735

`+

initial_capacity),

`

``

736

`+

_metadata() {

`

``

737

`+

init_checks();

`

``

738

`+

}

`

``

739

+

``

740

`+

GrowableArray(int initial_capacity, MEMFLAGS memflags) :

`

724

741

` GrowableArrayWithAllocator<E, GrowableArray >(

`

725

742

`allocate(initial_capacity, memflags),

`

726

743

` initial_capacity),

`

727

744

` _metadata(memflags) {

`

728

745

`init_checks();

`

729

746

` }

`

730

747

``

731

``

`-

GrowableArray(int initial_capacity, int initial_len, const E& filler, MEMFLAGS memflags = mtNone) :

`

``

748

`+

GrowableArray(int initial_capacity, int initial_len, const E& filler) :

`

``

749

`+

GrowableArrayWithAllocator<E, GrowableArray >(

`

``

750

`+

allocate(initial_capacity),

`

``

751

`+

initial_capacity, initial_len, filler),

`

``

752

`+

_metadata() {

`

``

753

`+

init_checks();

`

``

754

`+

}

`

``

755

+

``

756

`+

GrowableArray(int initial_capacity, int initial_len, const E& filler, MEMFLAGS memflags) :

`

732

757

` GrowableArrayWithAllocator<E, GrowableArray >(

`

733

758

`allocate(initial_capacity, memflags),

`

734

759

` initial_capacity, initial_len, filler),

`