Skip to content

Commit

Permalink
* fix aarch64 port, should be working now
Browse files Browse the repository at this point in the history
* remove some test code related to compilation policy again
  • Loading branch information
tschatzl committed Dec 19, 2024
1 parent 19d3c14 commit dd74c56
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 49 deletions.
47 changes: 26 additions & 21 deletions src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "precompiled.hpp"
#include "asm/macroAssembler.inline.hpp"
#include "ci/ciMethodData.hpp"
#include "gc/g1/g1BarrierSet.hpp"
#include "gc/g1/g1BarrierSetAssembler.hpp"
#include "gc/g1/g1BarrierSetRuntime.hpp"
Expand Down Expand Up @@ -295,10 +296,6 @@ static uint8_t gen_all_barrier_parts() {
return G1C2BarrierPostNotNull | G1C2BarrierPostGenCrossCheck | G1C2BarrierPostGenNullCheck | G1C2BarrierPostGenCardCheck;
}

static uint8_t gen_no_barrier_parts() {
return 0;
}

void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm,
Register store_addr,
Register new_val,
Expand Down Expand Up @@ -366,9 +363,11 @@ void G1BarrierSetAssembler::g1_write_barrier_post_c2(MacroAssembler* masm,
Register thread,
Register tmp1,
Register tmp2,
uint8_t ext_barrier_data) {
uint8_t barrier_data,
uint ext_barrier_data) {
Label done;
generate_post_barrier_fast_path(masm, store_addr, new_val, thread, tmp1, tmp2, done, ext_barrier_data);
assert((barrier_data & ext_barrier_data) == 0, "No overlapping barrier data flags");
generate_post_barrier_fast_path(masm, store_addr, new_val, thread, tmp1, tmp2, done, barrier_data | ext_barrier_data);
__ bind(done);
}

