1 /* |
1 /* |
2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2019, 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. |
859 } |
859 } |
860 move_regs(src->as_register(), dest->as_register()); |
860 move_regs(src->as_register(), dest->as_register()); |
861 |
861 |
862 } else if (dest->is_double_cpu()) { |
862 } else if (dest->is_double_cpu()) { |
863 #ifdef _LP64 |
863 #ifdef _LP64 |
864 if (src->type() == T_OBJECT || src->type() == T_ARRAY) { |
864 if (is_reference_type(src->type())) { |
865 // Surprising to me but we can see move of a long to t_object |
865 // Surprising to me but we can see move of a long to t_object |
866 __ verify_oop(src->as_register()); |
866 __ verify_oop(src->as_register()); |
867 move_regs(src->as_register(), dest->as_register_lo()); |
867 move_regs(src->as_register(), dest->as_register_lo()); |
868 return; |
868 return; |
869 } |
869 } |
930 assert(src->is_register(), "should not call otherwise"); |
930 assert(src->is_register(), "should not call otherwise"); |
931 assert(dest->is_stack(), "should not call otherwise"); |
931 assert(dest->is_stack(), "should not call otherwise"); |
932 |
932 |
933 if (src->is_single_cpu()) { |
933 if (src->is_single_cpu()) { |
934 Address dst = frame_map()->address_for_slot(dest->single_stack_ix()); |
934 Address dst = frame_map()->address_for_slot(dest->single_stack_ix()); |
935 if (type == T_OBJECT || type == T_ARRAY) { |
935 if (is_reference_type(type)) { |
936 __ verify_oop(src->as_register()); |
936 __ verify_oop(src->as_register()); |
937 __ movptr (dst, src->as_register()); |
937 __ movptr (dst, src->as_register()); |
938 } else if (type == T_METADATA) { |
938 } else if (type == T_METADATA) { |
939 __ movptr (dst, src->as_register()); |
939 __ movptr (dst, src->as_register()); |
940 } else { |
940 } else { |
976 void LIR_Assembler::reg2mem(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack, bool wide, bool /* unaligned */) { |
976 void LIR_Assembler::reg2mem(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack, bool wide, bool /* unaligned */) { |
977 LIR_Address* to_addr = dest->as_address_ptr(); |
977 LIR_Address* to_addr = dest->as_address_ptr(); |
978 PatchingStub* patch = NULL; |
978 PatchingStub* patch = NULL; |
979 Register compressed_src = rscratch1; |
979 Register compressed_src = rscratch1; |
980 |
980 |
981 if (type == T_ARRAY || type == T_OBJECT) { |
981 if (is_reference_type(type)) { |
982 __ verify_oop(src->as_register()); |
982 __ verify_oop(src->as_register()); |
983 #ifdef _LP64 |
983 #ifdef _LP64 |
984 if (UseCompressedOops && !wide) { |
984 if (UseCompressedOops && !wide) { |
985 __ movptr(compressed_src, src->as_register()); |
985 __ movptr(compressed_src, src->as_register()); |
986 __ encode_heap_oop(compressed_src); |
986 __ encode_heap_oop(compressed_src); |
1111 void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) { |
1111 void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) { |
1112 assert(src->is_stack(), "should not call otherwise"); |
1112 assert(src->is_stack(), "should not call otherwise"); |
1113 assert(dest->is_register(), "should not call otherwise"); |
1113 assert(dest->is_register(), "should not call otherwise"); |
1114 |
1114 |
1115 if (dest->is_single_cpu()) { |
1115 if (dest->is_single_cpu()) { |
1116 if (type == T_ARRAY || type == T_OBJECT) { |
1116 if (is_reference_type(type)) { |
1117 __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix())); |
1117 __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix())); |
1118 __ verify_oop(dest->as_register()); |
1118 __ verify_oop(dest->as_register()); |
1119 } else if (type == T_METADATA) { |
1119 } else if (type == T_METADATA) { |
1120 __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix())); |
1120 __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix())); |
1121 } else { |
1121 } else { |
1152 } |
1152 } |
1153 |
1153 |
1154 |
1154 |
1155 void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) { |
1155 void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) { |
1156 if (src->is_single_stack()) { |
1156 if (src->is_single_stack()) { |
1157 if (type == T_OBJECT || type == T_ARRAY) { |
1157 if (is_reference_type(type)) { |
1158 __ pushptr(frame_map()->address_for_slot(src ->single_stack_ix())); |
1158 __ pushptr(frame_map()->address_for_slot(src ->single_stack_ix())); |
1159 __ popptr (frame_map()->address_for_slot(dest->single_stack_ix())); |
1159 __ popptr (frame_map()->address_for_slot(dest->single_stack_ix())); |
1160 } else { |
1160 } else { |
1161 #ifndef _LP64 |
1161 #ifndef _LP64 |
1162 __ pushl(frame_map()->address_for_slot(src ->single_stack_ix())); |
1162 __ pushl(frame_map()->address_for_slot(src ->single_stack_ix())); |
1353 |
1353 |
1354 if (patch != NULL) { |
1354 if (patch != NULL) { |
1355 patching_epilog(patch, patch_code, addr->base()->as_register(), info); |
1355 patching_epilog(patch, patch_code, addr->base()->as_register(), info); |
1356 } |
1356 } |
1357 |
1357 |
1358 if (type == T_ARRAY || type == T_OBJECT) { |
1358 if (is_reference_type(type)) { |
1359 #ifdef _LP64 |
1359 #ifdef _LP64 |
1360 if (UseCompressedOops && !wide) { |
1360 if (UseCompressedOops && !wide) { |
1361 __ decode_heap_oop(dest->as_register()); |
1361 __ decode_heap_oop(dest->as_register()); |
1362 } |
1362 } |
1363 #endif |
1363 #endif |
1591 void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) { |
1591 void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) { |
1592 Register len = op->len()->as_register(); |
1592 Register len = op->len()->as_register(); |
1593 LP64_ONLY( __ movslq(len, len); ) |
1593 LP64_ONLY( __ movslq(len, len); ) |
1594 |
1594 |
1595 if (UseSlowPath || |
1595 if (UseSlowPath || |
1596 (!UseFastNewObjectArray && (op->type() == T_OBJECT || op->type() == T_ARRAY)) || |
1596 (!UseFastNewObjectArray && is_reference_type(op->type())) || |
1597 (!UseFastNewTypeArray && (op->type() != T_OBJECT && op->type() != T_ARRAY))) { |
1597 (!UseFastNewTypeArray && !is_reference_type(op->type()))) { |
1598 __ jmp(*op->stub()->entry()); |
1598 __ jmp(*op->stub()->entry()); |
1599 } else { |
1599 } else { |
1600 Register tmp1 = op->tmp1()->as_register(); |
1600 Register tmp1 = op->tmp1()->as_register(); |
1601 Register tmp2 = op->tmp2()->as_register(); |
1601 Register tmp2 = op->tmp2()->as_register(); |
1602 Register tmp3 = op->tmp3()->as_register(); |
1602 Register tmp3 = op->tmp3()->as_register(); |
2621 void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) { |
2621 void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) { |
2622 if (opr1->is_single_cpu()) { |
2622 if (opr1->is_single_cpu()) { |
2623 Register reg1 = opr1->as_register(); |
2623 Register reg1 = opr1->as_register(); |
2624 if (opr2->is_single_cpu()) { |
2624 if (opr2->is_single_cpu()) { |
2625 // cpu register - cpu register |
2625 // cpu register - cpu register |
2626 if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) { |
2626 if (is_reference_type(opr1->type())) { |
2627 __ cmpoop(reg1, opr2->as_register()); |
2627 __ cmpoop(reg1, opr2->as_register()); |
2628 } else { |
2628 } else { |
2629 assert(opr2->type() != T_OBJECT && opr2->type() != T_ARRAY, "cmp int, oop?"); |
2629 assert(!is_reference_type(opr2->type()), "cmp int, oop?"); |
2630 __ cmpl(reg1, opr2->as_register()); |
2630 __ cmpl(reg1, opr2->as_register()); |
2631 } |
2631 } |
2632 } else if (opr2->is_stack()) { |
2632 } else if (opr2->is_stack()) { |
2633 // cpu register - stack |
2633 // cpu register - stack |
2634 if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) { |
2634 if (is_reference_type(opr1->type())) { |
2635 __ cmpoop(reg1, frame_map()->address_for_slot(opr2->single_stack_ix())); |
2635 __ cmpoop(reg1, frame_map()->address_for_slot(opr2->single_stack_ix())); |
2636 } else { |
2636 } else { |
2637 __ cmpl(reg1, frame_map()->address_for_slot(opr2->single_stack_ix())); |
2637 __ cmpl(reg1, frame_map()->address_for_slot(opr2->single_stack_ix())); |
2638 } |
2638 } |
2639 } else if (opr2->is_constant()) { |
2639 } else if (opr2->is_constant()) { |
2640 // cpu register - constant |
2640 // cpu register - constant |
2641 LIR_Const* c = opr2->as_constant_ptr(); |
2641 LIR_Const* c = opr2->as_constant_ptr(); |
2642 if (c->type() == T_INT) { |
2642 if (c->type() == T_INT) { |
2643 __ cmpl(reg1, c->as_jint()); |
2643 __ cmpl(reg1, c->as_jint()); |
2644 } else if (c->type() == T_OBJECT || c->type() == T_ARRAY) { |
2644 } else if (is_reference_type(c->type())) { |
2645 // In 64bit oops are single register |
2645 // In 64bit oops are single register |
2646 jobject o = c->as_jobject(); |
2646 jobject o = c->as_jobject(); |
2647 if (o == NULL) { |
2647 if (o == NULL) { |
2648 __ cmpptr(reg1, (int32_t)NULL_WORD); |
2648 __ cmpptr(reg1, (int32_t)NULL_WORD); |
2649 } else { |
2649 } else { |
2739 __ fcmp(noreg, opr2->fpu(), op->fpu_pop_count() > 0, op->fpu_pop_count() > 1); |
2739 __ fcmp(noreg, opr2->fpu(), op->fpu_pop_count() > 0, op->fpu_pop_count() > 1); |
2740 |
2740 |
2741 } else if (opr1->is_address() && opr2->is_constant()) { |
2741 } else if (opr1->is_address() && opr2->is_constant()) { |
2742 LIR_Const* c = opr2->as_constant_ptr(); |
2742 LIR_Const* c = opr2->as_constant_ptr(); |
2743 #ifdef _LP64 |
2743 #ifdef _LP64 |
2744 if (c->type() == T_OBJECT || c->type() == T_ARRAY) { |
2744 if (is_reference_type(c->type())) { |
2745 assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "need to reverse"); |
2745 assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "need to reverse"); |
2746 __ movoop(rscratch1, c->as_jobject()); |
2746 __ movoop(rscratch1, c->as_jobject()); |
2747 } |
2747 } |
2748 #endif // LP64 |
2748 #endif // LP64 |
2749 if (op->info() != NULL) { |
2749 if (op->info() != NULL) { |
2751 } |
2751 } |
2752 // special case: address - constant |
2752 // special case: address - constant |
2753 LIR_Address* addr = opr1->as_address_ptr(); |
2753 LIR_Address* addr = opr1->as_address_ptr(); |
2754 if (c->type() == T_INT) { |
2754 if (c->type() == T_INT) { |
2755 __ cmpl(as_Address(addr), c->as_jint()); |
2755 __ cmpl(as_Address(addr), c->as_jint()); |
2756 } else if (c->type() == T_OBJECT || c->type() == T_ARRAY) { |
2756 } else if (is_reference_type(c->type())) { |
2757 #ifdef _LP64 |
2757 #ifdef _LP64 |
2758 // %%% Make this explode if addr isn't reachable until we figure out a |
2758 // %%% Make this explode if addr isn't reachable until we figure out a |
2759 // better strategy by giving noreg as the temp for as_Address |
2759 // better strategy by giving noreg as the temp for as_Address |
2760 __ cmpoop(rscratch1, as_Address(addr, noreg)); |
2760 __ cmpoop(rscratch1, as_Address(addr, noreg)); |
2761 #else |
2761 #else |
3050 __ resolve(ACCESS_WRITE, dst); |
3050 __ resolve(ACCESS_WRITE, dst); |
3051 |
3051 |
3052 CodeStub* stub = op->stub(); |
3052 CodeStub* stub = op->stub(); |
3053 int flags = op->flags(); |
3053 int flags = op->flags(); |
3054 BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL; |
3054 BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL; |
3055 if (basic_type == T_ARRAY) basic_type = T_OBJECT; |
3055 if (is_reference_type(basic_type)) basic_type = T_OBJECT; |
3056 |
3056 |
3057 // if we don't know anything, just go through the generic arraycopy |
3057 // if we don't know anything, just go through the generic arraycopy |
3058 if (default_type == NULL) { |
3058 if (default_type == NULL) { |
3059 // save outgoing arguments on stack in case call to System.arraycopy is needed |
3059 // save outgoing arguments on stack in case call to System.arraycopy is needed |
3060 // HACK ALERT. This code used to push the parameters in a hardwired fashion |
3060 // HACK ALERT. This code used to push the parameters in a hardwired fashion |