src/cpu/x86/vm/interp_masm_x86.cpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial