diff --git a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp index b87779779a492..05a795bdf403e 100644 --- a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp @@ -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" @@ -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, @@ -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); } @@ -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, @@ -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 } } diff --git a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp index 5be05cc1674de..257a11a9002c8 100644 --- a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp @@ -29,6 +29,7 @@ #include "gc/shared/modRefBarrierSetAssembler.hpp" #include "utilities/macros.hpp" +class ciMethodData; class LIR_Assembler; class StubAssembler; class G1PreBarrierStub; @@ -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, @@ -90,6 +100,7 @@ class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { Register thread, Register tmp1, Register tmp2, + uint8_t barrier_data, uint ext_barrier_data); #endif diff --git a/src/hotspot/cpu/aarch64/gc/g1/g1_aarch64.ad b/src/hotspot/cpu/aarch64/gc/g1/g1_aarch64.ad index bd34adee5d850..63ea523056f1a 100644 --- a/src/hotspot/cpu/aarch64/gc/g1/g1_aarch64.ad +++ b/src/hotspot/cpu/aarch64/gc/g1/g1_aarch64.ad @@ -67,8 +67,7 @@ static void write_barrier_post(MacroAssembler* masm, } Assembler::InlineSkippedInstructionsCounter skip_counter(masm); G1BarrierSetAssembler* g1_asm = static_cast(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)); } %} diff --git a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp index fc83f173ec8dc..a8a405d060367 100644 --- a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp @@ -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()); @@ -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; @@ -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); diff --git a/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp index 14974dd26e6d8..838199e70f277 100644 --- a/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp @@ -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, diff --git a/src/hotspot/share/compiler/compilationPolicy.cpp b/src/hotspot/share/compiler/compilationPolicy.cpp index f8b7fabea5e41..122565f4f266e 100644 --- a/src/hotspot/share/compiler/compilationPolicy.cpp +++ b/src/hotspot/share/compiler/compilationPolicy.cpp @@ -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; } @@ -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) { diff --git a/src/hotspot/share/gc/g1/g1CardTable.hpp b/src/hotspot/share/gc/g1/g1CardTable.hpp index 8dd736a693083..3f37b33995d88 100644 --- a/src/hotspot/share/gc/g1/g1CardTable.hpp +++ b/src/hotspot/share/gc/g1/g1CardTable.hpp @@ -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; diff --git a/src/hotspot/share/oops/methodData.cpp b/src/hotspot/share/oops/methodData.cpp index 8192113ce8d38..d2d28244b0f0c 100644 --- a/src/hotspot/share/oops/methodData.cpp +++ b/src/hotspot/share/oops/methodData.cpp @@ -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" @@ -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; @@ -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(); }