Skip to content

Commit e35becd

Browse files
committed
Backport fc616588c1bf731150a9d9b80033bb589bcb231f
1 parent be5ae4c commit e35becd

File tree

8 files changed

+45
-39
lines changed

8 files changed

+45
-39
lines changed

src/hotspot/cpu/aarch64/templateTable_aarch64.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,12 @@ void TemplateTable::sipush()
309309
__ asrw(r0, r0, 16);
310310
}
311311

312-
void TemplateTable::ldc(bool wide)
312+
void TemplateTable::ldc(LdcType type)
313313
{
314314
transition(vtos, vtos);
315315
Label call_ldc, notFloat, notClass, notInt, Done;
316316

317-
if (wide) {
317+
if (is_ldc_wide(type)) {
318318
__ get_unsigned_2_byte_index_at_bcp(r1, 1);
319319
} else {
320320
__ load_unsigned_byte(r1, at_bcp(1));
@@ -343,7 +343,7 @@ void TemplateTable::ldc(bool wide)
343343
__ br(Assembler::NE, notClass);
344344

345345
__ bind(call_ldc);
346-
__ mov(c_rarg1, wide);
346+
__ mov(c_rarg1, is_ldc_wide(type) ? 1 : 0);
347347
call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), c_rarg1);
348348
__ push_ptr(r0);
349349
__ verify_oop(r0);
@@ -376,15 +376,15 @@ void TemplateTable::ldc(bool wide)
376376
}
377377

378378
// Fast path for caching oop constants.
379-
void TemplateTable::fast_aldc(bool wide)
379+
void TemplateTable::fast_aldc(LdcType type)
380380
{
381381
transition(vtos, atos);
382382

383383
Register result = r0;
384384
Register tmp = r1;
385385
Register rarg = r2;
386386

387-
int index_size = wide ? sizeof(u2) : sizeof(u1);
387+
int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1);
388388

389389
Label resolved;
390390

src/hotspot/cpu/arm/templateTable_arm.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ void TemplateTable::sipush() {
364364
}
365365

366366