Expand Down Expand Up @@ -469,6 +468,13 @@ void G1BarrierSetAssembler::gen_pre_barrier_stub(LIR_Assembler* ce, G1PreBarrier

#define __ masm->

static void add_to_counter(MacroAssembler* masm, Register mdp, int offset, Register value) {
Address addr(mdp, offset);
__ ldr(rscratch1, addr);
__ add(rscratch1, rscratch1, value);
__ str(rscratch1, addr);
}

void G1BarrierSetAssembler::g1_write_barrier_post_profile_c1(ciMethodData* md,
int bci,
MacroAssembler* masm,
Expand All @@ -495,31 +501,30 @@ void G1BarrierSetAssembler::g1_write_barrier_post_profile_c1(ciMethodData* md,

if (UseCompressedOops) {
__ decode_heap_oop(tmp1, new_val);
__ xorptr(tmp1, tmp1, store_addr);
__ eor(tmp1, tmp1, store_addr);
} else {
__ xorptr(tmp1, new_val, store_addr);
__ eor(tmp1, new_val, store_addr);
}
__ shrptr(tmp1, tmp1, G1HeapRegion::LogOfHRGrainBytes);
__ lsr(tmp1, tmp1, G1HeapRegion::LogOfHRGrainBytes);
__ cmp(tmp1, zr);
__ cset(tmp1, Assembler::EQ);
__ addptr(Address(mdp, md->byte_offset_of_slot(data, G1CounterData::same_region_counter_offset())), tmp1); // How many same-region pointers
add_to_counter(masm, mdp, md->byte_offset_of_slot(data, G1CounterData::same_region_counter_offset()), tmp1); // How many same-region

__ cmp(new_val, zr);
__ cset(tmp1, Assembler::EQ);
__ addptr(Address(mdp, md->byte_offset_of_slot(data, G1CounterData::null_new_val_counter_offset())), tmp1); // How many zeros
add_to_counter(masm, mdp, md->byte_offset_of_slot(data, G1CounterData::null_new_val_counter_offset()), tmp1); // How many zeros

__ movptr(rscratch1, Address(thread, in_bytes(G1ThreadLocalData::card_table_base_offset())));
__ shrptr(tmp1, store_addr, G1CardTable::card_shift());
__ cmpb(Address(tmp1, rscratch1), G1CardTable::clean_card_val());
__ cset(tmp1, Assembler::EQ);
__ addptr(Address(mdp, md->byte_offset_of_slot(data, G1CounterData::clean_cards_counter_offset())), tmp1); // How many clean cards
__ ldr(rscratch1, Address(thread, in_bytes(G1ThreadLocalData::card_table_base_offset())));
__ lsr(tmp1, store_addr, G1CardTable::card_shift());
__ ldrb(tmp1, Address(tmp1, rscratch1));
__ cmp(tmp1, (uint8_t)G1CardTable::clean_card_val());
__ cset(tmp2, Assembler::EQ);
add_to_counter(masm, mdp, md->byte_offset_of_slot(data, G1CounterData::clean_cards_counter_offset()), tmp2); // How many clean cards

if (XXXProfileBarrierFromYoung) {
__ movptr(rscratch1, Address(thread, in_bytes(G1ThreadLocalData::card_table_base_offset())));
__ shrptr(tmp1, store_addr, G1CardTable::card_shift());
__ cmpb(Address(tmp1, rscratch1), G1CardTable::g1_young_card);
__ cset(tmp1, Assembler::EQ);
__ addptr(Address(mdp, md->byte_offset_of_slot(data, G1CounterData::from_young_counter_offset())), tmp1); // How many from-young cards
__ cmp(tmp1, (uint8_t)G1CardTable::g1_young_card_val());
__ cset(tmp2, Assembler::EQ);
add_to_counter(masm, mdp, md->byte_offset_of_slot(data, G1CounterData::from_young_counter_offset()), tmp2); // How many clean cards
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "gc/shared/modRefBarrierSetAssembler.hpp"
#include "utilities/macros.hpp"

class ciMethodData;
class LIR_Assembler;
class StubAssembler;
class G1PreBarrierStub;
Expand Down Expand Up @@ -66,6 +67,15 @@ class G1BarrierSetAssembler: public ModRefBarrierSetAssembler {

void generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm);

void g1_write_barrier_post_profile_c1(ciMethodData* md,
int bci,
MacroAssembler* masm,
Register store_addr,
Register new_val,
Register thread,
Register tmp1,
Register tmp2);

void g1_write_barrier_post_c1(MacroAssembler* masm,
Register store_addr,
Register new_val,
Expand All @@ -90,6 +100,7 @@ class G1BarrierSetAssembler: public ModRefBarrierSetAssembler {
Register thread,
Register tmp1,
Register tmp2,
uint8_t barrier_data,
uint ext_barrier_data);
#endif

Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/cpu/aarch64/gc/g1/g1_aarch64.ad
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ static void write_barrier_post(MacroAssembler* masm,
}
Assembler::InlineSkippedInstructionsCounter skip_counter(masm);
G1BarrierSetAssembler* g1_asm = static_cast<G1BarrierSetAssembler*>(BarrierSet::barrier_set()->barrier_set_assembler());
bool new_val_maybe_null = G1BarrierStubC2::post_new_val_maybe_null(node);
g1_asm->g1_write_barrier_post_c2(masm, store_addr, new_val, rthread, tmp1, tmp2, G1BarrierStubC2::ext_barrier_data(node));
g1_asm->g1_write_barrier_post_c2(masm, store_addr, new_val, rthread, tmp1, tmp2, G1BarrierStubC2::barrier_data(node), G1BarrierStubC2::ext_barrier_data(node));
}

%}
Expand Down
41 changes: 25 additions & 16 deletions src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ void InterpreterMacroAssembler::profile_null_seen(Register mdp, bool is_aastore)
test_method_data_pointer(mdp, profile_continue);

if (XXXProfileBarrier && is_aastore) {
addptr(mdp, in_bytes(CombinedData::receiver_type_data_offset()));
add(mdp, mdp, in_bytes(CombinedData::receiver_type_data_offset()));
}

set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
Expand Down Expand Up @@ -1418,6 +1418,13 @@ void InterpreterMacroAssembler::profile_switch_case(Register index,
}
}

static void add_to_counter(MacroAssembler* masm, Register mdp, int offset, Register value) {
Address addr(mdp, offset);
masm->ldr(rscratch1, addr);
masm->add(rscratch1, rscratch1, value);
masm->str(rscratch1, addr);
}

void InterpreterMacroAssembler::profile_oop_store(Register addr_base, Register addr_index, Register new_val) {
if (!XXXProfileBarrier) {
return;
Expand Down Expand Up @@ -1448,28 +1455,30 @@ void InterpreterMacroAssembler::profile_oop_store(Register addr_base, Register a
decode_heap_oop_not_null(new_val);
}

xorptr(tmp, addr, new_val);
shrptr(tmp, tmp, G1HeapRegion::LogOfHRGrainBytes);
add(addr_base, addr_base, addr_index);

eor(tmp, addr_base, new_val);
lsr(tmp, tmp, G1HeapRegion::LogOfHRGrainBytes);
cmp(tmp, zr);
cset(tmp, Assembler::equal);
addptr(Address(mdp, in_bytes(G1CounterData::same_region_counter_offset())), tmp);
cset(tmp, Assembler::EQ);
add_to_counter(this, mdp, in_bytes(G1CounterData::same_region_counter_offset()), tmp);

cmp(new_val, zr);
cset(tmp, Assembler::equal);
addptr(Address(mdp, in_bytes(G1CounterData::null_new_val_counter_offset())), tmp);
cset(tmp, Assembler::EQ);
add_to_counter(this, mdp, in_bytes(G1CounterData::null_new_val_counter_offset()), tmp);

movptr(tmp, Address(thread, G1ThreadLocalData::card_table_base_offset()));
add(addr_base, addr_base, addr_index);
shrptr(addr_base, G1CardTable::card_shift());
ldr(tmp, Address(rthread, G1ThreadLocalData::card_table_base_offset()));
lsr(addr_base, addr_base, G1CardTable::card_shift());

cmpb(Address(tmp, addr), G1CardTable::clean_card_val());
cset(tmp2, Assembler::notEqual);
addptr(Address(mdp, in_bytes(G1CounterData::clean_cards_counter_offset())), tmp2);
ldrb(tmp, Address(tmp, addr_base));
cmp(tmp, G1CardTable::clean_card_val());
cset(tmp2, Assembler::NE);
add_to_counter(this, mdp, in_bytes(G1CounterData::clean_cards_counter_offset()), tmp2);

if (XXXProfileBarrierFromYoung) {
cmpb(Address(tmp, addr), G1CardTable::g1_young_card);
cset(tmp2, Assembler::notEqual);
addptr(Address(mdp, in_bytes(G1CounterData::from_young_counter_offset())), tmp2);
cmp(tmp, G1CardTable::g1_young_card_val());
cset(tmp2, Assembler::NE);
add_to_counter(this, mdp, in_bytes(G1CounterData::from_young_counter_offset()), tmp2);
}

bind(profile_continue);
Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,6 @@ static uint8_t gen_all_barrier_parts() {
return G1C2BarrierPostNotNull | G1C2BarrierPostGenCrossCheck | G1C2BarrierPostGenNullCheck | G1C2BarrierPostGenCardCheck;
}

static uint8_t gen_no_barrier_parts() {
return 0;
}

void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm,
Register store_addr,
Register new_val,
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/compiler/compilationPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ bool CompilationPolicy::is_mature(Method* method) {
// start profiling without waiting for the compiled method to arrive.
// We also take the load on compilers into the account.
bool CompilationPolicy::should_create_mdo(const methodHandle& method, CompLevel cur_level) {
return true;
// return true; // FIXME: remove, testing
if (cur_level != CompLevel_none || force_comp_at_level_simple(method) || CompilationModeFlag::quick_only() || !ProfileInterpreter) {
return false;
}
Expand Down Expand Up @@ -956,9 +956,9 @@ bool CompilationPolicy::should_not_inline(ciEnv* env, ciMethod* callee) {
// Create MDO if necessary.
void CompilationPolicy::create_mdo(const methodHandle& mh, JavaThread* THREAD) {
if (mh->is_native() ||
mh->is_abstract() /*||
mh->is_abstract() ||
mh->is_accessor() ||
mh->is_constant_getter()*/) {
mh->is_constant_getter()) {
return;
}
if (mh->method_data() == nullptr) {
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/g1/g1CardTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class G1CardTable : public CardTable {
}

static CardValue g1_scanned_card_val() { return g1_card_already_scanned; }
static CardValue g1_young_card_val() { return g1_young_card; }

void verify_region(MemRegion mr, CardValue val, bool val_equals) override;

Expand Down
16 changes: 13 additions & 3 deletions src/hotspot/share/oops/methodData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "prims/jvmtiRedefineClasses.hpp"
#include "runtime/atomic.hpp"
#include "runtime/deoptimization.hpp"
#include "runtime/globals.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/safepointVerifiers.hpp"
Expand Down Expand Up @@ -738,7 +739,11 @@ int MethodData::bytecode_cell_count(Bytecodes::Code code) {
}
case Bytecodes::_aastore:
if (TypeProfileCasts) {
return XXXProfileBarrier ? CombinedData::static_cell_count() : ReceiverTypeData::static_cell_count();
if (XXXProfileBarrier) {
return CombinedData::static_cell_count();
} else {
return ReceiverTypeData::static_cell_count();
}
} else {
ShouldNotReachHere();
return false;
Expand Down Expand Up @@ -1079,8 +1084,13 @@ int MethodData::initialize_data(BytecodeStream* stream,
break;
case Bytecodes::_aastore:
if (TypeProfileCasts) {
cell_count = XXXProfileBarrier ? CombinedData::static_cell_count() : ReceiverTypeData::static_cell_count();
tag = XXXProfileBarrier ? DataLayout::combined_data_tag : DataLayout::receiver_type_data_tag;
if (XXXProfileBarrier) {
cell_count = CombinedData::static_cell_count();
tag = DataLayout::combined_data_tag;
} else {
cell_count = ReceiverTypeData::static_cell_count();
tag = DataLayout::receiver_type_data_tag;
}
} else {
ShouldNotReachHere();
}
Expand Down

0 comments on commit dd74c56

Please sign in to comment.