1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
165 Label L_patch_done; |
165 Label L_patch_done; |
166 |
166 |
167 switch (bc) { |
167 switch (bc) { |
168 case Bytecodes::_fast_aputfield: |
168 case Bytecodes::_fast_aputfield: |
169 case Bytecodes::_fast_bputfield: |
169 case Bytecodes::_fast_bputfield: |
|
170 case Bytecodes::_fast_zputfield: |
170 case Bytecodes::_fast_cputfield: |
171 case Bytecodes::_fast_cputfield: |
171 case Bytecodes::_fast_dputfield: |
172 case Bytecodes::_fast_dputfield: |
172 case Bytecodes::_fast_fputfield: |
173 case Bytecodes::_fast_fputfield: |
173 case Bytecodes::_fast_iputfield: |
174 case Bytecodes::_fast_iputfield: |
174 case Bytecodes::_fast_lputfield: |
175 case Bytecodes::_fast_lputfield: |
911 |
912 |
912 void TemplateTable::bastore() { |
913 void TemplateTable::bastore() { |
913 transition(itos, vtos); |
914 transition(itos, vtos); |
914 __ pop_i(O2); // index |
915 __ pop_i(O2); // index |
915 // Otos_i: val |
916 // Otos_i: val |
|
917 // O2: index |
916 // O3: array |
918 // O3: array |
917 __ index_check(O3, O2, 0, G3_scratch, O2); |
919 __ index_check(O3, O2, 0, G3_scratch, O2); |
|
920 // Need to check whether array is boolean or byte |
|
921 // since both types share the bastore bytecode. |
|
922 __ load_klass(O3, G4_scratch); |
|
923 __ ld(G4_scratch, in_bytes(Klass::layout_helper_offset()), G4_scratch); |
|
924 __ set(Klass::layout_helper_boolean_diffbit(), G3_scratch); |
|
925 __ andcc(G3_scratch, G4_scratch, G0); |
|
926 Label L_skip; |
|
927 __ br(Assembler::zero, false, Assembler::pn, L_skip); |
|
928 __ delayed()->nop(); |
|
929 __ and3(Otos_i, 1, Otos_i); // if it is a T_BOOLEAN array, mask the stored value to 0/1 |
|
930 __ bind(L_skip); |
918 __ stb(Otos_i, O2, arrayOopDesc::base_offset_in_bytes(T_BYTE)); |
931 __ stb(Otos_i, O2, arrayOopDesc::base_offset_in_bytes(T_BYTE)); |
919 } |
932 } |
920 |
933 |
921 |
934 |
922 void TemplateTable::castore() { |
935 void TemplateTable::castore() { |
1995 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), Otos_i); |
2008 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), Otos_i); |
1996 |
2009 |
1997 __ bind(skip_register_finalizer); |
2010 __ bind(skip_register_finalizer); |
1998 } |
2011 } |
1999 |
2012 |
|
2013 // Narrow result if state is itos but result type is smaller. |
|
2014 // Need to narrow in the return bytecode rather than in generate_return_entry |
|
2015 // since compiled code callers expect the result to already be narrowed. |
|
2016 if (state == itos) { |
|
2017 __ narrow(Otos_i); |
|
2018 } |
2000 __ remove_activation(state, /* throw_monitor_exception */ true); |
2019 __ remove_activation(state, /* throw_monitor_exception */ true); |
2001 |
2020 |
2002 // The caller's SP was adjusted upon method entry to accomodate |
2021 // The caller's SP was adjusted upon method entry to accomodate |
2003 // the callee's non-argument locals. Undo that adjustment. |
2022 // the callee's non-argument locals. Undo that adjustment. |
2004 __ ret(); // return to caller |
2023 __ ret(); // return to caller |
2214 } |
2233 } |
2215 |
2234 |
2216 Label checkVolatile; |
2235 Label checkVolatile; |
2217 |
2236 |
2218 // compute field type |
2237 // compute field type |
2219 Label notByte, notInt, notShort, notChar, notLong, notFloat, notObj; |
2238 Label notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj; |
2220 __ srl(Rflags, ConstantPoolCacheEntry::tos_state_shift, Rflags); |
2239 __ srl(Rflags, ConstantPoolCacheEntry::tos_state_shift, Rflags); |
2221 // Make sure we don't need to mask Rflags after the above shift |
2240 // Make sure we don't need to mask Rflags after the above shift |
2222 ConstantPoolCacheEntry::verify_tos_state_shift(); |
2241 ConstantPoolCacheEntry::verify_tos_state_shift(); |
2223 |
2242 |
2224 // Check atos before itos for getstatic, more likely (in Queens at least) |
2243 // Check atos before itos for getstatic, more likely (in Queens at least) |
2269 |
2288 |
2270 __ bind(notLong); |
2289 __ bind(notLong); |
2271 |
2290 |
2272 // cmp(Rflags, btos); |
2291 // cmp(Rflags, btos); |
2273 __ br(Assembler::notEqual, false, Assembler::pt, notByte); |
2292 __ br(Assembler::notEqual, false, Assembler::pt, notByte); |
2274 __ delayed() ->cmp(Rflags, ctos); |
2293 __ delayed() ->cmp(Rflags, ztos); |
2275 |
2294 |
2276 // btos |
2295 // btos |
2277 __ ldsb(Rclass, Roffset, Otos_i); |
2296 __ ldsb(Rclass, Roffset, Otos_i); |
2278 __ push(itos); |
2297 __ push(itos); |
2279 if (!is_static) { |
2298 if (!is_static) { |
2281 } |
2300 } |
2282 __ ba(checkVolatile); |
2301 __ ba(checkVolatile); |
2283 __ delayed()->tst(Lscratch); |
2302 __ delayed()->tst(Lscratch); |
2284 |
2303 |
2285 __ bind(notByte); |
2304 __ bind(notByte); |
|
2305 |
|
2306 // cmp(Rflags, ztos); |
|
2307 __ br(Assembler::notEqual, false, Assembler::pt, notBool); |
|
2308 __ delayed() ->cmp(Rflags, ctos); |
|
2309 |
|
2310 // ztos |
|
2311 __ ldsb(Rclass, Roffset, Otos_i); |
|
2312 __ push(itos); |
|
2313 if (!is_static) { |
|
2314 // use btos rewriting, no truncating to t/f bit is needed for getfield. |
|
2315 patch_bytecode(Bytecodes::_fast_bgetfield, G3_scratch, G4_scratch); |
|
2316 } |
|
2317 __ ba(checkVolatile); |
|
2318 __ delayed()->tst(Lscratch); |
|
2319 |
|
2320 __ bind(notBool); |
2286 |
2321 |
2287 // cmp(Rflags, ctos); |
2322 // cmp(Rflags, ctos); |
2288 __ br(Assembler::notEqual, false, Assembler::pt, notChar); |
2323 __ br(Assembler::notEqual, false, Assembler::pt, notChar); |
2289 __ delayed() ->cmp(Rflags, stos); |
2324 __ delayed() ->cmp(Rflags, stos); |
2290 |
2325 |
2443 // to do it for every data type, we use the saved values as the |
2478 // to do it for every data type, we use the saved values as the |
2444 // jvalue object. |
2479 // jvalue object. |
2445 switch (bytecode()) { // save tos values before call_VM() clobbers them |
2480 switch (bytecode()) { // save tos values before call_VM() clobbers them |
2446 case Bytecodes::_fast_aputfield: __ push_ptr(Otos_i); break; |
2481 case Bytecodes::_fast_aputfield: __ push_ptr(Otos_i); break; |
2447 case Bytecodes::_fast_bputfield: // fall through |
2482 case Bytecodes::_fast_bputfield: // fall through |
|
2483 case Bytecodes::_fast_zputfield: // fall through |
2448 case Bytecodes::_fast_sputfield: // fall through |
2484 case Bytecodes::_fast_sputfield: // fall through |
2449 case Bytecodes::_fast_cputfield: // fall through |
2485 case Bytecodes::_fast_cputfield: // fall through |
2450 case Bytecodes::_fast_iputfield: __ push_i(Otos_i); break; |
2486 case Bytecodes::_fast_iputfield: __ push_i(Otos_i); break; |
2451 case Bytecodes::_fast_dputfield: __ push_d(Ftos_d); break; |
2487 case Bytecodes::_fast_dputfield: __ push_d(Ftos_d); break; |
2452 case Bytecodes::_fast_fputfield: __ push_f(Ftos_f); break; |
2488 case Bytecodes::_fast_fputfield: __ push_f(Ftos_f); break; |
2460 // G3_scratch: jvalue object on the stack |
2496 // G3_scratch: jvalue object on the stack |
2461 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification), G4_scratch, G1_scratch, G3_scratch); |
2497 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification), G4_scratch, G1_scratch, G3_scratch); |
2462 switch (bytecode()) { // restore tos values |
2498 switch (bytecode()) { // restore tos values |
2463 case Bytecodes::_fast_aputfield: __ pop_ptr(Otos_i); break; |
2499 case Bytecodes::_fast_aputfield: __ pop_ptr(Otos_i); break; |
2464 case Bytecodes::_fast_bputfield: // fall through |
2500 case Bytecodes::_fast_bputfield: // fall through |
|
2501 case Bytecodes::_fast_zputfield: // fall through |
2465 case Bytecodes::_fast_sputfield: // fall through |
2502 case Bytecodes::_fast_sputfield: // fall through |
2466 case Bytecodes::_fast_cputfield: // fall through |
2503 case Bytecodes::_fast_cputfield: // fall through |
2467 case Bytecodes::_fast_iputfield: __ pop_i(Otos_i); break; |
2504 case Bytecodes::_fast_iputfield: __ pop_i(Otos_i); break; |
2468 case Bytecodes::_fast_dputfield: __ pop_d(Ftos_d); break; |
2505 case Bytecodes::_fast_dputfield: __ pop_d(Ftos_d); break; |
2469 case Bytecodes::_fast_fputfield: __ pop_f(Ftos_f); break; |
2506 case Bytecodes::_fast_fputfield: __ pop_f(Ftos_f); break; |
2575 __ srl(Rflags, ConstantPoolCacheEntry::tos_state_shift, Rflags); |
2612 __ srl(Rflags, ConstantPoolCacheEntry::tos_state_shift, Rflags); |
2576 // Make sure we don't need to mask Rflags after the above shift |
2613 // Make sure we don't need to mask Rflags after the above shift |
2577 ConstantPoolCacheEntry::verify_tos_state_shift(); |
2614 ConstantPoolCacheEntry::verify_tos_state_shift(); |
2578 |
2615 |
2579 // compute field type |
2616 // compute field type |
2580 Label notInt, notShort, notChar, notObj, notByte, notLong, notFloat; |
2617 Label notInt, notShort, notChar, notObj, notByte, notBool, notLong, notFloat; |
2581 |
2618 |
2582 if (is_static) { |
2619 if (is_static) { |
2583 // putstatic with object type most likely, check that first |
2620 // putstatic with object type most likely, check that first |
2584 __ cmp(Rflags, atos); |
2621 __ cmp(Rflags, atos); |
2585 __ br(Assembler::notEqual, false, Assembler::pt, notObj); |
2622 __ br(Assembler::notEqual, false, Assembler::pt, notObj); |
2643 __ bind(notObj); |
2680 __ bind(notObj); |
2644 } |
2681 } |
2645 |
2682 |
2646 // cmp(Rflags, btos); |
2683 // cmp(Rflags, btos); |
2647 __ br(Assembler::notEqual, false, Assembler::pt, notByte); |
2684 __ br(Assembler::notEqual, false, Assembler::pt, notByte); |
2648 __ delayed()->cmp(Rflags, ltos); |
2685 __ delayed()->cmp(Rflags, ztos); |
2649 |
2686 |
2650 // btos |
2687 // btos |
2651 { |
2688 { |
2652 __ pop_i(); |
2689 __ pop_i(); |
2653 if (!is_static) pop_and_check_object(Rclass); |
2690 if (!is_static) pop_and_check_object(Rclass); |
2658 __ ba(checkVolatile); |
2695 __ ba(checkVolatile); |
2659 __ delayed()->tst(Lscratch); |
2696 __ delayed()->tst(Lscratch); |
2660 } |
2697 } |
2661 |
2698 |
2662 __ bind(notByte); |
2699 __ bind(notByte); |
|
2700 |
|
2701 // cmp(Rflags, btos); |
|
2702 __ br(Assembler::notEqual, false, Assembler::pt, notBool); |
|
2703 __ delayed()->cmp(Rflags, ltos); |
|
2704 |
|
2705 // ztos |
|
2706 { |
|
2707 __ pop_i(); |
|
2708 if (!is_static) pop_and_check_object(Rclass); |
|
2709 __ and3(Otos_i, 1, Otos_i); |
|
2710 __ stb(Otos_i, Rclass, Roffset); |
|
2711 if (!is_static) { |
|
2712 patch_bytecode(Bytecodes::_fast_zputfield, G3_scratch, G4_scratch, true, byte_no); |
|
2713 } |
|
2714 __ ba(checkVolatile); |
|
2715 __ delayed()->tst(Lscratch); |
|
2716 } |
|
2717 |
|
2718 __ bind(notBool); |
2663 // cmp(Rflags, ltos); |
2719 // cmp(Rflags, ltos); |
2664 __ br(Assembler::notEqual, false, Assembler::pt, notLong); |
2720 __ br(Assembler::notEqual, false, Assembler::pt, notLong); |
2665 __ delayed()->cmp(Rflags, ctos); |
2721 __ delayed()->cmp(Rflags, ctos); |
2666 |
2722 |
2667 // ltos |
2723 // ltos |
2781 |
2837 |
2782 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f2_offset(), Roffset); |
2838 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f2_offset(), Roffset); |
2783 pop_and_check_object(Rclass); |
2839 pop_and_check_object(Rclass); |
2784 |
2840 |
2785 switch (bytecode()) { |
2841 switch (bytecode()) { |
|
2842 case Bytecodes::_fast_zputfield: __ and3(Otos_i, 1, Otos_i); // fall through to bputfield |
2786 case Bytecodes::_fast_bputfield: __ stb(Otos_i, Rclass, Roffset); break; |
2843 case Bytecodes::_fast_bputfield: __ stb(Otos_i, Rclass, Roffset); break; |
2787 case Bytecodes::_fast_cputfield: /* fall through */ |
2844 case Bytecodes::_fast_cputfield: /* fall through */ |
2788 case Bytecodes::_fast_sputfield: __ sth(Otos_i, Rclass, Roffset); break; |
2845 case Bytecodes::_fast_sputfield: __ sth(Otos_i, Rclass, Roffset); break; |
2789 case Bytecodes::_fast_iputfield: __ st(Otos_i, Rclass, Roffset); break; |
2846 case Bytecodes::_fast_iputfield: __ st(Otos_i, Rclass, Roffset); break; |
2790 case Bytecodes::_fast_lputfield: __ st_long(Otos_l, Rclass, Roffset); break; |
2847 case Bytecodes::_fast_lputfield: __ st_long(Otos_l, Rclass, Roffset); break; |