8326065: Merge Space into ContiguousSpace
Reviewed-by: cjplummer, sjohanss
This commit is contained in:
parent
11fdca0634
commit
ef2d5c40c0
@ -40,7 +40,9 @@
|
|||||||
#include "utilities/globalDefinitions.hpp"
|
#include "utilities/globalDefinitions.hpp"
|
||||||
#include "utilities/macros.hpp"
|
#include "utilities/macros.hpp"
|
||||||
|
|
||||||
ContiguousSpace::ContiguousSpace(): Space(),
|
ContiguousSpace::ContiguousSpace():
|
||||||
|
_bottom(nullptr),
|
||||||
|
_end(nullptr),
|
||||||
_next_compaction_space(nullptr),
|
_next_compaction_space(nullptr),
|
||||||
_top(nullptr) {
|
_top(nullptr) {
|
||||||
_mangler = new GenSpaceMangler(this);
|
_mangler = new GenSpaceMangler(this);
|
||||||
@ -101,20 +103,14 @@ void ContiguousSpace::mangle_unused_area_complete() {
|
|||||||
#endif // NOT_PRODUCT
|
#endif // NOT_PRODUCT
|
||||||
|
|
||||||
|
|
||||||
void Space::print_short() const { print_short_on(tty); }
|
void ContiguousSpace::print_short() const { print_short_on(tty); }
|
||||||
|
|
||||||
void Space::print_short_on(outputStream* st) const {
|
void ContiguousSpace::print_short_on(outputStream* st) const {
|
||||||
st->print(" space " SIZE_FORMAT "K, %3d%% used", capacity() / K,
|
st->print(" space " SIZE_FORMAT "K, %3d%% used", capacity() / K,
|
||||||
(int) ((double) used() * 100 / capacity()));
|
(int) ((double) used() * 100 / capacity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Space::print() const { print_on(tty); }
|
void ContiguousSpace::print() const { print_on(tty); }
|
||||||
|
|
||||||
void Space::print_on(outputStream* st) const {
|
|
||||||
print_short_on(st);
|
|
||||||
st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ")",
|
|
||||||
p2i(bottom()), p2i(end()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContiguousSpace::print_on(outputStream* st) const {
|
void ContiguousSpace::print_on(outputStream* st) const {
|
||||||
print_short_on(st);
|
print_short_on(st);
|
||||||
|
@ -45,35 +45,45 @@
|
|||||||
// for iterating over objects and free blocks, etc.
|
// for iterating over objects and free blocks, etc.
|
||||||
|
|
||||||
// Forward decls.
|
// Forward decls.
|
||||||
class Space;
|
|
||||||
class ContiguousSpace;
|
class ContiguousSpace;
|
||||||
class Generation;
|
class Generation;
|
||||||
class ContiguousSpace;
|
class ContiguousSpace;
|
||||||
class CardTableRS;
|
class CardTableRS;
|
||||||
class DirtyCardToOopClosure;
|
class DirtyCardToOopClosure;
|
||||||
|
class GenSpaceMangler;
|
||||||
|
|
||||||
// A Space describes a heap area. Class Space is an abstract
|
// A space in which the free area is contiguous. It therefore supports
|
||||||
// base class.
|
// faster allocation, and compaction.
|
||||||
//
|
|
||||||
// Space supports allocation, size computation and GC support is provided.
|
|
||||||
//
|
//
|
||||||
// Invariant: bottom() and end() are on page_size boundaries and
|
// Invariant: bottom() and end() are on page_size boundaries and
|
||||||
// bottom() <= top() <= end()
|
// bottom() <= top() <= end()
|
||||||
// top() is inclusive and end() is exclusive.
|
// top() is inclusive and end() is exclusive.
|
||||||
|
class ContiguousSpace: public CHeapObj<mtGC> {
|
||||||
class Space: public CHeapObj<mtGC> {
|
|
||||||
friend class VMStructs;
|
friend class VMStructs;
|
||||||
protected:
|
|
||||||
|
private:
|
||||||
HeapWord* _bottom;
|
HeapWord* _bottom;
|
||||||
HeapWord* _end;
|
HeapWord* _end;
|
||||||
|
|
||||||
// Used in support of save_marks()
|
// Used in support of save_marks()
|
||||||
HeapWord* _saved_mark_word;
|
HeapWord* _saved_mark_word;
|
||||||
|
|
||||||
Space():
|
ContiguousSpace* _next_compaction_space;
|
||||||
_bottom(nullptr), _end(nullptr) { }
|
|
||||||
|
HeapWord* _top;
|
||||||
|
// A helper for mangling the unused area of the space in debug builds.
|
||||||
|
GenSpaceMangler* _mangler;
|
||||||
|
|
||||||
|
GenSpaceMangler* mangler() { return _mangler; }
|
||||||
|
|
||||||
|
// Allocation helpers (return null if full).
|
||||||
|
inline HeapWord* allocate_impl(size_t word_size);
|
||||||
|
inline HeapWord* par_allocate_impl(size_t word_size);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ContiguousSpace();
|
||||||
|
~ContiguousSpace();
|
||||||
|
|
||||||
public:
|
|
||||||
// Accessors
|
// Accessors
|
||||||
HeapWord* bottom() const { return _bottom; }
|
HeapWord* bottom() const { return _bottom; }
|
||||||
HeapWord* end() const { return _end; }
|
HeapWord* end() const { return _end; }
|
||||||
@ -82,10 +92,6 @@ class Space: public CHeapObj<mtGC> {
|
|||||||
|
|
||||||
HeapWord* saved_mark_word() const { return _saved_mark_word; }
|
HeapWord* saved_mark_word() const { return _saved_mark_word; }
|
||||||
|
|
||||||
// Returns a subregion of the space containing only the allocated objects in
|
|
||||||
// the space.
|
|
||||||
virtual MemRegion used_region() const = 0;
|
|
||||||
|
|
||||||
// Returns a region that is guaranteed to contain (at least) all objects
|
// Returns a region that is guaranteed to contain (at least) all objects
|
||||||
// allocated at the time of the last call to "save_marks". If the space
|
// allocated at the time of the last call to "save_marks". If the space
|
||||||
// initializes its DirtyCardToOopClosure's specifying the "contig" option
|
// initializes its DirtyCardToOopClosure's specifying the "contig" option
|
||||||
@ -98,13 +104,6 @@ class Space: public CHeapObj<mtGC> {
|
|||||||
return MemRegion(bottom(), saved_mark_word());
|
return MemRegion(bottom(), saved_mark_word());
|
||||||
}
|
}
|
||||||
|
|
||||||
// For detecting GC bugs. Should only be called at GC boundaries, since
|
|
||||||
// some unused space may be used as scratch space during GC's.
|
|
||||||
// We also call this when expanding a space to satisfy an allocation
|
|
||||||
// request. See bug #4668531
|
|
||||||
virtual void mangle_unused_area() = 0;
|
|
||||||
virtual void mangle_unused_area_complete() = 0;
|
|
||||||
|
|
||||||
// Testers
|
// Testers
|
||||||
bool is_empty() const { return used() == 0; }
|
bool is_empty() const { return used() == 0; }
|
||||||
|
|
||||||
@ -123,53 +122,14 @@ class Space: public CHeapObj<mtGC> {
|
|||||||
bool is_in_reserved(const void* p) const { return _bottom <= p && p < _end; }
|
bool is_in_reserved(const void* p) const { return _bottom <= p && p < _end; }
|
||||||
|
|
||||||
// Size computations. Sizes are in bytes.
|
// Size computations. Sizes are in bytes.
|
||||||
size_t capacity() const { return byte_size(bottom(), end()); }
|
size_t capacity() const { return byte_size(bottom(), end()); }
|
||||||
virtual size_t used() const = 0;
|
size_t used() const { return byte_size(bottom(), top()); }
|
||||||
virtual size_t free() const = 0;
|
size_t free() const { return byte_size(top(), end()); }
|
||||||
|
|
||||||
// If "p" is in the space, returns the address of the start of the
|
|
||||||
// "block" that contains "p". We say "block" instead of "object" since
|
|
||||||
// some heaps may not pack objects densely; a chunk may either be an
|
|
||||||
// object or a non-object. If "p" is not in the space, return null.
|
|
||||||
virtual HeapWord* block_start_const(const void* p) const = 0;
|
|
||||||
|
|
||||||
// Allocation (return null if full). Assumes the caller has established
|
|
||||||
// mutually exclusive access to the space.
|
|
||||||
virtual HeapWord* allocate(size_t word_size) = 0;
|
|
||||||
|
|
||||||
// Allocation (return null if full). Enforces mutual exclusion internally.
|
|
||||||
virtual HeapWord* par_allocate(size_t word_size) = 0;
|
|
||||||
|
|
||||||
void print() const;
|
void print() const;
|
||||||
virtual void print_on(outputStream* st) const;
|
virtual void print_on(outputStream* st) const;
|
||||||
void print_short() const;
|
void print_short() const;
|
||||||
void print_short_on(outputStream* st) const;
|
void print_short_on(outputStream* st) const;
|
||||||
};
|
|
||||||
|
|
||||||
class GenSpaceMangler;
|
|
||||||
|
|
||||||
// A space in which the free area is contiguous. It therefore supports
|
|
||||||
// faster allocation, and compaction.
|
|
||||||
class ContiguousSpace: public Space {
|
|
||||||
friend class VMStructs;
|
|
||||||
|
|
||||||
private:
|
|
||||||
ContiguousSpace* _next_compaction_space;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
HeapWord* _top;
|
|
||||||
// A helper for mangling the unused area of the space in debug builds.
|
|
||||||
GenSpaceMangler* _mangler;
|
|
||||||
|
|
||||||
GenSpaceMangler* mangler() { return _mangler; }
|
|
||||||
|
|
||||||
// Allocation helpers (return null if full).
|
|
||||||
inline HeapWord* allocate_impl(size_t word_size);
|
|
||||||
inline HeapWord* par_allocate_impl(size_t word_size);
|
|
||||||
|
|
||||||
public:
|
|
||||||
ContiguousSpace();
|
|
||||||
~ContiguousSpace();
|
|
||||||
|
|
||||||
// Initialization.
|
// Initialization.
|
||||||
// "initialize" should be called once on a space, before it is used for
|
// "initialize" should be called once on a space, before it is used for
|
||||||
@ -206,19 +166,20 @@ protected:
|
|||||||
|
|
||||||
bool saved_mark_at_top() const { return saved_mark_word() == top(); }
|
bool saved_mark_at_top() const { return saved_mark_word() == top(); }
|
||||||
|
|
||||||
// In debug mode mangle (write it with a particular bit
|
|
||||||
// pattern) the unused part of a space.
|
|
||||||
|
|
||||||
// Used to save the address in a space for later use during mangling.
|
// Used to save the address in a space for later use during mangling.
|
||||||
void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN;
|
void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN;
|
||||||
// Used to save the space's current top for later use during mangling.
|
// Used to save the space's current top for later use during mangling.
|
||||||
void set_top_for_allocations() PRODUCT_RETURN;
|
void set_top_for_allocations() PRODUCT_RETURN;
|
||||||
|
|
||||||
|
// For detecting GC bugs. Should only be called at GC boundaries, since
|
||||||
|
// some unused space may be used as scratch space during GC's.
|
||||||
|
// We also call this when expanding a space to satisfy an allocation
|
||||||
|
// request. See bug #4668531
|
||||||
// Mangle regions in the space from the current top up to the
|
// Mangle regions in the space from the current top up to the
|
||||||
// previously mangled part of the space.
|
// previously mangled part of the space.
|
||||||
void mangle_unused_area() override PRODUCT_RETURN;
|
void mangle_unused_area() PRODUCT_RETURN;
|
||||||
// Mangle [top, end)
|
// Mangle [top, end)
|
||||||
void mangle_unused_area_complete() override PRODUCT_RETURN;
|
void mangle_unused_area_complete() PRODUCT_RETURN;
|
||||||
|
|
||||||
// Do some sparse checking on the area that should have been mangled.
|
// Do some sparse checking on the area that should have been mangled.
|
||||||
void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
|
void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
|
||||||
@ -226,17 +187,13 @@ protected:
|
|||||||
// This code may be null depending on the macro DEBUG_MANGLING.
|
// This code may be null depending on the macro DEBUG_MANGLING.
|
||||||
void check_mangled_unused_area_complete() PRODUCT_RETURN;
|
void check_mangled_unused_area_complete() PRODUCT_RETURN;
|
||||||
|
|
||||||
// Size computations: sizes in bytes.
|
MemRegion used_region() const { return MemRegion(bottom(), top()); }
|
||||||
size_t used() const override { return byte_size(bottom(), top()); }
|
|
||||||
size_t free() const override { return byte_size(top(), end()); }
|
|
||||||
|
|
||||||
// In a contiguous space we have a more obvious bound on what parts
|
// Allocation (return null if full). Assumes the caller has established
|
||||||
// contain objects.
|
// mutually exclusive access to the space.
|
||||||
MemRegion used_region() const override { return MemRegion(bottom(), top()); }
|
virtual HeapWord* allocate(size_t word_size);
|
||||||
|
// Allocation (return null if full). Enforces mutual exclusion internally.
|
||||||
// Allocation (return null if full)
|
virtual HeapWord* par_allocate(size_t word_size);
|
||||||
HeapWord* allocate(size_t word_size) override;
|
|
||||||
HeapWord* par_allocate(size_t word_size) override;
|
|
||||||
|
|
||||||
// Iteration
|
// Iteration
|
||||||
void object_iterate(ObjectClosure* blk);
|
void object_iterate(ObjectClosure* blk);
|
||||||
@ -251,14 +208,15 @@ protected:
|
|||||||
template <typename OopClosureType>
|
template <typename OopClosureType>
|
||||||
void oop_since_save_marks_iterate(OopClosureType* blk);
|
void oop_since_save_marks_iterate(OopClosureType* blk);
|
||||||
|
|
||||||
// Very inefficient implementation.
|
// If "p" is in the space, returns the address of the start of the
|
||||||
HeapWord* block_start_const(const void* p) const override;
|
// "block" that contains "p". We say "block" instead of "object" since
|
||||||
|
// some heaps may not pack objects densely; a chunk may either be an
|
||||||
|
// object or a non-object. If "p" is not in the space, return null.
|
||||||
|
virtual HeapWord* block_start_const(const void* p) const;
|
||||||
|
|
||||||
// Addresses for inlined allocation
|
// Addresses for inlined allocation
|
||||||
HeapWord** top_addr() { return &_top; }
|
HeapWord** top_addr() { return &_top; }
|
||||||
|
|
||||||
void print_on(outputStream* st) const override;
|
|
||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
void verify() const;
|
void verify() const;
|
||||||
};
|
};
|
||||||
|
@ -98,14 +98,13 @@
|
|||||||
nonstatic_field(CollectedHeap, _is_gc_active, bool) \
|
nonstatic_field(CollectedHeap, _is_gc_active, bool) \
|
||||||
nonstatic_field(CollectedHeap, _total_collections, unsigned int) \
|
nonstatic_field(CollectedHeap, _total_collections, unsigned int) \
|
||||||
\
|
\
|
||||||
|
nonstatic_field(ContiguousSpace, _bottom, HeapWord*) \
|
||||||
|
nonstatic_field(ContiguousSpace, _end, HeapWord*) \
|
||||||
nonstatic_field(ContiguousSpace, _top, HeapWord*) \
|
nonstatic_field(ContiguousSpace, _top, HeapWord*) \
|
||||||
nonstatic_field(ContiguousSpace, _saved_mark_word, HeapWord*) \
|
nonstatic_field(ContiguousSpace, _saved_mark_word, HeapWord*) \
|
||||||
\
|
\
|
||||||
nonstatic_field(MemRegion, _start, HeapWord*) \
|
nonstatic_field(MemRegion, _start, HeapWord*) \
|
||||||
nonstatic_field(MemRegion, _word_size, size_t) \
|
nonstatic_field(MemRegion, _word_size, size_t)
|
||||||
\
|
|
||||||
nonstatic_field(Space, _bottom, HeapWord*) \
|
|
||||||
nonstatic_field(Space, _end, HeapWord*)
|
|
||||||
|
|
||||||
#define VM_TYPES_GC(declare_type, \
|
#define VM_TYPES_GC(declare_type, \
|
||||||
declare_toplevel_type, \
|
declare_toplevel_type, \
|
||||||
@ -135,8 +134,7 @@
|
|||||||
/******************************************/ \
|
/******************************************/ \
|
||||||
\
|
\
|
||||||
declare_toplevel_type(CollectedHeap) \
|
declare_toplevel_type(CollectedHeap) \
|
||||||
declare_toplevel_type(Space) \
|
declare_toplevel_type(ContiguousSpace) \
|
||||||
declare_type(ContiguousSpace, Space) \
|
|
||||||
declare_toplevel_type(BarrierSet) \
|
declare_toplevel_type(BarrierSet) \
|
||||||
declare_type(ModRefBarrierSet, BarrierSet) \
|
declare_type(ModRefBarrierSet, BarrierSet) \
|
||||||
declare_type(CardTableBarrierSet, ModRefBarrierSet) \
|
declare_type(CardTableBarrierSet, ModRefBarrierSet) \
|
||||||
@ -164,7 +162,6 @@
|
|||||||
declare_toplevel_type(HeapWord*) \
|
declare_toplevel_type(HeapWord*) \
|
||||||
declare_toplevel_type(HeapWord* volatile) \
|
declare_toplevel_type(HeapWord* volatile) \
|
||||||
declare_toplevel_type(MemRegion*) \
|
declare_toplevel_type(MemRegion*) \
|
||||||
declare_toplevel_type(Space*) \
|
|
||||||
declare_toplevel_type(ThreadLocalAllocBuffer*) \
|
declare_toplevel_type(ThreadLocalAllocBuffer*) \
|
||||||
\
|
\
|
||||||
declare_toplevel_type(BarrierSet::FakeRtti)
|
declare_toplevel_type(BarrierSet::FakeRtti)
|
||||||
|
@ -46,8 +46,6 @@ public class SerialHeap extends CollectedHeap {
|
|||||||
private static AddressField youngGenField;
|
private static AddressField youngGenField;
|
||||||
private static AddressField oldGenField;
|
private static AddressField oldGenField;
|
||||||
|
|
||||||
private static GenerationFactory genFactory;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
VM.registerVMInitializedObserver(new Observer() {
|
VM.registerVMInitializedObserver(new Observer() {
|
||||||
public void update(Observable o, Object data) {
|
public void update(Observable o, Object data) {
|
||||||
@ -61,8 +59,6 @@ public class SerialHeap extends CollectedHeap {
|
|||||||
|
|
||||||
youngGenField = type.getAddressField("_young_gen");
|
youngGenField = type.getAddressField("_young_gen");
|
||||||
oldGenField = type.getAddressField("_old_gen");
|
oldGenField = type.getAddressField("_old_gen");
|
||||||
|
|
||||||
genFactory = new GenerationFactory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefNewGeneration youngGen() {
|
public DefNewGeneration youngGen() {
|
||||||
|
@ -34,7 +34,17 @@ import sun.jvm.hotspot.types.*;
|
|||||||
import sun.jvm.hotspot.utilities.Observable;
|
import sun.jvm.hotspot.utilities.Observable;
|
||||||
import sun.jvm.hotspot.utilities.Observer;
|
import sun.jvm.hotspot.utilities.Observer;
|
||||||
|
|
||||||
public class ContiguousSpace extends Space implements LiveRegionsProvider {
|
/** <P> A ContiguousSpace describes a heap area. </P>
|
||||||
|
|
||||||
|
<P> Invariant: bottom() and end() are on page_size boundaries and: </P>
|
||||||
|
|
||||||
|
<P> bottom() <= top() <= end() </P>
|
||||||
|
|
||||||
|
<P> top() is inclusive and end() is exclusive. </P> */
|
||||||
|
|
||||||
|
public class ContiguousSpace extends VMObject implements LiveRegionsProvider {
|
||||||
|
private static AddressField bottomField;
|
||||||
|
private static AddressField endField;
|
||||||
private static AddressField topField;
|
private static AddressField topField;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -48,6 +58,8 @@ public class ContiguousSpace extends Space implements LiveRegionsProvider {
|
|||||||
private static synchronized void initialize(TypeDataBase db) {
|
private static synchronized void initialize(TypeDataBase db) {
|
||||||
Type type = db.lookupType("ContiguousSpace");
|
Type type = db.lookupType("ContiguousSpace");
|
||||||
|
|
||||||
|
bottomField = type.getAddressField("_bottom");
|
||||||
|
endField = type.getAddressField("_end");
|
||||||
topField = type.getAddressField("_top");
|
topField = type.getAddressField("_top");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,24 +67,30 @@ public class ContiguousSpace extends Space implements LiveRegionsProvider {
|
|||||||
super(addr);
|
super(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Address top() {
|
public Address bottom() { return bottomField.getValue(addr); }
|
||||||
return topField.getValue(addr);
|
public Address end() { return endField.getValue(addr); }
|
||||||
|
public Address top() { return topField.getValue(addr); }
|
||||||
|
|
||||||
|
/** Support for iteration over heap -- not sure how this will
|
||||||
|
interact with GC in reflective system, but necessary for the
|
||||||
|
debugging mechanism */
|
||||||
|
public OopHandle bottomAsOopHandle() {
|
||||||
|
return bottomField.getOopHandle(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** In bytes */
|
/** Support for iteration over heap -- not sure how this will
|
||||||
public long capacity() {
|
interact with GC in reflective system, but necessary for the
|
||||||
return end().minus(bottom());
|
debugging mechanism */
|
||||||
|
public OopHandle nextOopHandle(OopHandle handle, long size) {
|
||||||
|
return handle.addOffsetToAsOopHandle(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** In bytes */
|
/** Returned value is in bytes */
|
||||||
public long used() {
|
public long capacity() { return end().minus(bottom()); }
|
||||||
return top().minus(bottom());
|
public long used() { return top().minus(bottom()); }
|
||||||
}
|
public long free() { return end().minus(top()); }
|
||||||
|
|
||||||
/** In bytes */
|
public void print() { printOn(System.out); }
|
||||||
public long free() {
|
|
||||||
return end().minus(top());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** In a contiguous space we have a more obvious bound on what parts
|
/** In a contiguous space we have a more obvious bound on what parts
|
||||||
contain objects. */
|
contain objects. */
|
||||||
@ -95,6 +113,10 @@ public class ContiguousSpace extends Space implements LiveRegionsProvider {
|
|||||||
public void printOn(PrintStream tty) {
|
public void printOn(PrintStream tty) {
|
||||||
tty.print(" [" + bottom() + "," +
|
tty.print(" [" + bottom() + "," +
|
||||||
top() + "," + end() + ")");
|
top() + "," + end() + ")");
|
||||||
super.printOn(tty);
|
tty.print(" space capacity = ");
|
||||||
|
tty.print(capacity());
|
||||||
|
tty.print(", ");
|
||||||
|
tty.print((double) used() * 100.0/ capacity());
|
||||||
|
tty.print(" used");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2000, 2020, 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
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sun.jvm.hotspot.gc.shared;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import sun.jvm.hotspot.debugger.*;
|
|
||||||
import sun.jvm.hotspot.gc.serial.*;
|
|
||||||
import sun.jvm.hotspot.runtime.*;
|
|
||||||
import sun.jvm.hotspot.types.*;
|
|
||||||
import sun.jvm.hotspot.utilities.Observable;
|
|
||||||
import sun.jvm.hotspot.utilities.Observer;
|
|
||||||
|
|
||||||
/** Factory containing a VirtualConstructor suitable for instantiating
|
|
||||||
wrapper objects for all types of generations */
|
|
||||||
|
|
||||||
public class GenerationFactory {
|
|
||||||
private static VirtualConstructor ctor;
|
|
||||||
|
|
||||||
static {
|
|
||||||
VM.registerVMInitializedObserver(new Observer() {
|
|
||||||
public void update(Observable o, Object data) {
|
|
||||||
initialize(VM.getVM().getTypeDataBase());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static synchronized void initialize(TypeDataBase db) {
|
|
||||||
ctor = new VirtualConstructor(db);
|
|
||||||
|
|
||||||
ctor.addMapping("DefNewGeneration", DefNewGeneration.class);
|
|
||||||
ctor.addMapping("TenuredGeneration", TenuredGeneration.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Generation newObject(Address addr) {
|
|
||||||
try {
|
|
||||||
return (Generation) ctor.instantiateWrapperFor(addr);
|
|
||||||
} catch (WrongTypeException e) {
|
|
||||||
return new Generation(addr) {
|
|
||||||
public String name() {
|
|
||||||
return "unknown generation type";
|
|
||||||
}
|
|
||||||
public void spaceIterate(SpaceClosure blk, boolean usedOnly) {
|
|
||||||
}
|
|
||||||
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
|
||||||
}
|
|
||||||
public void printOn(java.io.PrintStream tty) {
|
|
||||||
tty.println("unknown subtype of Generation @ " + getAddress() + " (" +
|
|
||||||
virtualSpace().low() + "," + virtualSpace().high() + ")");
|
|
||||||
}
|
|
||||||
public long used() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
public long free() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
public long capacity() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
public long contiguousAvailable() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2000, 2020, 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
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sun.jvm.hotspot.gc.shared;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
import sun.jvm.hotspot.debugger.*;
|
|
||||||
import sun.jvm.hotspot.memory.*;
|
|
||||||
import sun.jvm.hotspot.runtime.*;
|
|
||||||
import sun.jvm.hotspot.types.*;
|
|
||||||
import sun.jvm.hotspot.utilities.Observable;
|
|
||||||
import sun.jvm.hotspot.utilities.Observer;
|
|
||||||
|
|
||||||
/** <P> A Space describes a heap area. Class Space is an abstract base
|
|
||||||
class. </P>
|
|
||||||
|
|
||||||
<P> Space supports allocation, size computation and GC support is
|
|
||||||
provided. </P>
|
|
||||||
|
|
||||||
<P> Invariant: bottom() and end() are on page_size boundaries and: </P>
|
|
||||||
|
|
||||||
<P> bottom() <= top() <= end() </P>
|
|
||||||
|
|
||||||
<P> top() is inclusive and end() is exclusive. </P> */
|
|
||||||
|
|
||||||
public abstract class Space extends VMObject {
|
|
||||||
private static AddressField bottomField;
|
|
||||||
private static AddressField endField;
|
|
||||||
|
|
||||||
static {
|
|
||||||
VM.registerVMInitializedObserver(new Observer() {
|
|
||||||
public void update(Observable o, Object data) {
|
|
||||||
initialize(VM.getVM().getTypeDataBase());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static synchronized void initialize(TypeDataBase db) {
|
|
||||||
Type type = db.lookupType("Space");
|
|
||||||
|
|
||||||
bottomField = type.getAddressField("_bottom");
|
|
||||||
endField = type.getAddressField("_end");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Space(Address addr) {
|
|
||||||
super(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Address bottom() { return bottomField.getValue(addr); }
|
|
||||||
public Address end() { return endField.getValue(addr); }
|
|
||||||
|
|
||||||
/** Returns a subregion of the space containing all the objects in
|
|
||||||
the space. */
|
|
||||||
public MemRegion usedRegion() {
|
|
||||||
return new MemRegion(bottom(), end());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Support for iteration over heap -- not sure how this will
|
|
||||||
interact with GC in reflective system, but necessary for the
|
|
||||||
debugging mechanism */
|
|
||||||
public OopHandle bottomAsOopHandle() {
|
|
||||||
return bottomField.getOopHandle(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Support for iteration over heap -- not sure how this will
|
|
||||||
interact with GC in reflective system, but necessary for the
|
|
||||||
debugging mechanism */
|
|
||||||
public OopHandle nextOopHandle(OopHandle handle, long size) {
|
|
||||||
return handle.addOffsetToAsOopHandle(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returned value is in bytes */
|
|
||||||
public long capacity() { return end().minus(bottom()); }
|
|
||||||
/** Returned value is in bytes */
|
|
||||||
public abstract long used();
|
|
||||||
/** Returned value is in bytes */
|
|
||||||
public abstract long free();
|
|
||||||
|
|
||||||
/** Testers */
|
|
||||||
public boolean contains(Address p) {
|
|
||||||
return (bottom().lessThanOrEqual(p) && end().greaterThan(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void print() { printOn(System.out); }
|
|
||||||
public void printOn(PrintStream tty) {
|
|
||||||
tty.print(" space capacity = ");
|
|
||||||
tty.print(capacity());
|
|
||||||
tty.print(", ");
|
|
||||||
tty.print((double) used() * 100.0/ capacity());
|
|
||||||
tty.print(" used");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2000, 2015, 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
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sun.jvm.hotspot.gc.shared;
|
|
||||||
|
|
||||||
public interface SpaceClosure {
|
|
||||||
public void doSpace(Space s);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user