# HG changeset patch # User fujie # Date 1523326909 -28800 # Node ID e3f4d3592615f469a1554dbac4dba65a13523fcf # Parent 69619c96717a265bc1cfae778bc44bdcf190a6ee [Upgrade] jdk8u77-b03 --> jdk8u91-b15 (ztos support for MIPS) diff -r 69619c96717a -r e3f4d3592615 src/cpu/mips/vm/interp_masm_mips_64.cpp --- a/src/cpu/mips/vm/interp_masm_mips_64.cpp Thu May 24 18:59:17 2018 +0800 +++ b/src/cpu/mips/vm/interp_masm_mips_64.cpp Tue Apr 10 10:21:49 2018 +0800 @@ -219,6 +219,7 @@ ld_ptr(V0, val_addr); // fall through break; case btos: // fall through + case ztos: // fall through case ctos: // fall through case stos: // fall through case itos: @@ -466,6 +467,7 @@ switch (state) { case atos: pop_ptr(); break; case btos: + case ztos: case ctos: case stos: case itos: pop_i(); break; @@ -484,6 +486,7 @@ switch (state) { case atos: push_ptr(); break; case btos: + case ztos: case ctos: case stos: case itos: push_i(); break; @@ -572,7 +575,7 @@ if((long)table >= (long)Interpreter::dispatch_table(btos) && (long)table <= (long)Interpreter::dispatch_table(vtos) ) { - int table_size = (long)Interpreter::dispatch_table(ctos) - (long)Interpreter::dispatch_table(btos); + int table_size = (long)Interpreter::dispatch_table(itos) - (long)Interpreter::dispatch_table(stos); int table_offset = ((int)state - (int)itos) * table_size; // 2013/12/17 Fu: GP points to the starting address of Interpreter::dispatch_table(itos). @@ -1626,6 +1629,53 @@ } } + +void InterpreterMacroAssembler::narrow(Register result) { + + // Get method->_constMethod->_result_type + ld(T9, FP, frame::interpreter_frame_method_offset * wordSize); + ld(T9, T9, in_bytes(Method::const_offset())); + lbu(T9, T9, in_bytes(ConstMethod::result_type_offset())); + + Label done, notBool, notByte, notChar; + + // common case first + addiu(AT, T9, -T_INT); + beq(AT, R0, done); + nop(); + + // mask integer result to narrower return type. + addiu(AT, T9, -T_BOOLEAN); + bne(AT, R0, notBool); + nop(); + andi(result, result, 0x1); + beq(R0, R0, done); + nop(); + + bind(notBool); + addiu(AT, T9, -T_BYTE); + bne(AT, R0, notByte); + nop(); + seb(result, result); + beq(R0, R0, done); + nop(); + + bind(notByte); + addiu(AT, T9, -T_CHAR); + bne(AT, R0, notChar); + nop(); + andi(result, result, 0xFFFF); + beq(R0, R0, done); + nop(); + + bind(notChar); + seh(result, result); + + // Nothing to do for T_INT + bind(done); +} + + void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) { Label update, next, none; diff -r 69619c96717a -r e3f4d3592615 src/cpu/mips/vm/interp_masm_mips_64.hpp --- a/src/cpu/mips/vm/interp_masm_mips_64.hpp Thu May 24 18:59:17 2018 +0800 +++ b/src/cpu/mips/vm/interp_masm_mips_64.hpp Tue Apr 10 10:21:49 2018 +0800 @@ -62,6 +62,9 @@ #endif // CC_INTERP public: + // narrow int return value + void narrow(Register result); + InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code), _locals_register(LVP), _bcp_register(BCP) {} void get_2_byte_integer_at_bcp(Register reg, Register tmp, int offset); diff -r 69619c96717a -r e3f4d3592615 src/cpu/mips/vm/templateInterpreter_mips_64.cpp --- a/src/cpu/mips/vm/templateInterpreter_mips_64.cpp Thu May 24 18:59:17 2018 +0800 +++ b/src/cpu/mips/vm/templateInterpreter_mips_64.cpp Tue Apr 10 10:21:49 2018 +0800 @@ -684,7 +684,7 @@ __ dadd(T1, T1, T2); __ lw(T3, T1, 0); - Label notByte, notShort, notChar, notObj; + Label notByte, notBool, notShort, notChar, notObj; // const Address field_address (eax, esi, Address::times_1); // Need to differentiate between igetfield, agetfield, bgetfield etc. @@ -701,8 +701,17 @@ __ b(xreturn_path); __ delayed()->nop(); + //ztos + __ bind(notByte); + __ daddi(T1, T3, (-1) * ztos); + __ bne(T1, R0, notBool); + __ delayed()->nop(); + __ lb(V0, T0, 0); + __ b(xreturn_path); + __ delayed()->nop(); + //stos - __ bind(notByte); + __ bind(notBool); __ daddi(T1, T3, (-1) * stos); __ bne(T1, R0, notShort); __ delayed()->nop(); diff -r 69619c96717a -r e3f4d3592615 src/cpu/mips/vm/templateTable_mips_64.cpp --- a/src/cpu/mips/vm/templateTable_mips_64.cpp Thu May 24 18:59:17 2018 +0800 +++ b/src/cpu/mips/vm/templateTable_mips_64.cpp Tue Apr 10 10:21:49 2018 +0800 @@ -194,6 +194,7 @@ switch (bc) { case Bytecodes::_fast_aputfield: case Bytecodes::_fast_bputfield: + case Bytecodes::_fast_zputfield: case Bytecodes::_fast_cputfield: case Bytecodes::_fast_dputfield: case Bytecodes::_fast_fputfield: @@ -1217,6 +1218,7 @@ transition(itos, vtos); __ pop_i(SSR); if(UseBoundCheckInstruction) { + guarantee(false, "unimplemented yet!"); __ pop_ptr(T2); __ dadd(SSR, T2, SSR); __ addi(SSR, SSR, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // base @@ -1228,6 +1230,22 @@ __ gssble(FSR, SSR, AT); } else { index_check(T2, SSR); + + // Need to check whether array is boolean or byte + // since both types share the bastore bytecode. + __ load_klass(T9, T2); + __ lw(T9, T9, in_bytes(Klass::layout_helper_offset())); + + int diffbit = Klass::layout_helper_boolean_diffbit(); + __ move(AT, diffbit); + + Label L_skip; + __ andr(AT, T9, AT); + __ beq(AT, R0, L_skip); + __ nop(); + __ andi(FSR, FSR, 0x1); + __ bind(L_skip); + if (UseLoongsonISA && Assembler::is_simm(arrayOopDesc::base_offset_in_bytes(T_BYTE), 8)) { __ gssbx(FSR, T2, SSR, arrayOopDesc::base_offset_in_bytes(T_BYTE)); } else { @@ -2561,6 +2579,14 @@ InterpreterRuntime::register_finalizer), T1); __ bind(skip_register_finalizer); } + + // Narrow result if state is itos but result type is smaller. + // Need to narrow in the return bytecode rather than in generate_return_entry + // since compiled code callers expect the result to already be narrowed. + if (state == itos) { + __ narrow(FSR); + } + __ remove_activation(state, T9); __ sync(); @@ -2825,12 +2851,12 @@ __ dadd(index, obj, off); - Label Done, notByte, notInt, notShort, notChar, + Label Done, notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; assert(btos == 0, "change code, btos != 0"); __ dsrl(flags, flags, ConstantPoolCacheEntry::tos_state_shift); - __ andi(flags, flags, 0xf); + __ andi(flags, flags, ConstantPoolCacheEntry::tos_state_mask); __ bne(flags, R0, notByte); __ delayed()->nop(); @@ -2845,7 +2871,26 @@ __ b(Done); __ delayed()->daddi(SP, SP, - wordSize); + __ bind(notByte); + __ move(AT, ztos); + __ bne(flags, AT, notBool); + __ delayed()->nop(); + + // ztos + __ lb(FSR, index, 0); + __ sd(FSR, SP, - wordSize); + + // Rewrite bytecode to be faster + if (!is_static) { + // patch_bytecode(Bytecodes::_fast_igetfield, T3, T2); + patch_bytecode(Bytecodes::_fast_bgetfield, T3, T2); + } + __ b(Done); + __ delayed()->daddi(SP, SP, - wordSize); + + + __ bind(notBool); __ move(AT, itos); __ bne(flags, AT, notInt); __ delayed()->nop(); @@ -3096,7 +3141,7 @@ } - Label notByte, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; + Label notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; assert(btos == 0, "change code, btos != 0"); @@ -3119,8 +3164,28 @@ __ b(Done); __ delayed()->nop(); + // ztos + __ bind(notByte); + __ move(AT, ztos); + __ bne(flags, AT, notBool); + __ delayed()->nop(); + + __ pop(ztos); + if (!is_static) { + pop_and_check_object(obj); + } + __ dadd(AT, obj, off); + __ andi(FSR, FSR, 0x1); + __ sb(FSR, AT, 0); + + if (!is_static) { + patch_bytecode(Bytecodes::_fast_zputfield, bc, off, true, byte_no); + } + __ b(Done); + __ delayed()->nop(); + // itos - __ bind(notByte); + __ bind(notBool); __ move(AT, itos); __ bne(flags, AT, notInt); __ delayed()->nop(); @@ -3299,6 +3364,7 @@ switch (bytecode()) { // load values into the jvalue object case Bytecodes::_fast_aputfield: __ push_ptr(FSR); break; case Bytecodes::_fast_bputfield: // fall through + case Bytecodes::_fast_zputfield: // fall through case Bytecodes::_fast_sputfield: // fall through case Bytecodes::_fast_cputfield: // fall through case Bytecodes::_fast_iputfield: __ push_i(FSR); break; @@ -3322,6 +3388,7 @@ switch (bytecode()) { // restore tos values case Bytecodes::_fast_aputfield: __ pop_ptr(FSR); break; case Bytecodes::_fast_bputfield: // fall through + case Bytecodes::_fast_zputfield: // fall through case Bytecodes::_fast_sputfield: // fall through case Bytecodes::_fast_cputfield: // fall through case Bytecodes::_fast_iputfield: __ pop_i(FSR); break; @@ -3379,6 +3446,9 @@ // access field switch (bytecode()) { + case Bytecodes::_fast_zputfield: + __ andi(FSR, FSR, 0x1); // boolean is true if LSB is 1 + // fall through to bputfield case Bytecodes::_fast_bputfield: __ sb(FSR, T2, 0); break;