Skip to content

Commit 4be502e

Browse files
dbriemannTheRealMDoerr
authored andcommitted
8350642: Interpreter: Upgrade CountBytecodes to 64 bit on 64 bit platforms
Reviewed-by: lmesnik, mdoerr, shade
1 parent 1fe4526 commit 4be502e

12 files changed

+109
-22
lines changed

src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,7 @@ address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
21022102

21032103
void TemplateInterpreterGenerator::count_bytecode() {
21042104
__ mov(r10, (address) &BytecodeCounter::_counter_value);
2105-
__ atomic_addw(noreg, 1, r10);
2105+
__ atomic_add(noreg, 1, r10);
21062106
}
21072107

21082108
void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
@@ -2150,7 +2150,7 @@ void TemplateInterpreterGenerator::stop_interpreter_at() {
21502150
__ mov(rscratch1, (address) &BytecodeCounter::_counter_value);
21512151
__ ldr(rscratch1, Address(rscratch1));
21522152
__ mov(rscratch2, StopInterpreterAt);
2153-
__ cmpw(rscratch1, rscratch2);
2153+
__ cmp(rscratch1, rscratch2);
21542154
__ br(Assembler::NE, L);
21552155
__ brk(0);
21562156
__ bind(L);

src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,11 +2328,11 @@ address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
23282328
// Support short-cut for TraceBytecodesAt.
23292329
// Don't call into the VM if we don't want to trace to speed up things.
23302330
Label Lskip_vm_call;
2331-
if (TraceBytecodesAt > 0 && TraceBytecodesAt < max_intx) {
2331+
if (TraceBytecodesAt > 0) {
23322332
int offs1 = __ load_const_optimized(R11_scratch1, (address) &TraceBytecodesAt, R0, true);
23332333
int offs2 = __ load_const_optimized(R12_scratch2, (address) &BytecodeCounter::_counter_value, R0, true);
23342334
__ ld(R11_scratch1, offs1, R11_scratch1);
2335-
__ lwa(R12_scratch2, offs2, R12_scratch2);
2335+
__ ld(R12_scratch2, offs2, R12_scratch2);
23362336
__ cmpd(CR0, R12_scratch2, R11_scratch1);
23372337
__ blt(CR0, Lskip_vm_call);
23382338
}
@@ -2346,7 +2346,7 @@ address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
23462346
__ mtlr(R31);
23472347
__ pop(state);
23482348

2349-
if (TraceBytecodesAt > 0 && TraceBytecodesAt < max_intx) {
2349+
if (TraceBytecodesAt > 0) {
23502350
__ bind(Lskip_vm_call);
23512351
}
23522352
__ blr();
@@ -2356,9 +2356,9 @@ address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
23562356

23572357
void TemplateInterpreterGenerator::count_bytecode() {
23582358
int offs = __ load_const_optimized(R11_scratch1, (address) &BytecodeCounter::_counter_value, R12_scratch2, true);
2359-
__ lwz(R12_scratch2, offs, R11_scratch1);
2359+
__ ld(R12_scratch2, offs, R11_scratch1);
23602360
__ addi(R12_scratch2, R12_scratch2, 1);
2361-
__ stw(R12_scratch2, offs, R11_scratch1);
2361+
__ std(R12_scratch2, offs, R11_scratch1);
23622362
}
23632363

23642364
void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
@@ -2407,7 +2407,7 @@ void TemplateInterpreterGenerator::stop_interpreter_at() {
24072407
int offs1 = __ load_const_optimized(R11_scratch1, (address) &StopInterpreterAt, R0, true);
24082408
int offs2 = __ load_const_optimized(R12_scratch2, (address) &BytecodeCounter::_counter_value, R0, true);
24092409
__ ld(R11_scratch1, offs1, R11_scratch1);
2410-
__ lwa(R12_scratch2, offs2, R12_scratch2);
2410+
__ ld(R12_scratch2, offs2, R12_scratch2);
24112411
__ cmpd(CR0, R12_scratch2, R11_scratch1);
24122412
__ bne(CR0, L);
24132413
__ illtrap();

src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,7 @@ address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
18461846

18471847
void TemplateInterpreterGenerator::count_bytecode() {
18481848
__ mv(x7, (address) &BytecodeCounter::_counter_value);
1849-
__ atomic_addw(noreg, 1, x7);
1849+
__ atomic_add(noreg, 1, x7);
18501850
}
18511851

18521852
void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {

src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
23292329
// Skip runtime call, if the trace threshold is not yet reached.
23302330
__ load_absolute_address(Z_tmp_1, (address)&BytecodeCounter::_counter_value);
23312331
__ load_absolute_address(Z_tmp_2, (address)&TraceBytecodesAt);
2332-
__ load_sized_value(Z_tmp_1, Address(Z_tmp_1), 4, false /*signed*/);
2332+
__ load_sized_value(Z_tmp_1, Address(Z_tmp_1), 8, false /*signed*/);
23332333
__ load_sized_value(Z_tmp_2, Address(Z_tmp_2), 8, false /*signed*/);
23342334
__ compareU64_and_branch(Z_tmp_1, Z_tmp_2, Assembler::bcondLow, counter_below_trace_threshold);
23352335
}
@@ -2359,7 +2359,7 @@ address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
23592359
// Make feasible for old CPUs.
23602360
void TemplateInterpreterGenerator::count_bytecode() {
23612361
__ load_absolute_address(Z_R1_scratch, (address) &BytecodeCounter::_counter_value);
2362-
__ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch);
2362+
__ add2mem_64(Address(Z_R1_scratch), 1, Z_R0_scratch);
23632363
}
23642364

23652365
void TemplateInterpreterGenerator::histogram_bytecode(Template * t) {
@@ -2406,7 +2406,7 @@ void TemplateInterpreterGenerator::stop_interpreter_at() {
24062406

24072407
__ load_absolute_address(Z_tmp_1, (address)&BytecodeCounter::_counter_value);
24082408
__ load_absolute_address(Z_tmp_2, (address)&StopInterpreterAt);
2409-
__ load_sized_value(Z_tmp_1, Address(Z_tmp_1), 4, false /*signed*/);
2409+
__ load_sized_value(Z_tmp_1, Address(Z_tmp_1), 8, false /*signed*/);
24102410
__ load_sized_value(Z_tmp_2, Address(Z_tmp_2), 8, false /*signed*/);
24112411
__ compareU64_and_branch(Z_tmp_1, Z_tmp_2, Assembler::bcondLow, L);
24122412
assert(Z_tmp_1->is_nonvolatile(), "must be nonvolatile to preserve Z_tos");

src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,11 @@ address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
18741874
}
18751875

18761876
void TemplateInterpreterGenerator::count_bytecode() {
1877+
#ifndef _LP64
18771878
__ incrementl(ExternalAddress((address) &BytecodeCounter::_counter_value), rscratch1);
1879+
#else
1880+
__ incrementq(ExternalAddress((address) &BytecodeCounter::_counter_value), rscratch1);
1881+
#endif
18781882
}
18791883

18801884
void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
@@ -1914,9 +1918,14 @@ void TemplateInterpreterGenerator::trace_bytecode(Template* t) {
19141918

19151919
void TemplateInterpreterGenerator::stop_interpreter_at() {
19161920
Label L;
1921+
#ifndef _LP64
19171922
__ cmp32(ExternalAddress((address) &BytecodeCounter::_counter_value),
19181923
StopInterpreterAt,
19191924
rscratch1);
1925+
#else
1926+
__ mov64(rscratch1, StopInterpreterAt);
1927+
__ cmp64(rscratch1, ExternalAddress((address) &BytecodeCounter::_counter_value), rscratch2);
1928+
#endif
19201929
__ jcc(Assembler::notEqual, L);
19211930
__ int3();
19221931
__ bind(L);

src/hotspot/share/interpreter/bytecodeHistogram.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
// Implementation of BytecodeCounter
3535

36-
int BytecodeCounter::_counter_value = 0;
36+
uintx BytecodeCounter::_counter_value = 0;
3737
jlong BytecodeCounter::_reset_time = 0;
3838

3939

@@ -55,7 +55,7 @@ double BytecodeCounter::frequency() {
5555

5656
void BytecodeCounter::print() {
5757
tty->print_cr(
58-
"%d bytecodes executed in %.1fs (%.3fMHz)",
58+
"%zu bytecodes executed in %.1fs (%.3fMHz)",
5959
counter_value(),
6060
elapsed_time(),
6161
frequency() / 1000000.0

src/hotspot/share/interpreter/bytecodeHistogram.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
class BytecodeCounter: AllStatic {
3434
private:
35-
NOT_PRODUCT(static int _counter_value;)
35+
NOT_PRODUCT(static uintx _counter_value;)
3636
NOT_PRODUCT(static jlong _reset_time;)
3737

3838
friend class TemplateInterpreterGenerator;
@@ -43,7 +43,7 @@ class BytecodeCounter: AllStatic {
4343
static void reset() PRODUCT_RETURN;
4444

4545
// Counter info (all info since last reset)
46-
static int counter_value() PRODUCT_RETURN0 NOT_PRODUCT({ return _counter_value; });
46+
static uintx counter_value() PRODUCT_RETURN0 NOT_PRODUCT({ return _counter_value; });
4747
static double elapsed_time() PRODUCT_RETURN0; // in seconds
4848
static double frequency() PRODUCT_RETURN0; // bytecodes/seconds
4949

src/hotspot/share/interpreter/bytecodeTracer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ class BytecodePrinter {
129129
int bci = (int)(bcp - method->code_base());
130130
st->print("[%zu] ", Thread::current()->osthread()->thread_id_for_printing());
131131
if (Verbose) {
132-
st->print("%8d %4d " INTPTR_FORMAT " " INTPTR_FORMAT " %s",
132+
st->print("%8zu %4d " INTPTR_FORMAT " " INTPTR_FORMAT " %s",
133133
BytecodeCounter::counter_value(), bci, tos, tos2, Bytecodes::name(code));
134134
} else {
135-
st->print("%8d %4d %s",
135+
st->print("%8zu %4d %s",
136136
BytecodeCounter::counter_value(), bci, Bytecodes::name(code));
137137
}
138138
print_attributes(bci, st);

src/hotspot/share/runtime/globals.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,13 +1566,13 @@ const int ObjectAlignmentInBytes = 8;
15661566
"Minimal number of lookupswitch entries for rewriting to binary " \
15671567
"switch") \
15681568
\
1569-
develop(intx, StopInterpreterAt, 0, \
1569+
develop(uintx, StopInterpreterAt, 0, \
15701570
"Stop interpreter execution at specified bytecode number") \
15711571
\
1572-
develop(intx, TraceBytecodesAt, 0, \
1572+
develop(uintx, TraceBytecodesAt, 0, \
15731573
"Trace bytecodes starting with specified bytecode number") \
15741574
\
1575-
develop(intx, TraceBytecodesStopAt, 0, \
1575+
develop(uintx, TraceBytecodesStopAt, 0, \
15761576
"Stop bytecode tracing at the specified bytecode number") \
15771577
\
15781578
/* Priorities */ \

src/hotspot/share/runtime/java.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static void print_method_invocation_histogram() {
231231

232232
static void print_bytecode_count() {
233233
if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
234-
tty->print_cr("[BytecodeCounter::counter_value = %d]", BytecodeCounter::counter_value());
234+
tty->print_cr("[BytecodeCounter::counter_value = %zu]", BytecodeCounter::counter_value());
235235
}
236236
}
237237

0 commit comments

Comments
 (0)