1.1 --- a/src/cpu/x86/vm/templateTable_x86_32.cpp Mon Jan 11 13:41:45 2016 -0800 1.2 +++ b/src/cpu/x86/vm/templateTable_x86_32.cpp Fri Jan 15 22:33:15 2016 +0000 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -212,6 +212,7 @@ 1.11 switch (bc) { 1.12 case Bytecodes::_fast_aputfield: 1.13 case Bytecodes::_fast_bputfield: 1.14 + case Bytecodes::_fast_zputfield: 1.15 case Bytecodes::_fast_cputfield: 1.16 case Bytecodes::_fast_dputfield: 1.17 case Bytecodes::_fast_fputfield: 1.18 @@ -988,11 +989,21 @@ 1.19 void TemplateTable::bastore() { 1.20 transition(itos, vtos); 1.21 __ pop_i(rbx); 1.22 - // rax,: value 1.23 + // rax: value 1.24 + // rbx: index 1.25 // rdx: array 1.26 - index_check(rdx, rbx); // prefer index in rbx, 1.27 - // rbx,: index 1.28 - __ movb(Address(rdx, rbx, Address::times_1, arrayOopDesc::base_offset_in_bytes(T_BYTE)), rax); 1.29 + index_check(rdx, rbx); // prefer index in rbx 1.30 + // Need to check whether array is boolean or byte 1.31 + // since both types share the bastore bytecode. 1.32 + __ load_klass(rcx, rdx); 1.33 + __ movl(rcx, Address(rcx, Klass::layout_helper_offset())); 1.34 + int diffbit = Klass::layout_helper_boolean_diffbit(); 1.35 + __ testl(rcx, diffbit); 1.36 + Label L_skip; 1.37 + __ jccb(Assembler::zero, L_skip); 1.38 + __ andl(rax, 1); // if it is a T_BOOLEAN array, mask the stored value to 0/1 1.39 + __ bind(L_skip); 1.40 + __ movb(Address(rdx, rbx, Address::times_1, arrayOopDesc::base_offset_in_bytes(T_BYTE)), rax); 1.41 } 1.42 1.43 1.44 @@ -2037,7 +2048,14 @@ 1.45 __ bind(skip_register_finalizer); 1.46 } 1.47 1.48 + // Narrow result if state is itos but result type is smaller. 1.49 + // Need to narrow in the return bytecode rather than in generate_return_entry 1.50 + // since compiled code callers expect the result to already be narrowed. 1.51 + if (state == itos) { 1.52 + __ narrow(rax); 1.53 + } 1.54 __ remove_activation(state, rsi); 1.55 + 1.56 __ jmp(rsi); 1.57 } 1.58 1.59 @@ -2234,7 +2252,7 @@ 1.60 const Address lo(obj, off, Address::times_1, 0*wordSize); 1.61 const Address hi(obj, off, Address::times_1, 1*wordSize); 1.62 1.63 - Label Done, notByte, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; 1.64 + Label Done, notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; 1.65 1.66 __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift); 1.67 assert(btos == 0, "change code, btos != 0"); 1.68 @@ -2251,6 +2269,22 @@ 1.69 __ jmp(Done); 1.70 1.71 __ bind(notByte); 1.72 + 1.73 + __ cmpl(flags, ztos); 1.74 + __ jcc(Assembler::notEqual, notBool); 1.75 + 1.76 + // ztos (same code as btos) 1.77 + __ load_signed_byte(rax, lo); 1.78 + __ push(ztos); 1.79 + // Rewrite bytecode to be faster 1.80 + if (!is_static) { 1.81 + // use btos rewriting, no truncating to t/f bit is needed for getfield. 1.82 + patch_bytecode(Bytecodes::_fast_bgetfield, rcx, rbx); 1.83 + } 1.84 + __ jmp(Done); 1.85 + 1.86 + __ bind(notBool); 1.87 + 1.88 // itos 1.89 __ cmpl(flags, itos ); 1.90 __ jcc(Assembler::notEqual, notInt); 1.91 @@ -2450,7 +2484,7 @@ 1.92 const Address lo(obj, off, Address::times_1, 0*wordSize); 1.93 const Address hi(obj, off, Address::times_1, 1*wordSize); 1.94 1.95 - Label notByte, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; 1.96 + Label notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; 1.97 1.98 __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift); 1.99 assert(btos == 0, "change code, btos != 0"); 1.100 @@ -2469,6 +2503,22 @@ 1.101 } 1.102 1.103 __ bind(notByte); 1.104 + __ cmpl(flags, ztos); 1.105 + __ jcc(Assembler::notEqual, notBool); 1.106 + 1.107 + // ztos 1.108 + { 1.109 + __ pop(ztos); 1.110 + if (!is_static) pop_and_check_object(obj); 1.111 + __ andl(rax, 0x1); 1.112 + __ movb(lo, rax); 1.113 + if (!is_static) { 1.114 + patch_bytecode(Bytecodes::_fast_zputfield, rcx, rbx, true, byte_no); 1.115 + } 1.116 + __ jmp(Done); 1.117 + } 1.118 + 1.119 + __ bind(notBool); 1.120 __ cmpl(flags, itos); 1.121 __ jcc(Assembler::notEqual, notInt); 1.122 1.123 @@ -2640,6 +2690,7 @@ 1.124 switch (bytecode()) { // load values into the jvalue object 1.125 case Bytecodes::_fast_aputfield: __ push_ptr(rax); break; 1.126 case Bytecodes::_fast_bputfield: // fall through 1.127 + case Bytecodes::_fast_zputfield: // fall through 1.128 case Bytecodes::_fast_sputfield: // fall through 1.129 case Bytecodes::_fast_cputfield: // fall through 1.130 case Bytecodes::_fast_iputfield: __ push_i(rax); break; 1.131 @@ -2662,6 +2713,7 @@ 1.132 switch (bytecode()) { // restore tos values 1.133 case Bytecodes::_fast_aputfield: __ pop_ptr(rax); break; 1.134 case Bytecodes::_fast_bputfield: // fall through 1.135 + case Bytecodes::_fast_zputfield: // fall through 1.136 case Bytecodes::_fast_sputfield: // fall through 1.137 case Bytecodes::_fast_cputfield: // fall through 1.138 case Bytecodes::_fast_iputfield: __ pop_i(rax); break; 1.139 @@ -2712,6 +2764,8 @@ 1.140 1.141 // access field 1.142 switch (bytecode()) { 1.143 + case Bytecodes::_fast_zputfield: __ andl(rax, 0x1); // boolean is true if LSB is 1 1.144 + // fall through to bputfield 1.145 case Bytecodes::_fast_bputfield: __ movb(lo, rax); break; 1.146 case Bytecodes::_fast_sputfield: // fall through 1.147 case Bytecodes::_fast_cputfield: __ movw(lo, rax); break; 1.148 @@ -2746,6 +2800,8 @@ 1.149 1.150 // access field 1.151 switch (bytecode()) { 1.152 + case Bytecodes::_fast_zputfield: __ andl(rax, 0x1); // boolean is true if LSB is 1 1.153 + // fall through to bputfield 1.154 case Bytecodes::_fast_bputfield: __ movb(lo, rax); break; 1.155 case Bytecodes::_fast_sputfield: // fall through 1.156 case Bytecodes::_fast_cputfield: __ movw(lo, rax); break;