Mercurial > hg > graal-jvmci-8
comparison src/cpu/x86/vm/templateTable_x86_64.cpp @ 23614:32b682649973 jdk8u75-b04
8132051: Better byte behavior
Reviewed-by: coleenp, roland
author | kevinw |
---|---|
date | Fri, 15 Jan 2016 22:33:15 +0000 |
parents | 42790b7e4d48 |
children | b5f3a471e646 |
comparison
equal
deleted
inserted
replaced
23613:b374548dcb48 | 23614:32b682649973 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2003, 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. |
217 Label L_patch_done; | 217 Label L_patch_done; |
218 | 218 |
219 switch (bc) { | 219 switch (bc) { |
220 case Bytecodes::_fast_aputfield: | 220 case Bytecodes::_fast_aputfield: |
221 case Bytecodes::_fast_bputfield: | 221 case Bytecodes::_fast_bputfield: |
222 case Bytecodes::_fast_zputfield: | |
222 case Bytecodes::_fast_cputfield: | 223 case Bytecodes::_fast_cputfield: |
223 case Bytecodes::_fast_dputfield: | 224 case Bytecodes::_fast_dputfield: |
224 case Bytecodes::_fast_fputfield: | 225 case Bytecodes::_fast_fputfield: |
225 case Bytecodes::_fast_iputfield: | 226 case Bytecodes::_fast_iputfield: |
226 case Bytecodes::_fast_lputfield: | 227 case Bytecodes::_fast_lputfield: |
1016 __ pop_ptr(rdx); | 1017 __ pop_ptr(rdx); |
1017 // eax: value | 1018 // eax: value |
1018 // ebx: index | 1019 // ebx: index |
1019 // rdx: array | 1020 // rdx: array |
1020 index_check(rdx, rbx); // prefer index in ebx | 1021 index_check(rdx, rbx); // prefer index in ebx |
1022 // Need to check whether array is boolean or byte | |
1023 // since both types share the bastore bytecode. | |
1024 __ load_klass(rcx, rdx); | |
1025 __ movl(rcx, Address(rcx, Klass::layout_helper_offset())); | |
1026 int diffbit = Klass::layout_helper_boolean_diffbit(); | |
1027 __ testl(rcx, diffbit); | |
1028 Label L_skip; | |
1029 __ jccb(Assembler::zero, L_skip); | |
1030 __ andl(rax, 1); // if it is a T_BOOLEAN array, mask the stored value to 0/1 | |
1031 __ bind(L_skip); | |
1021 __ movb(Address(rdx, rbx, | 1032 __ movb(Address(rdx, rbx, |
1022 Address::times_1, | 1033 Address::times_1, |
1023 arrayOopDesc::base_offset_in_bytes(T_BYTE)), | 1034 arrayOopDesc::base_offset_in_bytes(T_BYTE)), |
1024 rax); | 1035 rax); |
1025 } | 1036 } |
2069 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), c_rarg1); | 2080 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), c_rarg1); |
2070 | 2081 |
2071 __ bind(skip_register_finalizer); | 2082 __ bind(skip_register_finalizer); |
2072 } | 2083 } |
2073 | 2084 |
2085 // Narrow result if state is itos but result type is smaller. | |
2086 // Need to narrow in the return bytecode rather than in generate_return_entry | |
2087 // since compiled code callers expect the result to already be narrowed. | |
2088 if (state == itos) { | |
2089 __ narrow(rax); | |
2090 } | |
2074 __ remove_activation(state, r13); | 2091 __ remove_activation(state, r13); |
2092 | |
2075 __ jmp(r13); | 2093 __ jmp(r13); |
2076 } | 2094 } |
2077 | 2095 |
2078 // ---------------------------------------------------------------------------- | 2096 // ---------------------------------------------------------------------------- |
2079 // Volatile variables demand their effects be made known to all CPU's | 2097 // Volatile variables demand their effects be made known to all CPU's |
2287 pop_and_check_object(obj); | 2305 pop_and_check_object(obj); |
2288 } | 2306 } |
2289 | 2307 |
2290 const Address field(obj, off, Address::times_1); | 2308 const Address field(obj, off, Address::times_1); |
2291 | 2309 |
2292 Label Done, notByte, notInt, notShort, notChar, | 2310 Label Done, notByte, notBool, notInt, notShort, notChar, |
2293 notLong, notFloat, notObj, notDouble; | 2311 notLong, notFloat, notObj, notDouble; |
2294 | 2312 |
2295 __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift); | 2313 __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift); |
2296 // Make sure we don't need to mask edx after the above shift | 2314 // Make sure we don't need to mask edx after the above shift |
2297 assert(btos == 0, "change code, btos != 0"); | 2315 assert(btos == 0, "change code, btos != 0"); |
2306 patch_bytecode(Bytecodes::_fast_bgetfield, bc, rbx); | 2324 patch_bytecode(Bytecodes::_fast_bgetfield, bc, rbx); |
2307 } | 2325 } |
2308 __ jmp(Done); | 2326 __ jmp(Done); |
2309 | 2327 |
2310 __ bind(notByte); | 2328 __ bind(notByte); |
2329 __ cmpl(flags, ztos); | |
2330 __ jcc(Assembler::notEqual, notBool); | |
2331 | |
2332 // ztos (same code as btos) | |
2333 __ load_signed_byte(rax, field); | |
2334 __ push(ztos); | |
2335 // Rewrite bytecode to be faster | |
2336 if (!is_static) { | |
2337 // use btos rewriting, no truncating to t/f bit is needed for getfield. | |
2338 patch_bytecode(Bytecodes::_fast_bgetfield, bc, rbx); | |
2339 } | |
2340 __ jmp(Done); | |
2341 | |
2342 __ bind(notBool); | |
2311 __ cmpl(flags, atos); | 2343 __ cmpl(flags, atos); |
2312 __ jcc(Assembler::notEqual, notObj); | 2344 __ jcc(Assembler::notEqual, notObj); |
2313 // atos | 2345 // atos |
2314 __ load_heap_oop(rax, field); | 2346 __ load_heap_oop(rax, field); |
2315 __ push(atos); | 2347 __ push(atos); |
2495 __ andl(rdx, 0x1); | 2527 __ andl(rdx, 0x1); |
2496 | 2528 |
2497 // field address | 2529 // field address |
2498 const Address field(obj, off, Address::times_1); | 2530 const Address field(obj, off, Address::times_1); |
2499 | 2531 |
2500 Label notByte, notInt, notShort, notChar, | 2532 Label notByte, notBool, notInt, notShort, notChar, |
2501 notLong, notFloat, notObj, notDouble; | 2533 notLong, notFloat, notObj, notDouble; |
2502 | 2534 |
2503 __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift); | 2535 __ shrl(flags, ConstantPoolCacheEntry::tos_state_shift); |
2504 | 2536 |
2505 assert(btos == 0, "change code, btos != 0"); | 2537 assert(btos == 0, "change code, btos != 0"); |
2516 } | 2548 } |
2517 __ jmp(Done); | 2549 __ jmp(Done); |
2518 } | 2550 } |
2519 | 2551 |
2520 __ bind(notByte); | 2552 __ bind(notByte); |
2553 __ cmpl(flags, ztos); | |
2554 __ jcc(Assembler::notEqual, notBool); | |
2555 | |
2556 // ztos | |
2557 { | |
2558 __ pop(ztos); | |
2559 if (!is_static) pop_and_check_object(obj); | |
2560 __ andl(rax, 0x1); | |
2561 __ movb(field, rax); | |
2562 if (!is_static) { | |
2563 patch_bytecode(Bytecodes::_fast_zputfield, bc, rbx, true, byte_no); | |
2564 } | |
2565 __ jmp(Done); | |
2566 } | |
2567 | |
2568 __ bind(notBool); | |
2521 __ cmpl(flags, atos); | 2569 __ cmpl(flags, atos); |
2522 __ jcc(Assembler::notEqual, notObj); | 2570 __ jcc(Assembler::notEqual, notObj); |
2523 | 2571 |
2524 // atos | 2572 // atos |
2525 { | 2573 { |
2664 // to do it for every data type, we use the saved values as the | 2712 // to do it for every data type, we use the saved values as the |
2665 // jvalue object. | 2713 // jvalue object. |
2666 switch (bytecode()) { // load values into the jvalue object | 2714 switch (bytecode()) { // load values into the jvalue object |
2667 case Bytecodes::_fast_aputfield: __ push_ptr(rax); break; | 2715 case Bytecodes::_fast_aputfield: __ push_ptr(rax); break; |
2668 case Bytecodes::_fast_bputfield: // fall through | 2716 case Bytecodes::_fast_bputfield: // fall through |
2717 case Bytecodes::_fast_zputfield: // fall through | |
2669 case Bytecodes::_fast_sputfield: // fall through | 2718 case Bytecodes::_fast_sputfield: // fall through |
2670 case Bytecodes::_fast_cputfield: // fall through | 2719 case Bytecodes::_fast_cputfield: // fall through |
2671 case Bytecodes::_fast_iputfield: __ push_i(rax); break; | 2720 case Bytecodes::_fast_iputfield: __ push_i(rax); break; |
2672 case Bytecodes::_fast_dputfield: __ push_d(); break; | 2721 case Bytecodes::_fast_dputfield: __ push_d(); break; |
2673 case Bytecodes::_fast_fputfield: __ push_f(); break; | 2722 case Bytecodes::_fast_fputfield: __ push_f(); break; |
2689 rbx, c_rarg2, c_rarg3); | 2738 rbx, c_rarg2, c_rarg3); |
2690 | 2739 |
2691 switch (bytecode()) { // restore tos values | 2740 switch (bytecode()) { // restore tos values |
2692 case Bytecodes::_fast_aputfield: __ pop_ptr(rax); break; | 2741 case Bytecodes::_fast_aputfield: __ pop_ptr(rax); break; |
2693 case Bytecodes::_fast_bputfield: // fall through | 2742 case Bytecodes::_fast_bputfield: // fall through |
2743 case Bytecodes::_fast_zputfield: // fall through | |
2694 case Bytecodes::_fast_sputfield: // fall through | 2744 case Bytecodes::_fast_sputfield: // fall through |
2695 case Bytecodes::_fast_cputfield: // fall through | 2745 case Bytecodes::_fast_cputfield: // fall through |
2696 case Bytecodes::_fast_iputfield: __ pop_i(rax); break; | 2746 case Bytecodes::_fast_iputfield: __ pop_i(rax); break; |
2697 case Bytecodes::_fast_dputfield: __ pop_d(); break; | 2747 case Bytecodes::_fast_dputfield: __ pop_d(); break; |
2698 case Bytecodes::_fast_fputfield: __ pop_f(); break; | 2748 case Bytecodes::_fast_fputfield: __ pop_f(); break; |
2744 __ movq(field, rax); | 2794 __ movq(field, rax); |
2745 break; | 2795 break; |
2746 case Bytecodes::_fast_iputfield: | 2796 case Bytecodes::_fast_iputfield: |
2747 __ movl(field, rax); | 2797 __ movl(field, rax); |
2748 break; | 2798 break; |
2799 case Bytecodes::_fast_zputfield: | |
2800 __ andl(rax, 0x1); // boolean is true if LSB is 1 | |
2801 // fall through to bputfield | |
2749 case Bytecodes::_fast_bputfield: | 2802 case Bytecodes::_fast_bputfield: |
2750 __ movb(field, rax); | 2803 __ movb(field, rax); |
2751 break; | 2804 break; |
2752 case Bytecodes::_fast_sputfield: | 2805 case Bytecodes::_fast_sputfield: |
2753 // fall through | 2806 // fall through |