Skip to content

Commit ea2c447

Browse files
author
Kim Barrett
committed
8259778: Merge MutableSpace and ImmutableSpace
Reviewed-by: sspitsyn, dholmes, tschatzl
1 parent 251c641 commit ea2c447

File tree

8 files changed

+68
-275
lines changed

8 files changed

+68
-275
lines changed

src/hotspot/share/gc/parallel/immutableSpace.cpp

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/hotspot/share/gc/parallel/immutableSpace.hpp

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/hotspot/share/gc/parallel/mutableSpace.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@
3535
#include "utilities/align.hpp"
3636
#include "utilities/macros.hpp"
3737

38-
MutableSpace::MutableSpace(size_t alignment): ImmutableSpace(), _alignment(alignment), _top(NULL) {
38+
MutableSpace::MutableSpace(size_t alignment) :
39+
_mangler(NULL),
40+
_last_setup_region(),
41+
_alignment(alignment),
42+
_bottom(NULL),
43+
_top(NULL),
44+
_end(NULL)
45+
{
3946
assert(MutableSpace::alignment() % os::vm_page_size() == 0,
4047
"Space should be aligned");
4148
_mangler = new MutableSpaceMangler(this);

src/hotspot/share/gc/parallel/mutableSpace.hpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,40 @@
2525
#ifndef SHARE_GC_PARALLEL_MUTABLESPACE_HPP
2626
#define SHARE_GC_PARALLEL_MUTABLESPACE_HPP
2727

28-
#include "gc/parallel/immutableSpace.hpp"
28+
#include "memory/allocation.hpp"
29+
#include "memory/iterator.hpp"
2930
#include "memory/memRegion.hpp"
3031
#include "utilities/copy.hpp"
32+
#include "utilities/globalDefinitions.hpp"
33+
#include "utilities/macros.hpp"
3134

3235
class WorkGang;
3336

34-
// A MutableSpace is a subtype of ImmutableSpace that supports the
35-
// concept of allocation. This includes the concepts that a space may
36-
// be only partially full, and the query methods that go with such
37-
// an assumption. MutableSpace is also responsible for minimizing the
37+
// A MutableSpace supports the concept of allocation. This includes the
38+
// concepts that a space may be only partially full, and the query methods
39+
// that go with such an assumption.
40+
//
41+
// MutableSpace is also responsible for minimizing the
3842
// page allocation time by having the memory pretouched (with
3943
// AlwaysPretouch) and for optimizing page placement on NUMA systems
4044
// by make the underlying region interleaved (with UseNUMA).
4145
//
42-
// Invariant: (ImmutableSpace +) bottom() <= top() <= end()
43-
// top() is inclusive and end() is exclusive.
46+
// Invariant: bottom() <= top() <= end()
47+
// top() and end() are exclusive.
4448

4549
class MutableSpaceMangler;
4650

47-
class MutableSpace: public ImmutableSpace {
51+
class MutableSpace: public CHeapObj<mtGC> {
4852
friend class VMStructs;
4953

5054
// Helper for mangling unused space in debug builds
5155
MutableSpaceMangler* _mangler;
5256
// The last region which page had been setup to be interleaved.
5357
MemRegion _last_setup_region;
5458
size_t _alignment;
55-
protected:
59+
HeapWord* _bottom;
5660
HeapWord* volatile _top;
61+
HeapWord* _end;
5762

5863
MutableSpaceMangler* mangler() { return _mangler; }
5964

@@ -67,17 +72,25 @@ class MutableSpace: public ImmutableSpace {
6772
MutableSpace(size_t page_size);
6873

6974
// Accessors
75+
HeapWord* bottom() const { return _bottom; }
7076
HeapWord* top() const { return _top; }
77+
HeapWord* end() const { return _end; }
78+
79+
void set_bottom(HeapWord* value) { _bottom = value; }
7180
virtual void set_top(HeapWord* value) { _top = value; }
81+
void set_end(HeapWord* value) { _end = value; }
7282

7383
HeapWord* volatile* top_addr() { return &_top; }
7484
HeapWord** end_addr() { return &_end; }
7585

76-
virtual void set_bottom(HeapWord* value) { _bottom = value; }
77-
virtual void set_end(HeapWord* value) { _end = value; }
78-
7986
size_t alignment() { return _alignment; }
8087

88+
MemRegion region() const { return MemRegion(bottom(), end()); }
89+
90+
size_t capacity_in_bytes() const { return capacity_in_words() * HeapWordSize; }
91+
size_t capacity_in_words() const { return pointer_delta(end(), bottom()); }
92+
virtual size_t capacity_in_words(Thread*) const { return capacity_in_words(); }
93+
8194
// Returns a subregion containing all objects in this space.
8295
MemRegion used_region() { return MemRegion(bottom(), top()); }
8396

@@ -92,10 +105,6 @@ class MutableSpace: public ImmutableSpace {
92105
WorkGang* pretouch_gang = NULL);
93106

94107
virtual void clear(bool mangle_space);
95-
// Does the usual initialization but optionally resets top to bottom.
96-
#if 0 // MANGLE_SPACE
97-
void initialize(MemRegion mr, bool clear_space, bool reset_top);
98-
#endif
99108
virtual void update() { }
100109
virtual void accumulate_statistics() { }
101110

src/hotspot/share/gc/parallel/spaceCounters.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 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
@@ -25,7 +25,6 @@
2525
#ifndef SHARE_GC_PARALLEL_SPACECOUNTERS_HPP
2626
#define SHARE_GC_PARALLEL_SPACECOUNTERS_HPP
2727

28-
#include "gc/parallel/immutableSpace.hpp"
2928
#include "gc/parallel/mutableSpace.hpp"
3029
#include "gc/shared/generationCounters.hpp"
3130
#include "runtime/perfData.hpp"

src/hotspot/share/gc/parallel/vmStructs_parallelgc.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 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
@@ -25,7 +25,6 @@
2525
#ifndef SHARE_GC_PARALLEL_VMSTRUCTS_PARALLELGC_HPP
2626
#define SHARE_GC_PARALLEL_VMSTRUCTS_PARALLELGC_HPP
2727

28-
#include "gc/parallel/immutableSpace.hpp"
2928
#include "gc/parallel/mutableSpace.hpp"
3029
#include "gc/parallel/parallelScavengeHeap.hpp"
3130
#include "gc/parallel/psOldGen.hpp"
@@ -46,9 +45,8 @@
4645
nonstatic_field(PSVirtualSpace, _committed_low_addr, char*) \
4746
nonstatic_field(PSVirtualSpace, _committed_high_addr, char*) \
4847
\
49-
nonstatic_field(ImmutableSpace, _bottom, HeapWord*) \
50-
nonstatic_field(ImmutableSpace, _end, HeapWord*) \
51-
\
48+
nonstatic_field(MutableSpace, _bottom, HeapWord*) \
49+
nonstatic_field(MutableSpace, _end, HeapWord*) \
5250
volatile_nonstatic_field(MutableSpace, _top, HeapWord*) \
5351
\
5452
nonstatic_field(PSYoungGen, _reserved, MemRegion) \
@@ -81,8 +79,7 @@
8179
declare_type(ParallelScavengeHeap, CollectedHeap) \
8280
\
8381
declare_toplevel_type(PSVirtualSpace) \
84-
declare_toplevel_type(ImmutableSpace) \
85-
declare_type(MutableSpace, ImmutableSpace) \
82+
declare_toplevel_type(MutableSpace) \
8683
declare_toplevel_type(PSYoungGen) \
8784
declare_toplevel_type(PSOldGen) \
8885
\
@@ -91,7 +88,6 @@
9188
/*****************************/ \
9289
\
9390
declare_toplevel_type(PSVirtualSpace*) \
94-
declare_toplevel_type(ImmutableSpace*) \
9591
declare_toplevel_type(MutableSpace*) \
9692
declare_toplevel_type(PSYoungGen*) \
9793
declare_toplevel_type(PSOldGen*) \

0 commit comments

Comments
 (0)