Tue, 02 Sep 2014 12:48:45 -0700
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
Summary: Add new C2 intrinsic for BigInteger::multiplyToLen() on x86 in 64-bit VM.
Reviewed-by: roland
roland@5987 | 1 | /* |
roland@5987 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
roland@5987 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
roland@5987 | 4 | * |
roland@5987 | 5 | * This code is free software; you can redistribute it and/or modify it |
roland@5987 | 6 | * under the terms of the GNU General Public License version 2 only, as |
roland@5987 | 7 | * published by the Free Software Foundation. |
roland@5987 | 8 | * |
roland@5987 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
roland@5987 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
roland@5987 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
roland@5987 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
roland@5987 | 13 | * accompanied this code). |
roland@5987 | 14 | * |
roland@5987 | 15 | * You should have received a copy of the GNU General Public License version |
roland@5987 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
roland@5987 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
roland@5987 | 18 | * |
roland@5987 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
roland@5987 | 20 | * or visit www.oracle.com if you need additional information or have any |
roland@5987 | 21 | * questions. |
roland@5987 | 22 | * |
roland@5987 | 23 | */ |
roland@5987 | 24 | |
roland@5987 | 25 | #include "precompiled.hpp" |
roland@5987 | 26 | #include "interp_masm_x86.hpp" |
roland@5987 | 27 | #include "interpreter/interpreter.hpp" |
roland@5987 | 28 | #include "oops/methodData.hpp" |
roland@5987 | 29 | |
roland@5987 | 30 | #ifndef CC_INTERP |
roland@5987 | 31 | void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) { |
roland@5987 | 32 | Label update, next, none; |
roland@5987 | 33 | |
roland@5987 | 34 | verify_oop(obj); |
roland@5987 | 35 | |
roland@5987 | 36 | testptr(obj, obj); |
roland@5987 | 37 | jccb(Assembler::notZero, update); |
roland@5987 | 38 | orptr(mdo_addr, TypeEntries::null_seen); |
roland@5987 | 39 | jmpb(next); |
roland@5987 | 40 | |
roland@5987 | 41 | bind(update); |
roland@5987 | 42 | load_klass(obj, obj); |
roland@5987 | 43 | |
roland@5987 | 44 | xorptr(obj, mdo_addr); |
roland@5987 | 45 | testptr(obj, TypeEntries::type_klass_mask); |
roland@5987 | 46 | jccb(Assembler::zero, next); // klass seen before, nothing to |
roland@5987 | 47 | // do. The unknown bit may have been |
roland@5987 | 48 | // set already but no need to check. |
roland@5987 | 49 | |
roland@5987 | 50 | testptr(obj, TypeEntries::type_unknown); |
roland@5987 | 51 | jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore. |
roland@5987 | 52 | |
roland@5987 | 53 | cmpptr(mdo_addr, 0); |
roland@5987 | 54 | jccb(Assembler::equal, none); |
roland@5987 | 55 | cmpptr(mdo_addr, TypeEntries::null_seen); |
roland@5987 | 56 | jccb(Assembler::equal, none); |
roland@5987 | 57 | // There is a chance that the checks above (re-reading profiling |
roland@5987 | 58 | // data from memory) fail if another thread has just set the |
roland@5987 | 59 | // profiling to this obj's klass |
roland@5987 | 60 | xorptr(obj, mdo_addr); |
roland@5987 | 61 | testptr(obj, TypeEntries::type_klass_mask); |
roland@5987 | 62 | jccb(Assembler::zero, next); |
roland@5987 | 63 | |
roland@5987 | 64 | // different than before. Cannot keep accurate profile. |
roland@5987 | 65 | orptr(mdo_addr, TypeEntries::type_unknown); |
roland@5987 | 66 | jmpb(next); |
roland@5987 | 67 | |
roland@5987 | 68 | bind(none); |
roland@5987 | 69 | // first time here. Set profile type. |
roland@5987 | 70 | movptr(mdo_addr, obj); |
roland@5987 | 71 | |
roland@5987 | 72 | bind(next); |
roland@5987 | 73 | } |
roland@5987 | 74 | |
roland@5987 | 75 | void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) { |
roland@5987 | 76 | if (!ProfileInterpreter) { |
roland@5987 | 77 | return; |
roland@5987 | 78 | } |
roland@5987 | 79 | |
roland@5987 | 80 | if (MethodData::profile_arguments() || MethodData::profile_return()) { |
roland@5987 | 81 | Label profile_continue; |
roland@5987 | 82 | |
roland@5987 | 83 | test_method_data_pointer(mdp, profile_continue); |
roland@5987 | 84 | |
roland@5987 | 85 | int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size()); |
roland@5987 | 86 | |
roland@5987 | 87 | cmpb(Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start), is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag); |
roland@5987 | 88 | jcc(Assembler::notEqual, profile_continue); |
roland@5987 | 89 | |
roland@5987 | 90 | if (MethodData::profile_arguments()) { |
roland@5987 | 91 | Label done; |
roland@5987 | 92 | int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset()); |
roland@5987 | 93 | addptr(mdp, off_to_args); |
roland@5987 | 94 | |
roland@5987 | 95 | for (int i = 0; i < TypeProfileArgsLimit; i++) { |
roland@5987 | 96 | if (i > 0 || MethodData::profile_return()) { |
roland@5987 | 97 | // If return value type is profiled we may have no argument to profile |
roland@5987 | 98 | movptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); |
roland@5987 | 99 | subl(tmp, i*TypeStackSlotEntries::per_arg_count()); |
roland@5987 | 100 | cmpl(tmp, TypeStackSlotEntries::per_arg_count()); |
roland@5987 | 101 | jcc(Assembler::less, done); |
roland@5987 | 102 | } |
roland@5987 | 103 | movptr(tmp, Address(callee, Method::const_offset())); |
roland@5987 | 104 | load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset())); |
roland@5987 | 105 | // stack offset o (zero based) from the start of the argument |
roland@5987 | 106 | // list, for n arguments translates into offset n - o - 1 from |
roland@5987 | 107 | // the end of the argument list |
roland@5987 | 108 | subptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args)); |
roland@5987 | 109 | subl(tmp, 1); |
roland@5987 | 110 | Address arg_addr = argument_address(tmp); |
roland@5987 | 111 | movptr(tmp, arg_addr); |
roland@5987 | 112 | |
roland@5987 | 113 | Address mdo_arg_addr(mdp, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args); |
roland@5987 | 114 | profile_obj_type(tmp, mdo_arg_addr); |
roland@5987 | 115 | |
roland@5987 | 116 | int to_add = in_bytes(TypeStackSlotEntries::per_arg_size()); |
roland@5987 | 117 | addptr(mdp, to_add); |
roland@5987 | 118 | off_to_args += to_add; |
roland@5987 | 119 | } |
roland@5987 | 120 | |
roland@5987 | 121 | if (MethodData::profile_return()) { |
roland@5987 | 122 | movptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); |
roland@5987 | 123 | subl(tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count()); |
roland@5987 | 124 | } |
roland@5987 | 125 | |
roland@5987 | 126 | bind(done); |
roland@5987 | 127 | |
roland@5987 | 128 | if (MethodData::profile_return()) { |
roland@5987 | 129 | // We're right after the type profile for the last |
roland@6223 | 130 | // argument. tmp is the number of cells left in the |
roland@5987 | 131 | // CallTypeData/VirtualCallTypeData to reach its end. Non null |
roland@5987 | 132 | // if there's a return to profile. |
roland@5987 | 133 | assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type"); |
roland@5987 | 134 | shll(tmp, exact_log2(DataLayout::cell_size)); |
roland@5987 | 135 | addptr(mdp, tmp); |
roland@5987 | 136 | } |
roland@5987 | 137 | movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp); |
roland@5987 | 138 | } else { |
roland@5987 | 139 | assert(MethodData::profile_return(), "either profile call args or call ret"); |
roland@6643 | 140 | update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size())); |
roland@5987 | 141 | } |
roland@5987 | 142 | |
roland@5987 | 143 | // mdp points right after the end of the |
roland@5987 | 144 | // CallTypeData/VirtualCallTypeData, right after the cells for the |
roland@5987 | 145 | // return value type if there's one |
roland@5987 | 146 | |
roland@5987 | 147 | bind(profile_continue); |
roland@5987 | 148 | } |
roland@5987 | 149 | } |
roland@5987 | 150 | |
roland@5987 | 151 | void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) { |
roland@5987 | 152 | assert_different_registers(mdp, ret, tmp, _bcp_register); |
roland@5987 | 153 | if (ProfileInterpreter && MethodData::profile_return()) { |
roland@5987 | 154 | Label profile_continue, done; |
roland@5987 | 155 | |
roland@5987 | 156 | test_method_data_pointer(mdp, profile_continue); |
roland@5987 | 157 | |
roland@5987 | 158 | if (MethodData::profile_return_jsr292_only()) { |
roland@5987 | 159 | // If we don't profile all invoke bytecodes we must make sure |
roland@5987 | 160 | // it's a bytecode we indeed profile. We can't go back to the |
roland@5987 | 161 | // begining of the ProfileData we intend to update to check its |
roland@5987 | 162 | // type because we're right after it and we don't known its |
roland@5987 | 163 | // length |
roland@5987 | 164 | Label do_profile; |
roland@5987 | 165 | cmpb(Address(_bcp_register, 0), Bytecodes::_invokedynamic); |
roland@5987 | 166 | jcc(Assembler::equal, do_profile); |
roland@5987 | 167 | cmpb(Address(_bcp_register, 0), Bytecodes::_invokehandle); |
roland@5987 | 168 | jcc(Assembler::equal, do_profile); |
roland@5987 | 169 | get_method(tmp); |
roland@5987 | 170 | cmpb(Address(tmp, Method::intrinsic_id_offset_in_bytes()), vmIntrinsics::_compiledLambdaForm); |
roland@5987 | 171 | jcc(Assembler::notEqual, profile_continue); |
roland@5987 | 172 | |
roland@5987 | 173 | bind(do_profile); |
roland@5987 | 174 | } |
roland@5987 | 175 | |
roland@5987 | 176 | Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size())); |
roland@5987 | 177 | mov(tmp, ret); |
roland@5987 | 178 | profile_obj_type(tmp, mdo_ret_addr); |
roland@5987 | 179 | |
roland@5987 | 180 | bind(profile_continue); |
roland@5987 | 181 | } |
roland@5987 | 182 | } |
roland@5987 | 183 | |
roland@5987 | 184 | void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) { |
roland@5987 | 185 | if (ProfileInterpreter && MethodData::profile_parameters()) { |
roland@5987 | 186 | Label profile_continue, done; |
roland@5987 | 187 | |
roland@5987 | 188 | test_method_data_pointer(mdp, profile_continue); |
roland@5987 | 189 | |
roland@5987 | 190 | // Load the offset of the area within the MDO used for |
roland@5987 | 191 | // parameters. If it's negative we're not profiling any parameters |
roland@5987 | 192 | movl(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset()))); |
roland@5987 | 193 | testl(tmp1, tmp1); |
roland@5987 | 194 | jcc(Assembler::negative, profile_continue); |
roland@5987 | 195 | |
roland@5987 | 196 | // Compute a pointer to the area for parameters from the offset |
roland@5987 | 197 | // and move the pointer to the slot for the last |
roland@5987 | 198 | // parameters. Collect profiling from last parameter down. |
roland@5987 | 199 | // mdo start + parameters offset + array length - 1 |
roland@5987 | 200 | addptr(mdp, tmp1); |
roland@6223 | 201 | movptr(tmp1, Address(mdp, ArrayData::array_len_offset())); |
roland@5987 | 202 | decrement(tmp1, TypeStackSlotEntries::per_arg_count()); |
roland@5987 | 203 | |
roland@5987 | 204 | Label loop; |
roland@5987 | 205 | bind(loop); |
roland@5987 | 206 | |
roland@5987 | 207 | int off_base = in_bytes(ParametersTypeData::stack_slot_offset(0)); |
roland@5987 | 208 | int type_base = in_bytes(ParametersTypeData::type_offset(0)); |
roland@5987 | 209 | Address::ScaleFactor per_arg_scale = Address::times(DataLayout::cell_size); |
roland@5987 | 210 | Address arg_off(mdp, tmp1, per_arg_scale, off_base); |
roland@5987 | 211 | Address arg_type(mdp, tmp1, per_arg_scale, type_base); |
roland@5987 | 212 | |
roland@5987 | 213 | // load offset on the stack from the slot for this parameter |
roland@5987 | 214 | movptr(tmp2, arg_off); |
roland@5987 | 215 | negptr(tmp2); |
roland@5987 | 216 | // read the parameter from the local area |
roland@5987 | 217 | movptr(tmp2, Address(_locals_register, tmp2, Interpreter::stackElementScale())); |
roland@5987 | 218 | |
roland@5987 | 219 | // profile the parameter |
roland@5987 | 220 | profile_obj_type(tmp2, arg_type); |
roland@5987 | 221 | |
roland@5987 | 222 | // go to next parameter |
roland@5987 | 223 | decrement(tmp1, TypeStackSlotEntries::per_arg_count()); |
roland@5987 | 224 | jcc(Assembler::positive, loop); |
roland@5987 | 225 | |
roland@5987 | 226 | bind(profile_continue); |
roland@5987 | 227 | } |
roland@5987 | 228 | } |
roland@5987 | 229 | #endif |