367-
void TemplateTable::ldc(bool wide) {
367+
void TemplateTable::ldc(LdcType type) {
368368
transition(vtos, vtos);
369369
Label fastCase, Condy, Done;
370370

@@ -373,7 +373,7 @@ void TemplateTable::ldc(bool wide) {
373373
const Register Rtags = R3_tmp;
374374
const Register RtagType = R3_tmp;
375375

376-
if (wide) {
376+
if (is_ldc_wide(type)) {
377377
__ get_unsigned_2_byte_index_at_bcp(Rindex, 1);
378378
} else {
379379
__ ldrb(Rindex, at_bcp(1));
@@ -401,7 +401,7 @@ void TemplateTable::ldc(bool wide) {
401401
__ b(fastCase, ne);
402402

403403
// slow case - call runtime
404-
__ mov(R1, wide);
404+
__ mov(R1, is_ldc_wide(type) ? 1 : 0);
405405
call_VM(R0_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), R1);
406406
__ push(atos);
407407
__ b(Done);
@@ -429,9 +429,9 @@ void TemplateTable::ldc(bool wide) {
429429
}
430430

431431
// Fast path for caching oop constants.
432-
void TemplateTable::fast_aldc(bool wide) {
432+
void TemplateTable::fast_aldc(LdcType type) {
433433
transition(vtos, atos);
434-
int index_size = wide ? sizeof(u2) : sizeof(u1);
434+
int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1);
435435
Label resolved;
436436

437437
// We are resolved if the resolved reference cache entry contains a

src/hotspot/cpu/ppc/templateTable_ppc_64.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ void TemplateTable::sipush() {
237237
__ get_2_byte_integer_at_bcp(1, R17_tos, InterpreterMacroAssembler::Signed);
238238
}
239239

240-
void TemplateTable::ldc(bool wide) {
240+
void TemplateTable::ldc(LdcType type) {
241241
Register Rscratch1 = R11_scratch1,
242242
Rscratch2 = R12_scratch2,
243243
Rcpool = R3_ARG1;
@@ -246,7 +246,7 @@ void TemplateTable::ldc(bool wide) {
246246
Label notInt, notFloat, notClass, exit;
247247

248248
__ get_cpool_and_tags(Rcpool, Rscratch2); // Set Rscratch2 = &tags.
249-
if (wide) { // Read index.
249+
if (is_ldc_wide(type)) { // Read index.
250250
__ get_2_byte_integer_at_bcp(1, Rscratch1, InterpreterMacroAssembler::Unsigned);
251251
} else {
252252
__ lbz(Rscratch1, 1, R14_bcp);
@@ -268,7 +268,7 @@ void TemplateTable::ldc(bool wide) {
268268
__ crnor(CCR0, Assembler::equal, CCR1, Assembler::equal); // Neither resolved class nor unresolved case from above?
269269
__ beq(CCR0, notClass);
270270

271-
__ li(R4, wide ? 1 : 0);
271+
__ li(R4, is_ldc_wide(type) ? 1 : 0);
272272
call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), R4);
273273
__ push(atos);
274274
__ b(exit);
@@ -301,10 +301,10 @@ void TemplateTable::ldc(bool wide) {
301301
}
302302

303303
// Fast path for caching oop constants.
304-
void TemplateTable::fast_aldc(bool wide) {
304+
void TemplateTable::fast_aldc(LdcType type) {
305305
transition(vtos, atos);
306306

307-
int index_size = wide ? sizeof(u2) : sizeof(u1);
307+
int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1);
308308
Label is_null;
309309

310310
// We are resolved if the resolved reference cache entry contains a

src/hotspot/cpu/riscv/templateTable_riscv.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,12 @@ void TemplateTable::sipush()
300300
}
301301
}
302302

303-
void TemplateTable::ldc(bool wide)
303+
void TemplateTable::ldc(LdcType type)
304304
{
305305
transition(vtos, vtos);
306306
Label call_ldc, notFloat, notClass, notInt, Done;
307307

308-
if (wide) {
308+
if (is_ldc_wide(type)) {
309309
__ get_unsigned_2_byte_index_at_bcp(x11, 1);
310310
} else {
311311
__ load_unsigned_byte(x11, at_bcp(1));
@@ -335,7 +335,7 @@ void TemplateTable::ldc(bool wide)
335335
__ bne(x13, t1, notClass);
336336

337337
__ bind(call_ldc);
338-
__ mv(c_rarg1, wide);
338+
__ mv(c_rarg1, is_ldc_wide(type) ? 1 : 0);
339339
call_VM(x10, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), c_rarg1);
340340
__ push_ptr(x10);
341341
__ verify_oop(x10);
@@ -369,15 +369,15 @@ void TemplateTable::ldc(bool wide)
369369
}
370370

371371
// Fast path for caching oop constants.
372-
void TemplateTable::fast_aldc(bool wide)
372+
void TemplateTable::fast_aldc(LdcType type)
373373
{
374374
transition(vtos, atos);
375375

376376
const Register result = x10;
377377
const Register tmp = x11;
378378
const Register rarg = x12;
379379

380-
const int index_size = wide ? sizeof(u2) : sizeof(u1);
380+
const int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1);
381381

382382
Label resolved;
383383

src/hotspot/cpu/s390/templateTable_s390.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,13 @@ void TemplateTable::sipush() {
377377
}
378378

379379

380-
void TemplateTable::ldc(bool wide) {
380+
void TemplateTable::ldc(LdcType type) {
381381
transition(vtos, vtos);
382382
Label call_ldc, notFloat, notClass, notInt, Done;
383383
const Register RcpIndex = Z_tmp_1;
384384
const Register Rtags = Z_ARG2;
385385

386-
if (wide) {
386+
if (is_ldc_wide(type)) {
387387
__ get_2_byte_integer_at_bcp(RcpIndex, 1, InterpreterMacroAssembler::Unsigned);
388388
} else {
389389
__ z_llgc(RcpIndex, at_bcp(1));
@@ -411,7 +411,7 @@ void TemplateTable::ldc(bool wide) {
411411

412412
// We deal with a class. Call vm to do the appropriate.
413413
__ bind(call_ldc);
414-
__ load_const_optimized(Z_ARG2, wide);
414+
__ load_const_optimized(Z_ARG2, is_ldc_wide(type) ? 1 : 0);
415415
call_VM(Z_RET, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), Z_ARG2);
416416
__ push_ptr(Z_RET);
417417
__ z_bru(Done);
@@ -447,11 +447,11 @@ void TemplateTable::ldc(bool wide) {
447447
// Fast path for caching oop constants.
448448
// %%% We should use this to handle Class and String constants also.
449449
// %%% It will simplify the ldc/primitive path considerably.
450-
void TemplateTable::fast_aldc(bool wide) {
450+
void TemplateTable::fast_aldc(LdcType type) {
451451
transition(vtos, atos);
452452

453453
const Register index = Z_tmp_2;
454-
int index_size = wide ? sizeof(u2) : sizeof(u1);
454+
int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1);
455455
Label L_do_resolve, L_resolved;
456456

457457
// We are resolved if the resolved reference cache entry contains a

src/hotspot/cpu/x86/templateTable_x86.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,12 @@ void TemplateTable::sipush() {
350350
__ sarl(rax, 16);
351351
}
352352

353-
void TemplateTable::ldc(bool wide) {
353+
void TemplateTable::ldc(LdcType type) {
354354
transition(vtos, vtos);
355355
Register rarg = NOT_LP64(rcx) LP64_ONLY(c_rarg1);
356356
Label call_ldc, notFloat, notClass, notInt, Done;
357357

358-
if (wide) {
358+
if (is_ldc_wide(type)) {
359359
__ get_unsigned_2_byte_index_at_bcp(rbx, 1);
360360
} else {
361361
__ load_unsigned_byte(rbx, at_bcp(1));
@@ -383,7 +383,7 @@ void TemplateTable::ldc(bool wide) {
383383

384384
__ bind(call_ldc);
385385

386-
__ movl(rarg, wide);
386+
__ movl(rarg, is_ldc_wide(type) ? 1 : 0);
387387
call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), rarg);
388388

389389
__ push(atos);
@@ -415,13 +415,13 @@ void TemplateTable::ldc(bool wide) {
415415
}
416416

417417
// Fast path for caching oop constants.
418-
void TemplateTable::fast_aldc(bool wide) {
418+
void TemplateTable::fast_aldc(LdcType type) {
419419
transition(vtos, atos);
420420

421421
Register result = rax;
422422
Register tmp = rdx;
423423
Register rarg = NOT_LP64(rcx) LP64_ONLY(c_rarg1);
424-
int index_size = wide ? sizeof(u2) : sizeof(u1);
424+
int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1);
425425

426426
Label resolved;
427427

src/hotspot/share/interpreter/templateTable.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ void TemplateTable::def(Bytecodes::Code code, int flags, TosState in, TosState o
202202
}
203203

204204

205-
void TemplateTable::def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(bool arg ), bool arg) {
206-
def(code, flags, in, out, (Template::generator)gen, (int)arg);
205+
void TemplateTable::def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(LdcType ldct), LdcType ldct) {
206+
def(code, flags, in, out, (Template::generator)gen, (int)ldct);
207207
}
208208

209209

@@ -250,8 +250,8 @@ void TemplateTable::initialize() {
250250
def(Bytecodes::_dconst_1 , ____|____|____|____, vtos, dtos, dconst , 1 );
251251
def(Bytecodes::_bipush , ubcp|____|____|____, vtos, itos, bipush , _ );
252252
def(Bytecodes::_sipush , ubcp|____|____|____, vtos, itos, sipush , _ );
253-
def(Bytecodes::_ldc , ubcp|____|clvm|____, vtos, vtos, ldc , false );
254-
def(Bytecodes::_ldc_w , ubcp|____|clvm|____, vtos, vtos, ldc , true );
253+
def(Bytecodes::_ldc , ubcp|____|clvm|____, vtos, vtos, ldc , ldc_normal );
254+
def(Bytecodes::_ldc_w , ubcp|____|clvm|____, vtos, vtos, ldc , ldc_wide );
255255
def(Bytecodes::_ldc2_w , ubcp|____|clvm|____, vtos, vtos, ldc2_w , _ );
256256
def(Bytecodes::_iload , ubcp|____|clvm|____, vtos, itos, iload , _ );
257257
def(Bytecodes::_lload , ubcp|____|____|____, vtos, ltos, lload , _ );
@@ -484,8 +484,8 @@ void TemplateTable::initialize() {
484484
def(Bytecodes::_fast_linearswitch , ubcp|disp|____|____, itos, vtos, fast_linearswitch , _ );
485485
def(Bytecodes::_fast_binaryswitch , ubcp|disp|____|____, itos, vtos, fast_binaryswitch , _ );
486486

487-
def(Bytecodes::_fast_aldc , ubcp|____|clvm|____, vtos, atos, fast_aldc , false );
488-
def(Bytecodes::_fast_aldc_w , ubcp|____|clvm|____, vtos, atos, fast_aldc , true );
487+
def(Bytecodes::_fast_aldc , ubcp|____|clvm|____, vtos, atos, fast_aldc , ldc_normal );
488+
def(Bytecodes::_fast_aldc_w , ubcp|____|clvm|____, vtos, atos, fast_aldc , ldc_wide );
489489

490490
def(Bytecodes::_return_register_finalizer , ____|disp|clvm|____, vtos, vtos, _return , vtos );
491491

src/hotspot/share/interpreter/templateTable.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class TemplateTable: AllStatic {
8383
enum Operation { add, sub, mul, div, rem, _and, _or, _xor, shl, shr, ushr };
8484
enum Condition { equal, not_equal, less, less_equal, greater, greater_equal };
8585
enum CacheByte { f1_byte = 1, f2_byte = 2 }; // byte_no codes
86+
enum LdcType { ldc_normal = 0, ldc_wide = 1 }; // LDC type
8687
enum RewriteControl { may_rewrite, may_not_rewrite }; // control for fast code under CDS
8788

8889
private:
@@ -105,6 +106,11 @@ class TemplateTable: AllStatic {
105106
static void patch_bytecode(Bytecodes::Code bc, Register bc_reg,
106107
Register temp_reg, bool load_bc_into_bc_reg = true, int byte_no = -1);
107108

109+
static bool is_ldc_wide(LdcType type) {
110+
assert(type == ldc_wide || type == ldc_normal, "sanity");
111+
return (type == ldc_wide);
112+
}
113+
108114
// C calls
109115
static void call_VM(Register oop_result, address entry_point);
110116
static void call_VM(Register oop_result, address entry_point, Register arg_1);
@@ -128,9 +134,9 @@ class TemplateTable: AllStatic {
128134

129135
static void bipush();
130136
static void sipush();
131-
static void ldc(bool wide);
137+
static void ldc(LdcType type);
132138
static void ldc2_w();
133-
static void fast_aldc(bool wide);
139+
static void fast_aldc(LdcType type);
134140

135141
static void locals_index(Register reg, int offset = 1);
136142
static void iload();
@@ -327,7 +333,7 @@ class TemplateTable: AllStatic {
327333
// initialization helpers
328334
static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)( ), char filler );
329335
static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(int arg ), int arg );
330-
static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(bool arg ), bool arg );
336+
static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(LdcType ldct), LdcType ldct);
331337
static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(TosState tos), TosState tos);
332338
static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Operation op), Operation op);
333339
static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Condition cc), Condition cc);

0 commit comments

Comments
 (0)