Skip to content

Commit

Permalink
8259778: Merge MutableSpace and ImmutableSpace
Browse files Browse the repository at this point in the history
Reviewed-by: sspitsyn, dholmes, tschatzl
  • Loading branch information
Kim Barrett committed Jan 29, 2021
1 parent 251c641 commit ea2c447
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 275 deletions.
83 changes: 0 additions & 83 deletions src/hotspot/share/gc/parallel/immutableSpace.cpp

This file was deleted.

71 changes: 0 additions & 71 deletions src/hotspot/share/gc/parallel/immutableSpace.hpp

This file was deleted.

9 changes: 8 additions & 1 deletion src/hotspot/share/gc/parallel/mutableSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@
#include "utilities/align.hpp"
#include "utilities/macros.hpp"

MutableSpace::MutableSpace(size_t alignment): ImmutableSpace(), _alignment(alignment), _top(NULL) {
MutableSpace::MutableSpace(size_t alignment) :
_mangler(NULL),
_last_setup_region(),
_alignment(alignment),
_bottom(NULL),
_top(NULL),
_end(NULL)
{
assert(MutableSpace::alignment() % os::vm_page_size() == 0,
"Space should be aligned");
_mangler = new MutableSpaceMangler(this);
Expand Down
41 changes: 25 additions & 16 deletions src/hotspot/share/gc/parallel/mutableSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,40 @@
#ifndef SHARE_GC_PARALLEL_MUTABLESPACE_HPP
#define SHARE_GC_PARALLEL_MUTABLESPACE_HPP

#include "gc/parallel/immutableSpace.hpp"
#include "memory/allocation.hpp"
#include "memory/iterator.hpp"
#include "memory/memRegion.hpp"
#include "utilities/copy.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"

class WorkGang;

// A MutableSpace is a subtype of ImmutableSpace that supports the
// concept of allocation. This includes the concepts that a space may
// be only partially full, and the query methods that go with such
// an assumption. MutableSpace is also responsible for minimizing the
// A MutableSpace supports the concept of allocation. This includes the
// concepts that a space may be only partially full, and the query methods
// that go with such an assumption.
//
// MutableSpace is also responsible for minimizing the
// page allocation time by having the memory pretouched (with
// AlwaysPretouch) and for optimizing page placement on NUMA systems
// by make the underlying region interleaved (with UseNUMA).
//
// Invariant: (ImmutableSpace +) bottom() <= top() <= end()
// top() is inclusive and end() is exclusive.
// Invariant: bottom() <= top() <= end()
// top() and end() are exclusive.

class MutableSpaceMangler;

class MutableSpace: public ImmutableSpace {
class MutableSpace: public CHeapObj<mtGC> {
friend class VMStructs;

// Helper for mangling unused space in debug builds
MutableSpaceMangler* _mangler;
// The last region which page had been setup to be interleaved.
MemRegion _last_setup_region;
size_t _alignment;
protected:
HeapWord* _bottom;
HeapWord* volatile _top;
HeapWord* _end;

MutableSpaceMangler* mangler() { return _mangler; }

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

// Accessors
HeapWord* bottom() const { return _bottom; }
HeapWord* top() const { return _top; }
HeapWord* end() const { return _end; }

void set_bottom(HeapWord* value) { _bottom = value; }
virtual void set_top(HeapWord* value) { _top = value; }
void set_end(HeapWord* value) { _end = value; }

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

virtual void set_bottom(HeapWord* value) { _bottom = value; }
virtual void set_end(HeapWord* value) { _end = value; }

size_t alignment() { return _alignment; }

MemRegion region() const { return MemRegion(bottom(), end()); }

size_t capacity_in_bytes() const { return capacity_in_words() * HeapWordSize; }
size_t capacity_in_words() const { return pointer_delta(end(), bottom()); }
virtual size_t capacity_in_words(Thread*) const { return capacity_in_words(); }

// Returns a subregion containing all objects in this space.
MemRegion used_region() { return MemRegion(bottom(), top()); }

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

virtual void clear(bool mangle_space);
// Does the usual initialization but optionally resets top to bottom.
#if 0 // MANGLE_SPACE
void initialize(MemRegion mr, bool clear_space, bool reset_top);
#endif
virtual void update() { }
virtual void accumulate_statistics() { }

Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/gc/parallel/spaceCounters.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,7 +25,6 @@
#ifndef SHARE_GC_PARALLEL_SPACECOUNTERS_HPP
#define SHARE_GC_PARALLEL_SPACECOUNTERS_HPP

#include "gc/parallel/immutableSpace.hpp"
#include "gc/parallel/mutableSpace.hpp"
#include "gc/shared/generationCounters.hpp"
#include "runtime/perfData.hpp"
Expand Down
12 changes: 4 additions & 8 deletions src/hotspot/share/gc/parallel/vmStructs_parallelgc.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,7 +25,6 @@
#ifndef SHARE_GC_PARALLEL_VMSTRUCTS_PARALLELGC_HPP
#define SHARE_GC_PARALLEL_VMSTRUCTS_PARALLELGC_HPP

#include "gc/parallel/immutableSpace.hpp"
#include "gc/parallel/mutableSpace.hpp"
#include "gc/parallel/parallelScavengeHeap.hpp"
#include "gc/parallel/psOldGen.hpp"
Expand All @@ -46,9 +45,8 @@
nonstatic_field(PSVirtualSpace, _committed_low_addr, char*) \
nonstatic_field(PSVirtualSpace, _committed_high_addr, char*) \
\
nonstatic_field(ImmutableSpace, _bottom, HeapWord*) \
nonstatic_field(ImmutableSpace, _end, HeapWord*) \
\
nonstatic_field(MutableSpace, _bottom, HeapWord*) \
nonstatic_field(MutableSpace, _end, HeapWord*) \
volatile_nonstatic_field(MutableSpace, _top, HeapWord*) \
\
nonstatic_field(PSYoungGen, _reserved, MemRegion) \
Expand Down Expand Up @@ -81,8 +79,7 @@
declare_type(ParallelScavengeHeap, CollectedHeap) \
\
declare_toplevel_type(PSVirtualSpace) \
declare_toplevel_type(ImmutableSpace) \
declare_type(MutableSpace, ImmutableSpace) \
declare_toplevel_type(MutableSpace) \
declare_toplevel_type(PSYoungGen) \
declare_toplevel_type(PSOldGen) \
\
Expand All @@ -91,7 +88,6 @@
/*****************************/ \
\
declare_toplevel_type(PSVirtualSpace*) \
declare_toplevel_type(ImmutableSpace*) \
declare_toplevel_type(MutableSpace*) \
declare_toplevel_type(PSYoungGen*) \
declare_toplevel_type(PSOldGen*) \
Expand Down
Loading

0 comments on commit ea2c447

Please sign in to comment.