- Build with command
make THIRD_PARTY_HEAP=$PWD/my_third_party_heap
. - This will search for, and include
$PWD/my_third_party_heap/CompileThirdPartyHeap.gmk
# TOPDIR points to openjdk root directory
JVM_SRC_DIRS += $(TOPDIR)/my_third_party_heap
JVM_CFLAGS += -DINCLUDE_THIRD_PARTY_HEAP -DTHIRD_PARTY_HEAP_SRC=$(TOPDIR)/my_third_party_heap
This will compile every .cpp
files under $PWD/my_third_party_heap
and link to libjava.so.
This is useful for mmtk to build the libmmtk.so building libjava.so
Add this to CompileThirdPartyHeap.gmk
:
lib_mmtk:
echo "your build commands here"
$(BUILD_LIBJVM): lib_mmtk
Currently, we need to add a cpp file in my_third_party_heap
and implement 2 interfaces:
#include "gc/shared/thirdPartyHeap.hpp"
namespace third_party_heap {
class MutatorContext;
MutatorContext* bind_mutator(::Thread* current) {
// Returns a pointer of a thread-local storage
}
GCArguments* new_gc_arguments() {
// Return your inherited GCArguments instance
}
};
- An implementation of
GCArguments
is responsible for create aCollectedHeap*
.- So you need to define a implementation of
CollectedHeap
as well. - And implement
CollectedHeap::mem_allocate
method for object allocation- Allocate objects either by:
- Allocate with global synchronization
- Get pre-created
MutatorContext*
, and allocate without synchronization.
- (Possibly) triggers a gc manually within this method
- Allocate objects either by:
- So you need to define a implementation of
We only have no-barrier support...
CollectedHeap::mem_allocate
without UseTLAB
seems have bad performance...