Skip to content

Commit

Permalink
8296301: Interpreter(RISC-V): Implement -XX:+PrintBytecodeHistogram a…
Browse files Browse the repository at this point in the history
…nd -XX:+PrintBytecodePairHistogram options

Reviewed-by: fjiang, fyang
  • Loading branch information
Yanhong Zhu authored and RealFYang committed Nov 11, 2022
1 parent f754840 commit d4d183e
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,18 +1737,35 @@ address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
}

void TemplateInterpreterGenerator::count_bytecode() {
__ push_reg(t0);
__ push_reg(x10);
__ mv(x10, (address) &BytecodeCounter::_counter_value);
__ mv(t0, 1);
__ amoadd_d(zr, x10, t0, Assembler::aqrl);
__ pop_reg(x10);
__ pop_reg(t0);
__ mv(x7, (address) &BytecodeCounter::_counter_value);
__ atomic_addw(noreg, 1, x7);
}

void TemplateInterpreterGenerator::histogram_bytecode(Template* t) { ; }
void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
__ mv(x7, (address) &BytecodeHistogram::_counters[t->bytecode()]);
__ atomic_addw(noreg, 1, x7);
}

void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) { ; }
void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) {
// Calculate new index for counter:
// _index = (_index >> log2_number_of_codes) |
// (bytecode << log2_number_of_codes);
Register index_addr = t1;
Register index = t0;
__ mv(index_addr, (address) &BytecodePairHistogram::_index);
__ lw(index, index_addr);
__ mv(x7, ((int)t->bytecode()) << BytecodePairHistogram::log2_number_of_codes);
__ srli(index, index, BytecodePairHistogram::log2_number_of_codes);
__ orrw(index, x7, index);
__ sw(index, index_addr);
// Bump bucket contents:
// _counters[_index] ++;
Register counter_addr = t1;
__ mv(x7, (address) &BytecodePairHistogram::_counters);
__ slli(index, index, LogBytesPerInt);
__ add(counter_addr, x7, index);
__ atomic_addw(noreg, 1, counter_addr);
}

void TemplateInterpreterGenerator::trace_bytecode(Template* t) {
// Call a little run-time stub to avoid blow-up for each bytecode.
Expand Down

1 comment on commit d4d183e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.