Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename alloc bit to valid object bit (VO bit) #214

Merged
merged 3 commits into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -xe
unset JAVA_TOOL_OPTIONS

export MMTK_EXTREME_ASSERTIONS=0
export GLOBAL_ALLOC_BIT=1
export VO_BIT=1
. $(dirname "$0")/ci-build.sh

cd $OPENJDK_PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/ci-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ cd $cur
cd $cur
./ci-test-assertions.sh
cd $cur
./ci-test-global-alloc-bit.sh
./ci-test-vo-bit.sh
cd $cur
./ci-test-malloc-mark-sweep.sh
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
run: |
./.github/scripts/ci-build.sh
./.github/scripts/ci-test-only-normal.sh
- name: DaCapo Tests with global allocation bit
run: ./.github/scripts/ci-test-global-alloc-bit.sh
- name: DaCapo Tests with valid object bit (VO bit)
run: ./.github/scripts/ci-test-vo-bit.sh
- name: DaCapo Tests with malloc Mark-Sweep
run: ./.github/scripts/ci-test-malloc-mark-sweep.sh

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,14 @@ building OpenJDK, we can change its location to be in the object's header:
$ MARK_IN_HEADER=1 make CONF=linux-x86_64-normal-server-$DEBUG_LEVEL THIRD_PARTY_HEAP=$PWD/../mmtk-openjdk/openjdk
```

### Alloc bit
To support the `global_alloc_bit` feature in mmtk-core, you can set the environment variable `GLOBAL_ALLOC_BIT=1` when
building OpenJDK. This will set the feature for mmtk-core, as well as compiling the fastpath for the alloc bit.
### Valid object bit

To support the `vo_bit` (valid object bit) feature in mmtk-core, you can set the
environment variable `VO_BIT=1` when building OpenJDK. This will set the feature
for mmtk-core, as well as compiling the fastpath for the VO bit.

```console
$ GLOBAL_ALLOC_BIT=1 make CONF=linux-x86_64-normal-server-$DEBUG_LEVEL THIRD_PARTY_HEAP=$PWD/../mmtk-openjdk/openjdk
$ VO_BIT=1 make CONF=linux-x86_64-normal-server-$DEBUG_LEVEL THIRD_PARTY_HEAP=$PWD/../mmtk-openjdk/openjdk
```

## Test
Expand Down
4 changes: 2 additions & 2 deletions mmtk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ once_cell = "1.10.0"
# - change branch
# - change repo name
# But other changes including adding/removing whitespaces in commented lines may break the CI.
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "f8469b0a019bea58cba26e9fb5c70fb7398ccd31" }
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "df146b7af6cf41cc7d6996e1ca538fd2b32950f5" }
# Uncomment the following to build locally
# mmtk = { path = "../repos/mmtk-core" }

Expand All @@ -42,9 +42,9 @@ default = []
mmtk_extreme_assertions = ["mmtk/extreme_assertions"]
nogc_lock_free = ["mmtk/nogc_lock_free"]
nogc_no_zeroing = ["mmtk/nogc_no_zeroing"]
# Use the env var GLOBAL_ALLOC_BIT=1 when building OpenJDK so the fastpath for setting the alloc bit will be compiled in.
# Use the env var VO_BIT=1 when building OpenJDK so the fastpath for setting the alloc bit will be compiled in.
# See README.
global_alloc_bit = ["mmtk/global_alloc_bit"]
vo_bit = ["mmtk/vo_bit"]

# This compile time constant places the mark bit in the header of the object instead of on the side.
mark_bit_in_header = []
Expand Down
4 changes: 2 additions & 2 deletions mmtk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ pub static GLOBAL_SIDE_METADATA_VM_BASE_ADDRESS: uintptr_t =
mmtk::util::metadata::side_metadata::GLOBAL_SIDE_METADATA_VM_BASE_ADDRESS.as_usize();

#[no_mangle]
pub static GLOBAL_ALLOC_BIT_ADDRESS: uintptr_t =
mmtk::util::metadata::side_metadata::ALLOC_SIDE_METADATA_ADDR.as_usize();
pub static VO_BIT_ADDRESS: uintptr_t =
mmtk::util::metadata::side_metadata::VO_BIT_SIDE_METADATA_ADDR.as_usize();

#[no_mangle]
pub static FREE_LIST_ALLOCATOR_SIZE: uintptr_t =
Expand Down
10 changes: 5 additions & 5 deletions openjdk/CompileThirdPartyHeap.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ ifdef MMTK_PLAN
GC_FEATURES=--features $(MMTK_PLAN)
endif

ifeq ($(GLOBAL_ALLOC_BIT), 1)
ifeq ($(VO_BIT), 1)
ifndef GC_FEATURES
GC_FEATURES=--features global_alloc_bit
GC_FEATURES=--features vo_bit
else
GC_FEATURES:=$(strip $(GC_FEATURES))",global_alloc_bit"
GC_FEATURES:=$(strip $(GC_FEATURES))",vo_bit"
endif
endif

Expand Down Expand Up @@ -79,8 +79,8 @@ FORCE:
TARGETS += $(LIB_MMTK)
JVM_SRC_DIRS += $(MMTK_CPP_ROOT) $(MMTK_CPP_ROOT)/barriers
JVM_CFLAGS += -std=c++11 -DINCLUDE_THIRD_PARTY_HEAP -DTHIRD_PARTY_HEAP_SRC=$(MMTK_CPP_ROOT)
ifeq ($(GLOBAL_ALLOC_BIT), 1)
JVM_CFLAGS += -DMMTK_ENABLE_GLOBAL_ALLOC_BIT
ifeq ($(VO_BIT), 1)
JVM_CFLAGS += -DMMTK_ENABLE_VO_BIT
endif

$(BUILD_LIBJVM): $(LIB_MMTK)
2 changes: 1 addition & 1 deletion openjdk/mmtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ typedef enum {

extern const uintptr_t GLOBAL_SIDE_METADATA_BASE_ADDRESS;
extern const uintptr_t GLOBAL_SIDE_METADATA_VM_BASE_ADDRESS;
extern const uintptr_t GLOBAL_ALLOC_BIT_ADDRESS;
extern const uintptr_t VO_BIT_ADDRESS;
extern const size_t MMTK_MARK_COMPACT_HEADER_RESERVED_IN_BYTES;
extern const uintptr_t FREE_LIST_ALLOCATOR_SIZE;

Expand Down
2 changes: 1 addition & 1 deletion openjdk/mmtkBarrierSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define MMTK_ENABLE_ALLOCATION_FASTPATH true
#define MMTK_ENABLE_BARRIER_FASTPATH true

const intptr_t ALLOC_BIT_BASE_ADDRESS = GLOBAL_ALLOC_BIT_ADDRESS;
const intptr_t VO_BIT_BASE_ADDRESS = VO_BIT_ADDRESS;

struct MMTkAllocatorOffsets {
int tlab_top_offset;
Expand Down
12 changes: 6 additions & 6 deletions openjdk/mmtkBarrierSetAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ void MMTkBarrierSetAssembler::eden_allocate(MacroAssembler* masm, Register threa
__ jcc(Assembler::above, slow_case);
// lab.cursor = end
__ movptr(cursor, end);
bool enable_global_alloc_bit = false;
#ifdef MMTK_ENABLE_GLOBAL_ALLOC_BIT
enable_global_alloc_bit = true;
bool enable_vo_bit = false;
#ifdef MMTK_ENABLE_VO_BIT
enable_vo_bit = true;
#endif
if (enable_global_alloc_bit || selector.tag == TAG_MARK_COMPACT) {
if (enable_vo_bit || selector.tag == TAG_MARK_COMPACT) {
Register tmp3 = rdi;
Register tmp2 = rscratch1;
assert_different_registers(obj, tmp2, tmp3, rcx);

// tmp2 = load-byte (SIDE_METADATA_BASE_ADDRESS + (obj >> 6));
__ movptr(tmp3, obj);
__ shrptr(tmp3, 6);
__ movptr(tmp2, ALLOC_BIT_BASE_ADDRESS);
__ movptr(tmp2, VO_BIT_BASE_ADDRESS);
__ movb(tmp2, Address(tmp2, tmp3));
// tmp3 = 1 << ((obj >> 3) & 7)
// 1. rcx = (obj >> 3) & 7
Expand All @@ -126,7 +126,7 @@ void MMTkBarrierSetAssembler::eden_allocate(MacroAssembler* masm, Register threa
// store-byte tmp2 (SIDE_METADATA_BASE_ADDRESS + (obj >> 6))
__ movptr(tmp3, obj);
__ shrptr(tmp3, 6);
__ movptr(rcx, ALLOC_BIT_BASE_ADDRESS);
__ movptr(rcx, VO_BIT_BASE_ADDRESS);
__ movb(Address(rcx, tmp3), tmp2);
}

Expand Down
18 changes: 9 additions & 9 deletions openjdk/mmtkBarrierSetC2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,14 @@ void MMTkBarrierSetC2::expand_allocate(PhaseMacroExpand* x,
fast_oop_ctrl = needgc_false; // No contention, so this is the fast path
fast_oop_rawmem = store_eden_top;

bool enable_global_alloc_bit = false;
#ifdef MMTK_ENABLE_GLOBAL_ALLOC_BIT
enable_global_alloc_bit = true;
bool enable_vo_bit = false;
#ifdef MMTK_ENABLE_VO_BIT
enable_vo_bit = true;
#endif
if (enable_global_alloc_bit || selector.tag == TAG_MARK_COMPACT) {
if (enable_vo_bit || selector.tag == TAG_MARK_COMPACT) {
// set the alloc bit:
// intptr_t addr = (intptr_t) (void*) fast_oop;
// uint8_t* meta_addr = (uint8_t*) (ALLOC_BIT_BASE_ADDRESS + (addr >> 6));
// uint8_t* meta_addr = (uint8_t*) (VO_BIT_BASE_ADDRESS + (addr >> 6));
// intptr_t shift = (addr >> 3) & 0b111;
// uint8_t byte_val = *meta_addr;
// uint8_t new_byte_val = byte_val | (1 << shift);
Expand All @@ -293,7 +293,7 @@ void MMTkBarrierSetC2::expand_allocate(PhaseMacroExpand* x,
Node *meta_offset = new URShiftLNode(obj_addr, addr_shift);
x->transform_later(meta_offset);

Node *meta_base = ConLNode::make(ALLOC_BIT_BASE_ADDRESS);
Node *meta_base = ConLNode::make(VO_BIT_BASE_ADDRESS);
x->transform_later(meta_base);

Node *meta_addr = new AddLNode(meta_base, meta_offset);
Expand Down Expand Up @@ -329,10 +329,10 @@ void MMTkBarrierSetC2::expand_allocate(PhaseMacroExpand* x,
Node *new_meta_val = new OrINode(meta_val, set_bit);
x->transform_later(new_meta_val);

Node *set_alloc_bit = new StoreBNode(fast_oop_ctrl, fast_oop_rawmem, meta_addr_p, TypeRawPtr::BOTTOM, new_meta_val, MemNode::unordered);
x->transform_later(set_alloc_bit);
Node *set_vo_bit = new StoreBNode(fast_oop_ctrl, fast_oop_rawmem, meta_addr_p, TypeRawPtr::BOTTOM, new_meta_val, MemNode::unordered);
x->transform_later(set_vo_bit);

fast_oop_rawmem = set_alloc_bit;
fast_oop_rawmem = set_vo_bit;
}

InitializeNode* init = alloc->initialization();
Expand Down