Sat, 12 Oct 2013 12:12:59 +0200
8026054: New type profiling points: type of return values at calls
Summary: x86 interpreter and c1 type profiling for return values at calls
Reviewed-by: kvn, twisti
duke@435 | 1 | /* |
acorn@4497 | 2 | * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "classfile/systemDictionary.hpp" |
stefank@2314 | 27 | #include "interpreter/bytecode.hpp" |
stefank@2314 | 28 | #include "interpreter/bytecodeStream.hpp" |
stefank@2314 | 29 | #include "interpreter/linkResolver.hpp" |
acorn@4497 | 30 | #include "memory/heapInspection.hpp" |
coleenp@4037 | 31 | #include "oops/methodData.hpp" |
coleenp@4037 | 32 | #include "prims/jvmtiRedefineClasses.hpp" |
stefank@2314 | 33 | #include "runtime/compilationPolicy.hpp" |
stefank@2314 | 34 | #include "runtime/deoptimization.hpp" |
stefank@2314 | 35 | #include "runtime/handles.inline.hpp" |
duke@435 | 36 | |
duke@435 | 37 | // ================================================================== |
duke@435 | 38 | // DataLayout |
duke@435 | 39 | // |
duke@435 | 40 | // Overlay for generic profiling data. |
duke@435 | 41 | |
duke@435 | 42 | // Some types of data layouts need a length field. |
duke@435 | 43 | bool DataLayout::needs_array_len(u1 tag) { |
kvn@480 | 44 | return (tag == multi_branch_data_tag) || (tag == arg_info_data_tag); |
duke@435 | 45 | } |
duke@435 | 46 | |
duke@435 | 47 | // Perform generic initialization of the data. More specific |
duke@435 | 48 | // initialization occurs in overrides of ProfileData::post_initialize. |
duke@435 | 49 | void DataLayout::initialize(u1 tag, u2 bci, int cell_count) { |
duke@435 | 50 | _header._bits = (intptr_t)0; |
duke@435 | 51 | _header._struct._tag = tag; |
duke@435 | 52 | _header._struct._bci = bci; |
duke@435 | 53 | for (int i = 0; i < cell_count; i++) { |
duke@435 | 54 | set_cell_at(i, (intptr_t)0); |
duke@435 | 55 | } |
duke@435 | 56 | if (needs_array_len(tag)) { |
duke@435 | 57 | set_cell_at(ArrayData::array_len_off_set, cell_count - 1); // -1 for header. |
duke@435 | 58 | } |
roland@5914 | 59 | if (tag == call_type_data_tag) { |
roland@5914 | 60 | CallTypeData::initialize(this, cell_count); |
roland@5914 | 61 | } else if (tag == virtual_call_type_data_tag) { |
roland@5914 | 62 | VirtualCallTypeData::initialize(this, cell_count); |
roland@5914 | 63 | } |
duke@435 | 64 | } |
duke@435 | 65 | |
coleenp@4037 | 66 | void DataLayout::clean_weak_klass_links(BoolObjectClosure* cl) { |
ysr@1376 | 67 | ResourceMark m; |
coleenp@4037 | 68 | data_in()->clean_weak_klass_links(cl); |
ysr@1376 | 69 | } |
ysr@1376 | 70 | |
ysr@1376 | 71 | |
duke@435 | 72 | // ================================================================== |
duke@435 | 73 | // ProfileData |
duke@435 | 74 | // |
duke@435 | 75 | // A ProfileData object is created to refer to a section of profiling |
duke@435 | 76 | // data in a structured way. |
duke@435 | 77 | |
duke@435 | 78 | // Constructor for invalid ProfileData. |
duke@435 | 79 | ProfileData::ProfileData() { |
duke@435 | 80 | _data = NULL; |
duke@435 | 81 | } |
duke@435 | 82 | |
duke@435 | 83 | #ifndef PRODUCT |
roland@5914 | 84 | void ProfileData::print_shared(outputStream* st, const char* name) const { |
duke@435 | 85 | st->print("bci: %d", bci()); |
duke@435 | 86 | st->fill_to(tab_width_one); |
duke@435 | 87 | st->print("%s", name); |
duke@435 | 88 | tab(st); |
duke@435 | 89 | int trap = trap_state(); |
duke@435 | 90 | if (trap != 0) { |
duke@435 | 91 | char buf[100]; |
duke@435 | 92 | st->print("trap(%s) ", Deoptimization::format_trap_state(buf, sizeof(buf), trap)); |
duke@435 | 93 | } |
duke@435 | 94 | int flags = data()->flags(); |
duke@435 | 95 | if (flags != 0) |
duke@435 | 96 | st->print("flags(%d) ", flags); |
duke@435 | 97 | } |
duke@435 | 98 | |
roland@5914 | 99 | void ProfileData::tab(outputStream* st, bool first) const { |
roland@5914 | 100 | st->fill_to(first ? tab_width_one : tab_width_two); |
duke@435 | 101 | } |
duke@435 | 102 | #endif // !PRODUCT |
duke@435 | 103 | |
duke@435 | 104 | // ================================================================== |
duke@435 | 105 | // BitData |
duke@435 | 106 | // |
duke@435 | 107 | // A BitData corresponds to a one-bit flag. This is used to indicate |
duke@435 | 108 | // whether a checkcast bytecode has seen a null value. |
duke@435 | 109 | |
duke@435 | 110 | |
duke@435 | 111 | #ifndef PRODUCT |
roland@5914 | 112 | void BitData::print_data_on(outputStream* st) const { |
duke@435 | 113 | print_shared(st, "BitData"); |
duke@435 | 114 | } |
duke@435 | 115 | #endif // !PRODUCT |
duke@435 | 116 | |
duke@435 | 117 | // ================================================================== |
duke@435 | 118 | // CounterData |
duke@435 | 119 | // |
duke@435 | 120 | // A CounterData corresponds to a simple counter. |
duke@435 | 121 | |
duke@435 | 122 | #ifndef PRODUCT |
roland@5914 | 123 | void CounterData::print_data_on(outputStream* st) const { |
duke@435 | 124 | print_shared(st, "CounterData"); |
duke@435 | 125 | st->print_cr("count(%u)", count()); |
duke@435 | 126 | } |
duke@435 | 127 | #endif // !PRODUCT |
duke@435 | 128 | |
duke@435 | 129 | // ================================================================== |
duke@435 | 130 | // JumpData |
duke@435 | 131 | // |
duke@435 | 132 | // A JumpData is used to access profiling information for a direct |
duke@435 | 133 | // branch. It is a counter, used for counting the number of branches, |
duke@435 | 134 | // plus a data displacement, used for realigning the data pointer to |
duke@435 | 135 | // the corresponding target bci. |
duke@435 | 136 | |
coleenp@4037 | 137 | void JumpData::post_initialize(BytecodeStream* stream, MethodData* mdo) { |
duke@435 | 138 | assert(stream->bci() == bci(), "wrong pos"); |
duke@435 | 139 | int target; |
duke@435 | 140 | Bytecodes::Code c = stream->code(); |
duke@435 | 141 | if (c == Bytecodes::_goto_w || c == Bytecodes::_jsr_w) { |
duke@435 | 142 | target = stream->dest_w(); |
duke@435 | 143 | } else { |
duke@435 | 144 | target = stream->dest(); |
duke@435 | 145 | } |
duke@435 | 146 | int my_di = mdo->dp_to_di(dp()); |
duke@435 | 147 | int target_di = mdo->bci_to_di(target); |
duke@435 | 148 | int offset = target_di - my_di; |
duke@435 | 149 | set_displacement(offset); |
duke@435 | 150 | } |
duke@435 | 151 | |
duke@435 | 152 | #ifndef PRODUCT |
roland@5914 | 153 | void JumpData::print_data_on(outputStream* st) const { |
duke@435 | 154 | print_shared(st, "JumpData"); |
duke@435 | 155 | st->print_cr("taken(%u) displacement(%d)", taken(), displacement()); |
duke@435 | 156 | } |
duke@435 | 157 | #endif // !PRODUCT |
duke@435 | 158 | |
roland@5921 | 159 | int TypeStackSlotEntries::compute_cell_count(Symbol* signature, int max) { |
roland@5921 | 160 | ResourceMark rm; |
roland@5921 | 161 | SignatureStream ss(signature); |
roland@5921 | 162 | int args_count = MIN2(ss.reference_parameter_count(), max); |
roland@5921 | 163 | return args_count * per_arg_cell_count; |
roland@5921 | 164 | } |
roland@5921 | 165 | |
roland@5921 | 166 | int TypeEntriesAtCall::compute_cell_count(BytecodeStream* stream) { |
roland@5914 | 167 | assert(Bytecodes::is_invoke(stream->code()), "should be invoke"); |
roland@5921 | 168 | assert(TypeStackSlotEntries::per_arg_count() > ReturnTypeEntry::static_cell_count(), "code to test for arguments/results broken"); |
roland@5914 | 169 | Bytecode_invoke inv(stream->method(), stream->bci()); |
roland@5921 | 170 | int args_cell = 0; |
roland@5921 | 171 | if (arguments_profiling_enabled()) { |
roland@5921 | 172 | args_cell = TypeStackSlotEntries::compute_cell_count(inv.signature(), TypeProfileArgsLimit); |
roland@5921 | 173 | } |
roland@5921 | 174 | int ret_cell = 0; |
roland@5921 | 175 | if (return_profiling_enabled() && (inv.result_type() == T_OBJECT || inv.result_type() == T_ARRAY)) { |
roland@5921 | 176 | ret_cell = ReturnTypeEntry::static_cell_count(); |
roland@5921 | 177 | } |
roland@5921 | 178 | int header_cell = 0; |
roland@5921 | 179 | if (args_cell + ret_cell > 0) { |
roland@5921 | 180 | header_cell = header_cell_count(); |
roland@5921 | 181 | } |
roland@5914 | 182 | |
roland@5921 | 183 | return header_cell + args_cell + ret_cell; |
roland@5914 | 184 | } |
roland@5914 | 185 | |
roland@5914 | 186 | class ArgumentOffsetComputer : public SignatureInfo { |
roland@5914 | 187 | private: |
roland@5914 | 188 | int _max; |
roland@5914 | 189 | GrowableArray<int> _offsets; |
roland@5914 | 190 | |
roland@5914 | 191 | void set(int size, BasicType type) { _size += size; } |
roland@5914 | 192 | void do_object(int begin, int end) { |
roland@5914 | 193 | if (_offsets.length() < _max) { |
roland@5914 | 194 | _offsets.push(_size); |
roland@5914 | 195 | } |
roland@5914 | 196 | SignatureInfo::do_object(begin, end); |
roland@5914 | 197 | } |
roland@5914 | 198 | void do_array (int begin, int end) { |
roland@5914 | 199 | if (_offsets.length() < _max) { |
roland@5914 | 200 | _offsets.push(_size); |
roland@5914 | 201 | } |
roland@5914 | 202 | SignatureInfo::do_array(begin, end); |
roland@5914 | 203 | } |
roland@5914 | 204 | |
roland@5914 | 205 | public: |
roland@5914 | 206 | ArgumentOffsetComputer(Symbol* signature, int max) |
roland@5914 | 207 | : SignatureInfo(signature), _max(max), _offsets(Thread::current(), max) { |
roland@5914 | 208 | } |
roland@5914 | 209 | |
roland@5914 | 210 | int total() { lazy_iterate_parameters(); return _size; } |
roland@5914 | 211 | |
roland@5914 | 212 | int off_at(int i) const { return _offsets.at(i); } |
roland@5914 | 213 | }; |
roland@5914 | 214 | |
roland@5921 | 215 | void TypeStackSlotEntries::post_initialize(Symbol* signature, bool has_receiver) { |
roland@5914 | 216 | ResourceMark rm; |
roland@5921 | 217 | ArgumentOffsetComputer aos(signature, _number_of_entries); |
roland@5921 | 218 | aos.total(); |
roland@5921 | 219 | for (int i = 0; i < _number_of_entries; i++) { |
roland@5921 | 220 | set_stack_slot(i, aos.off_at(i) + (has_receiver ? 1 : 0)); |
roland@5921 | 221 | set_type(i, type_none()); |
roland@5921 | 222 | } |
roland@5921 | 223 | } |
roland@5914 | 224 | |
roland@5921 | 225 | void CallTypeData::post_initialize(BytecodeStream* stream, MethodData* mdo) { |
roland@5914 | 226 | assert(Bytecodes::is_invoke(stream->code()), "should be invoke"); |
roland@5914 | 227 | Bytecode_invoke inv(stream->method(), stream->bci()); |
roland@5914 | 228 | |
roland@5921 | 229 | SignatureStream ss(inv.signature()); |
roland@5921 | 230 | if (has_arguments()) { |
roland@5914 | 231 | #ifdef ASSERT |
roland@5921 | 232 | ResourceMark rm; |
roland@5921 | 233 | int count = MIN2(ss.reference_parameter_count(), (int)TypeProfileArgsLimit); |
roland@5921 | 234 | assert(count > 0, "room for args type but none found?"); |
roland@5921 | 235 | check_number_of_arguments(count); |
roland@5914 | 236 | #endif |
roland@5921 | 237 | _args.post_initialize(inv.signature(), inv.has_receiver()); |
roland@5921 | 238 | } |
roland@5914 | 239 | |
roland@5921 | 240 | if (has_return()) { |
roland@5921 | 241 | assert(inv.result_type() == T_OBJECT || inv.result_type() == T_ARRAY, "room for a ret type but doesn't return obj?"); |
roland@5921 | 242 | _ret.post_initialize(); |
roland@5921 | 243 | } |
roland@5921 | 244 | } |
roland@5921 | 245 | |
roland@5921 | 246 | void VirtualCallTypeData::post_initialize(BytecodeStream* stream, MethodData* mdo) { |
roland@5921 | 247 | assert(Bytecodes::is_invoke(stream->code()), "should be invoke"); |
roland@5921 | 248 | Bytecode_invoke inv(stream->method(), stream->bci()); |
roland@5921 | 249 | |
roland@5921 | 250 | if (has_arguments()) { |
roland@5921 | 251 | #ifdef ASSERT |
roland@5921 | 252 | ResourceMark rm; |
roland@5921 | 253 | SignatureStream ss(inv.signature()); |
roland@5921 | 254 | int count = MIN2(ss.reference_parameter_count(), (int)TypeProfileArgsLimit); |
roland@5921 | 255 | assert(count > 0, "room for args type but none found?"); |
roland@5921 | 256 | check_number_of_arguments(count); |
roland@5921 | 257 | #endif |
roland@5921 | 258 | _args.post_initialize(inv.signature(), inv.has_receiver()); |
roland@5921 | 259 | } |
roland@5921 | 260 | |
roland@5921 | 261 | if (has_return()) { |
roland@5921 | 262 | assert(inv.result_type() == T_OBJECT || inv.result_type() == T_ARRAY, "room for a ret type but doesn't return obj?"); |
roland@5921 | 263 | _ret.post_initialize(); |
roland@5914 | 264 | } |
roland@5914 | 265 | } |
roland@5914 | 266 | |
roland@5914 | 267 | bool TypeEntries::is_loader_alive(BoolObjectClosure* is_alive_cl, intptr_t p) { |
roland@5914 | 268 | return !is_type_none(p) && |
roland@5914 | 269 | !((Klass*)klass_part(p))->is_loader_alive(is_alive_cl); |
roland@5914 | 270 | } |
roland@5914 | 271 | |
roland@5914 | 272 | void TypeStackSlotEntries::clean_weak_klass_links(BoolObjectClosure* is_alive_cl) { |
roland@5921 | 273 | for (int i = 0; i < _number_of_entries; i++) { |
roland@5914 | 274 | intptr_t p = type(i); |
roland@5914 | 275 | if (is_loader_alive(is_alive_cl, p)) { |
roland@5914 | 276 | set_type(i, type_none()); |
roland@5914 | 277 | } |
roland@5914 | 278 | } |
roland@5914 | 279 | } |
roland@5914 | 280 | |
roland@5921 | 281 | void ReturnTypeEntry::clean_weak_klass_links(BoolObjectClosure* is_alive_cl) { |
roland@5921 | 282 | intptr_t p = type(); |
roland@5921 | 283 | if (is_loader_alive(is_alive_cl, p)) { |
roland@5921 | 284 | set_type(type_none()); |
roland@5921 | 285 | } |
roland@5921 | 286 | } |
roland@5921 | 287 | |
roland@5921 | 288 | bool TypeEntriesAtCall::return_profiling_enabled() { |
roland@5921 | 289 | return MethodData::profile_return(); |
roland@5921 | 290 | } |
roland@5921 | 291 | |
roland@5921 | 292 | bool TypeEntriesAtCall::arguments_profiling_enabled() { |
roland@5914 | 293 | return MethodData::profile_arguments(); |
roland@5914 | 294 | } |
roland@5914 | 295 | |
roland@5914 | 296 | #ifndef PRODUCT |
roland@5914 | 297 | void TypeEntries::print_klass(outputStream* st, intptr_t k) { |
roland@5914 | 298 | if (is_type_none(k)) { |
roland@5914 | 299 | st->print("none"); |
roland@5914 | 300 | } else if (is_type_unknown(k)) { |
roland@5914 | 301 | st->print("unknown"); |
roland@5914 | 302 | } else { |
roland@5914 | 303 | valid_klass(k)->print_value_on(st); |
roland@5914 | 304 | } |
roland@5914 | 305 | if (was_null_seen(k)) { |
roland@5914 | 306 | st->print(" (null seen)"); |
roland@5914 | 307 | } |
roland@5914 | 308 | } |
roland@5914 | 309 | |
roland@5914 | 310 | void TypeStackSlotEntries::print_data_on(outputStream* st) const { |
roland@5921 | 311 | for (int i = 0; i < _number_of_entries; i++) { |
roland@5914 | 312 | _pd->tab(st); |
roland@5914 | 313 | st->print("%d: stack(%u) ", i, stack_slot(i)); |
roland@5914 | 314 | print_klass(st, type(i)); |
roland@5914 | 315 | st->cr(); |
roland@5914 | 316 | } |
roland@5914 | 317 | } |
roland@5914 | 318 | |
roland@5921 | 319 | void ReturnTypeEntry::print_data_on(outputStream* st) const { |
roland@5921 | 320 | _pd->tab(st); |
roland@5921 | 321 | print_klass(st, type()); |
roland@5921 | 322 | st->cr(); |
roland@5921 | 323 | } |
roland@5921 | 324 | |
roland@5914 | 325 | void CallTypeData::print_data_on(outputStream* st) const { |
roland@5914 | 326 | CounterData::print_data_on(st); |
roland@5921 | 327 | if (has_arguments()) { |
roland@5921 | 328 | tab(st, true); |
roland@5921 | 329 | st->print("argument types"); |
roland@5921 | 330 | _args.print_data_on(st); |
roland@5921 | 331 | } |
roland@5921 | 332 | if (has_return()) { |
roland@5921 | 333 | tab(st, true); |
roland@5921 | 334 | st->print("return type"); |
roland@5921 | 335 | _ret.print_data_on(st); |
roland@5921 | 336 | } |
roland@5914 | 337 | } |
roland@5914 | 338 | |
roland@5914 | 339 | void VirtualCallTypeData::print_data_on(outputStream* st) const { |
roland@5914 | 340 | VirtualCallData::print_data_on(st); |
roland@5921 | 341 | if (has_arguments()) { |
roland@5921 | 342 | tab(st, true); |
roland@5921 | 343 | st->print("argument types"); |
roland@5921 | 344 | _args.print_data_on(st); |
roland@5921 | 345 | } |
roland@5921 | 346 | if (has_return()) { |
roland@5921 | 347 | tab(st, true); |
roland@5921 | 348 | st->print("return type"); |
roland@5921 | 349 | _ret.print_data_on(st); |
roland@5921 | 350 | } |
roland@5914 | 351 | } |
roland@5914 | 352 | #endif |
roland@5914 | 353 | |
duke@435 | 354 | // ================================================================== |
duke@435 | 355 | // ReceiverTypeData |
duke@435 | 356 | // |
duke@435 | 357 | // A ReceiverTypeData is used to access profiling information about a |
duke@435 | 358 | // dynamic type check. It consists of a counter which counts the total times |
coleenp@4037 | 359 | // that the check is reached, and a series of (Klass*, count) pairs |
duke@435 | 360 | // which are used to store a type profile for the receiver of the check. |
duke@435 | 361 | |
coleenp@4037 | 362 | void ReceiverTypeData::clean_weak_klass_links(BoolObjectClosure* is_alive_cl) { |
ysr@1376 | 363 | for (uint row = 0; row < row_limit(); row++) { |
coleenp@4037 | 364 | Klass* p = receiver(row); |
coleenp@4037 | 365 | if (p != NULL && !p->is_loader_alive(is_alive_cl)) { |
ysr@1376 | 366 | clear_row(row); |
ysr@1376 | 367 | } |
ysr@1376 | 368 | } |
ysr@1376 | 369 | } |
ysr@1376 | 370 | |
duke@435 | 371 | #ifndef PRODUCT |
roland@5914 | 372 | void ReceiverTypeData::print_receiver_data_on(outputStream* st) const { |
duke@435 | 373 | uint row; |
duke@435 | 374 | int entries = 0; |
duke@435 | 375 | for (row = 0; row < row_limit(); row++) { |
duke@435 | 376 | if (receiver(row) != NULL) entries++; |
duke@435 | 377 | } |
duke@435 | 378 | st->print_cr("count(%u) entries(%u)", count(), entries); |
iveresov@2138 | 379 | int total = count(); |
iveresov@2138 | 380 | for (row = 0; row < row_limit(); row++) { |
iveresov@2138 | 381 | if (receiver(row) != NULL) { |
iveresov@2138 | 382 | total += receiver_count(row); |
iveresov@2138 | 383 | } |
iveresov@2138 | 384 | } |
duke@435 | 385 | for (row = 0; row < row_limit(); row++) { |
duke@435 | 386 | if (receiver(row) != NULL) { |
duke@435 | 387 | tab(st); |
duke@435 | 388 | receiver(row)->print_value_on(st); |
iveresov@2138 | 389 | st->print_cr("(%u %4.2f)", receiver_count(row), (float) receiver_count(row) / (float) total); |
duke@435 | 390 | } |
duke@435 | 391 | } |
duke@435 | 392 | } |
roland@5914 | 393 | void ReceiverTypeData::print_data_on(outputStream* st) const { |
duke@435 | 394 | print_shared(st, "ReceiverTypeData"); |
duke@435 | 395 | print_receiver_data_on(st); |
duke@435 | 396 | } |
roland@5914 | 397 | void VirtualCallData::print_data_on(outputStream* st) const { |
duke@435 | 398 | print_shared(st, "VirtualCallData"); |
duke@435 | 399 | print_receiver_data_on(st); |
duke@435 | 400 | } |
duke@435 | 401 | #endif // !PRODUCT |
duke@435 | 402 | |
duke@435 | 403 | // ================================================================== |
duke@435 | 404 | // RetData |
duke@435 | 405 | // |
duke@435 | 406 | // A RetData is used to access profiling information for a ret bytecode. |
duke@435 | 407 | // It is composed of a count of the number of times that the ret has |
duke@435 | 408 | // been executed, followed by a series of triples of the form |
duke@435 | 409 | // (bci, count, di) which count the number of times that some bci was the |
duke@435 | 410 | // target of the ret and cache a corresponding displacement. |
duke@435 | 411 | |
coleenp@4037 | 412 | void RetData::post_initialize(BytecodeStream* stream, MethodData* mdo) { |
duke@435 | 413 | for (uint row = 0; row < row_limit(); row++) { |
duke@435 | 414 | set_bci_displacement(row, -1); |
duke@435 | 415 | set_bci(row, no_bci); |
duke@435 | 416 | } |
duke@435 | 417 | // release so other threads see a consistent state. bci is used as |
duke@435 | 418 | // a valid flag for bci_displacement. |
duke@435 | 419 | OrderAccess::release(); |
duke@435 | 420 | } |
duke@435 | 421 | |
duke@435 | 422 | // This routine needs to atomically update the RetData structure, so the |
duke@435 | 423 | // caller needs to hold the RetData_lock before it gets here. Since taking |
duke@435 | 424 | // the lock can block (and allow GC) and since RetData is a ProfileData is a |
duke@435 | 425 | // wrapper around a derived oop, taking the lock in _this_ method will |
duke@435 | 426 | // basically cause the 'this' pointer's _data field to contain junk after the |
duke@435 | 427 | // lock. We require the caller to take the lock before making the ProfileData |
duke@435 | 428 | // structure. Currently the only caller is InterpreterRuntime::update_mdp_for_ret |
coleenp@4037 | 429 | address RetData::fixup_ret(int return_bci, MethodData* h_mdo) { |
duke@435 | 430 | // First find the mdp which corresponds to the return bci. |
duke@435 | 431 | address mdp = h_mdo->bci_to_dp(return_bci); |
duke@435 | 432 | |
duke@435 | 433 | // Now check to see if any of the cache slots are open. |
duke@435 | 434 | for (uint row = 0; row < row_limit(); row++) { |
duke@435 | 435 | if (bci(row) == no_bci) { |
duke@435 | 436 | set_bci_displacement(row, mdp - dp()); |
duke@435 | 437 | set_bci_count(row, DataLayout::counter_increment); |
duke@435 | 438 | // Barrier to ensure displacement is written before the bci; allows |
duke@435 | 439 | // the interpreter to read displacement without fear of race condition. |
duke@435 | 440 | release_set_bci(row, return_bci); |
duke@435 | 441 | break; |
duke@435 | 442 | } |
duke@435 | 443 | } |
duke@435 | 444 | return mdp; |
duke@435 | 445 | } |
duke@435 | 446 | |
duke@435 | 447 | |
duke@435 | 448 | #ifndef PRODUCT |
roland@5914 | 449 | void RetData::print_data_on(outputStream* st) const { |
duke@435 | 450 | print_shared(st, "RetData"); |
duke@435 | 451 | uint row; |
duke@435 | 452 | int entries = 0; |
duke@435 | 453 | for (row = 0; row < row_limit(); row++) { |
duke@435 | 454 | if (bci(row) != no_bci) entries++; |
duke@435 | 455 | } |
duke@435 | 456 | st->print_cr("count(%u) entries(%u)", count(), entries); |
duke@435 | 457 | for (row = 0; row < row_limit(); row++) { |
duke@435 | 458 | if (bci(row) != no_bci) { |
duke@435 | 459 | tab(st); |
duke@435 | 460 | st->print_cr("bci(%d: count(%u) displacement(%d))", |
duke@435 | 461 | bci(row), bci_count(row), bci_displacement(row)); |
duke@435 | 462 | } |
duke@435 | 463 | } |
duke@435 | 464 | } |
duke@435 | 465 | #endif // !PRODUCT |
duke@435 | 466 | |
duke@435 | 467 | // ================================================================== |
duke@435 | 468 | // BranchData |
duke@435 | 469 | // |
duke@435 | 470 | // A BranchData is used to access profiling data for a two-way branch. |
duke@435 | 471 | // It consists of taken and not_taken counts as well as a data displacement |
duke@435 | 472 | // for the taken case. |
duke@435 | 473 | |
coleenp@4037 | 474 | void BranchData::post_initialize(BytecodeStream* stream, MethodData* mdo) { |
duke@435 | 475 | assert(stream->bci() == bci(), "wrong pos"); |
duke@435 | 476 | int target = stream->dest(); |
duke@435 | 477 | int my_di = mdo->dp_to_di(dp()); |
duke@435 | 478 | int target_di = mdo->bci_to_di(target); |
duke@435 | 479 | int offset = target_di - my_di; |
duke@435 | 480 | set_displacement(offset); |
duke@435 | 481 | } |
duke@435 | 482 | |
duke@435 | 483 | #ifndef PRODUCT |
roland@5914 | 484 | void BranchData::print_data_on(outputStream* st) const { |
duke@435 | 485 | print_shared(st, "BranchData"); |
duke@435 | 486 | st->print_cr("taken(%u) displacement(%d)", |
duke@435 | 487 | taken(), displacement()); |
duke@435 | 488 | tab(st); |
duke@435 | 489 | st->print_cr("not taken(%u)", not_taken()); |
duke@435 | 490 | } |
duke@435 | 491 | #endif |
duke@435 | 492 | |
duke@435 | 493 | // ================================================================== |
duke@435 | 494 | // MultiBranchData |
duke@435 | 495 | // |
duke@435 | 496 | // A MultiBranchData is used to access profiling information for |
duke@435 | 497 | // a multi-way branch (*switch bytecodes). It consists of a series |
duke@435 | 498 | // of (count, displacement) pairs, which count the number of times each |
duke@435 | 499 | // case was taken and specify the data displacment for each branch target. |
duke@435 | 500 | |
duke@435 | 501 | int MultiBranchData::compute_cell_count(BytecodeStream* stream) { |
duke@435 | 502 | int cell_count = 0; |
duke@435 | 503 | if (stream->code() == Bytecodes::_tableswitch) { |
never@2462 | 504 | Bytecode_tableswitch sw(stream->method()(), stream->bcp()); |
never@2462 | 505 | cell_count = 1 + per_case_cell_count * (1 + sw.length()); // 1 for default |
duke@435 | 506 | } else { |
never@2462 | 507 | Bytecode_lookupswitch sw(stream->method()(), stream->bcp()); |
never@2462 | 508 | cell_count = 1 + per_case_cell_count * (sw.number_of_pairs() + 1); // 1 for default |
duke@435 | 509 | } |
duke@435 | 510 | return cell_count; |
duke@435 | 511 | } |
duke@435 | 512 | |
duke@435 | 513 | void MultiBranchData::post_initialize(BytecodeStream* stream, |
coleenp@4037 | 514 | MethodData* mdo) { |
duke@435 | 515 | assert(stream->bci() == bci(), "wrong pos"); |
duke@435 | 516 | int target; |
duke@435 | 517 | int my_di; |
duke@435 | 518 | int target_di; |
duke@435 | 519 | int offset; |
duke@435 | 520 | if (stream->code() == Bytecodes::_tableswitch) { |
never@2462 | 521 | Bytecode_tableswitch sw(stream->method()(), stream->bcp()); |
never@2462 | 522 | int len = sw.length(); |
duke@435 | 523 | assert(array_len() == per_case_cell_count * (len + 1), "wrong len"); |
duke@435 | 524 | for (int count = 0; count < len; count++) { |
never@2462 | 525 | target = sw.dest_offset_at(count) + bci(); |
duke@435 | 526 | my_di = mdo->dp_to_di(dp()); |
duke@435 | 527 | target_di = mdo->bci_to_di(target); |
duke@435 | 528 | offset = target_di - my_di; |
duke@435 | 529 | set_displacement_at(count, offset); |
duke@435 | 530 | } |
never@2462 | 531 | target = sw.default_offset() + bci(); |
duke@435 | 532 | my_di = mdo->dp_to_di(dp()); |
duke@435 | 533 | target_di = mdo->bci_to_di(target); |
duke@435 | 534 | offset = target_di - my_di; |
duke@435 | 535 | set_default_displacement(offset); |
duke@435 | 536 | |
duke@435 | 537 | } else { |
never@2462 | 538 | Bytecode_lookupswitch sw(stream->method()(), stream->bcp()); |
never@2462 | 539 | int npairs = sw.number_of_pairs(); |
duke@435 | 540 | assert(array_len() == per_case_cell_count * (npairs + 1), "wrong len"); |
duke@435 | 541 | for (int count = 0; count < npairs; count++) { |
never@2462 | 542 | LookupswitchPair pair = sw.pair_at(count); |
never@2462 | 543 | target = pair.offset() + bci(); |
duke@435 | 544 | my_di = mdo->dp_to_di(dp()); |
duke@435 | 545 | target_di = mdo->bci_to_di(target); |
duke@435 | 546 | offset = target_di - my_di; |
duke@435 | 547 | set_displacement_at(count, offset); |
duke@435 | 548 | } |
never@2462 | 549 | target = sw.default_offset() + bci(); |
duke@435 | 550 | my_di = mdo->dp_to_di(dp()); |
duke@435 | 551 | target_di = mdo->bci_to_di(target); |
duke@435 | 552 | offset = target_di - my_di; |
duke@435 | 553 | set_default_displacement(offset); |
duke@435 | 554 | } |
duke@435 | 555 | } |
duke@435 | 556 | |
duke@435 | 557 | #ifndef PRODUCT |
roland@5914 | 558 | void MultiBranchData::print_data_on(outputStream* st) const { |
duke@435 | 559 | print_shared(st, "MultiBranchData"); |
duke@435 | 560 | st->print_cr("default_count(%u) displacement(%d)", |
duke@435 | 561 | default_count(), default_displacement()); |
duke@435 | 562 | int cases = number_of_cases(); |
duke@435 | 563 | for (int i = 0; i < cases; i++) { |
duke@435 | 564 | tab(st); |
duke@435 | 565 | st->print_cr("count(%u) displacement(%d)", |
duke@435 | 566 | count_at(i), displacement_at(i)); |
duke@435 | 567 | } |
duke@435 | 568 | } |
duke@435 | 569 | #endif |
duke@435 | 570 | |
kvn@480 | 571 | #ifndef PRODUCT |
roland@5914 | 572 | void ArgInfoData::print_data_on(outputStream* st) const { |
kvn@480 | 573 | print_shared(st, "ArgInfoData"); |
kvn@480 | 574 | int nargs = number_of_args(); |
kvn@480 | 575 | for (int i = 0; i < nargs; i++) { |
kvn@480 | 576 | st->print(" 0x%x", arg_modified(i)); |
kvn@480 | 577 | } |
kvn@480 | 578 | st->cr(); |
kvn@480 | 579 | } |
kvn@480 | 580 | |
kvn@480 | 581 | #endif |
duke@435 | 582 | // ================================================================== |
coleenp@4037 | 583 | // MethodData* |
duke@435 | 584 | // |
coleenp@4037 | 585 | // A MethodData* holds information which has been collected about |
duke@435 | 586 | // a method. |
duke@435 | 587 | |
coleenp@4037 | 588 | MethodData* MethodData::allocate(ClassLoaderData* loader_data, methodHandle method, TRAPS) { |
coleenp@4037 | 589 | int size = MethodData::compute_allocation_size_in_words(method); |
coleenp@4037 | 590 | |
iklam@5208 | 591 | return new (loader_data, size, false, MetaspaceObj::MethodDataType, THREAD) |
iklam@5208 | 592 | MethodData(method(), size, CHECK_NULL); |
coleenp@4037 | 593 | } |
coleenp@4037 | 594 | |
coleenp@4037 | 595 | int MethodData::bytecode_cell_count(Bytecodes::Code code) { |
roland@4860 | 596 | #if defined(COMPILER1) && !defined(COMPILER2) |
roland@4860 | 597 | return no_profile_data; |
roland@4860 | 598 | #else |
duke@435 | 599 | switch (code) { |
duke@435 | 600 | case Bytecodes::_checkcast: |
duke@435 | 601 | case Bytecodes::_instanceof: |
duke@435 | 602 | case Bytecodes::_aastore: |
duke@435 | 603 | if (TypeProfileCasts) { |
duke@435 | 604 | return ReceiverTypeData::static_cell_count(); |
duke@435 | 605 | } else { |
duke@435 | 606 | return BitData::static_cell_count(); |
duke@435 | 607 | } |
duke@435 | 608 | case Bytecodes::_invokespecial: |
duke@435 | 609 | case Bytecodes::_invokestatic: |
roland@5921 | 610 | if (MethodData::profile_arguments() || MethodData::profile_return()) { |
roland@5914 | 611 | return variable_cell_count; |
roland@5914 | 612 | } else { |
roland@5914 | 613 | return CounterData::static_cell_count(); |
roland@5914 | 614 | } |
duke@435 | 615 | case Bytecodes::_goto: |
duke@435 | 616 | case Bytecodes::_goto_w: |
duke@435 | 617 | case Bytecodes::_jsr: |
duke@435 | 618 | case Bytecodes::_jsr_w: |
duke@435 | 619 | return JumpData::static_cell_count(); |
duke@435 | 620 | case Bytecodes::_invokevirtual: |
duke@435 | 621 | case Bytecodes::_invokeinterface: |
roland@5921 | 622 | if (MethodData::profile_arguments() || MethodData::profile_return()) { |
roland@5914 | 623 | return variable_cell_count; |
roland@5914 | 624 | } else { |
roland@5914 | 625 | return VirtualCallData::static_cell_count(); |
roland@5914 | 626 | } |
jrose@1161 | 627 | case Bytecodes::_invokedynamic: |
roland@5921 | 628 | if (MethodData::profile_arguments() || MethodData::profile_return()) { |
roland@5914 | 629 | return variable_cell_count; |
roland@5914 | 630 | } else { |
roland@5914 | 631 | return CounterData::static_cell_count(); |
roland@5914 | 632 | } |
duke@435 | 633 | case Bytecodes::_ret: |
duke@435 | 634 | return RetData::static_cell_count(); |
duke@435 | 635 | case Bytecodes::_ifeq: |
duke@435 | 636 | case Bytecodes::_ifne: |
duke@435 | 637 | case Bytecodes::_iflt: |
duke@435 | 638 | case Bytecodes::_ifge: |
duke@435 | 639 | case Bytecodes::_ifgt: |
duke@435 | 640 | case Bytecodes::_ifle: |
duke@435 | 641 | case Bytecodes::_if_icmpeq: |
duke@435 | 642 | case Bytecodes::_if_icmpne: |
duke@435 | 643 | case Bytecodes::_if_icmplt: |
duke@435 | 644 | case Bytecodes::_if_icmpge: |
duke@435 | 645 | case Bytecodes::_if_icmpgt: |
duke@435 | 646 | case Bytecodes::_if_icmple: |
duke@435 | 647 | case Bytecodes::_if_acmpeq: |
duke@435 | 648 | case Bytecodes::_if_acmpne: |
duke@435 | 649 | case Bytecodes::_ifnull: |
duke@435 | 650 | case Bytecodes::_ifnonnull: |
duke@435 | 651 | return BranchData::static_cell_count(); |
duke@435 | 652 | case Bytecodes::_lookupswitch: |
duke@435 | 653 | case Bytecodes::_tableswitch: |
duke@435 | 654 | return variable_cell_count; |
duke@435 | 655 | } |
duke@435 | 656 | return no_profile_data; |
roland@4860 | 657 | #endif |
duke@435 | 658 | } |
duke@435 | 659 | |
duke@435 | 660 | // Compute the size of the profiling information corresponding to |
duke@435 | 661 | // the current bytecode. |
coleenp@4037 | 662 | int MethodData::compute_data_size(BytecodeStream* stream) { |
duke@435 | 663 | int cell_count = bytecode_cell_count(stream->code()); |
duke@435 | 664 | if (cell_count == no_profile_data) { |
duke@435 | 665 | return 0; |
duke@435 | 666 | } |
duke@435 | 667 | if (cell_count == variable_cell_count) { |
roland@5914 | 668 | switch (stream->code()) { |
roland@5914 | 669 | case Bytecodes::_lookupswitch: |
roland@5914 | 670 | case Bytecodes::_tableswitch: |
roland@5914 | 671 | cell_count = MultiBranchData::compute_cell_count(stream); |
roland@5914 | 672 | break; |
roland@5914 | 673 | case Bytecodes::_invokespecial: |
roland@5914 | 674 | case Bytecodes::_invokestatic: |
roland@5914 | 675 | case Bytecodes::_invokedynamic: |
roland@5921 | 676 | assert(MethodData::profile_arguments() || MethodData::profile_return(), "should be collecting args profile"); |
roland@5921 | 677 | if (profile_arguments_for_invoke(stream->method(), stream->bci()) || |
roland@5921 | 678 | profile_return_for_invoke(stream->method(), stream->bci())) { |
roland@5914 | 679 | cell_count = CallTypeData::compute_cell_count(stream); |
roland@5914 | 680 | } else { |
roland@5914 | 681 | cell_count = CounterData::static_cell_count(); |
roland@5914 | 682 | } |
roland@5914 | 683 | break; |
roland@5914 | 684 | case Bytecodes::_invokevirtual: |
roland@5914 | 685 | case Bytecodes::_invokeinterface: { |
roland@5921 | 686 | assert(MethodData::profile_arguments() || MethodData::profile_return(), "should be collecting args profile"); |
roland@5921 | 687 | if (profile_arguments_for_invoke(stream->method(), stream->bci()) || |
roland@5921 | 688 | profile_return_for_invoke(stream->method(), stream->bci())) { |
roland@5914 | 689 | cell_count = VirtualCallTypeData::compute_cell_count(stream); |
roland@5914 | 690 | } else { |
roland@5914 | 691 | cell_count = VirtualCallData::static_cell_count(); |
roland@5914 | 692 | } |
roland@5914 | 693 | break; |
roland@5914 | 694 | } |
roland@5914 | 695 | default: |
roland@5914 | 696 | fatal("unexpected bytecode for var length profile data"); |
roland@5914 | 697 | } |
duke@435 | 698 | } |
duke@435 | 699 | // Note: cell_count might be zero, meaning that there is just |
duke@435 | 700 | // a DataLayout header, with no extra cells. |
duke@435 | 701 | assert(cell_count >= 0, "sanity"); |
duke@435 | 702 | return DataLayout::compute_size_in_bytes(cell_count); |
duke@435 | 703 | } |
duke@435 | 704 | |
coleenp@4037 | 705 | int MethodData::compute_extra_data_count(int data_size, int empty_bc_count) { |
duke@435 | 706 | if (ProfileTraps) { |
duke@435 | 707 | // Assume that up to 3% of BCIs with no MDP will need to allocate one. |
duke@435 | 708 | int extra_data_count = (uint)(empty_bc_count * 3) / 128 + 1; |
duke@435 | 709 | // If the method is large, let the extra BCIs grow numerous (to ~1%). |
duke@435 | 710 | int one_percent_of_data |
duke@435 | 711 | = (uint)data_size / (DataLayout::header_size_in_bytes()*128); |
duke@435 | 712 | if (extra_data_count < one_percent_of_data) |
duke@435 | 713 | extra_data_count = one_percent_of_data; |
duke@435 | 714 | if (extra_data_count > empty_bc_count) |
duke@435 | 715 | extra_data_count = empty_bc_count; // no need for more |
duke@435 | 716 | return extra_data_count; |
duke@435 | 717 | } else { |
duke@435 | 718 | return 0; |
duke@435 | 719 | } |
duke@435 | 720 | } |
duke@435 | 721 | |
coleenp@4037 | 722 | // Compute the size of the MethodData* necessary to store |
duke@435 | 723 | // profiling information about a given method. Size is in bytes. |
coleenp@4037 | 724 | int MethodData::compute_allocation_size_in_bytes(methodHandle method) { |
duke@435 | 725 | int data_size = 0; |
duke@435 | 726 | BytecodeStream stream(method); |
duke@435 | 727 | Bytecodes::Code c; |
duke@435 | 728 | int empty_bc_count = 0; // number of bytecodes lacking data |
duke@435 | 729 | while ((c = stream.next()) >= 0) { |
duke@435 | 730 | int size_in_bytes = compute_data_size(&stream); |
duke@435 | 731 | data_size += size_in_bytes; |
duke@435 | 732 | if (size_in_bytes == 0) empty_bc_count += 1; |
duke@435 | 733 | } |
duke@435 | 734 | int object_size = in_bytes(data_offset()) + data_size; |
duke@435 | 735 | |
duke@435 | 736 | // Add some extra DataLayout cells (at least one) to track stray traps. |
duke@435 | 737 | int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); |
duke@435 | 738 | object_size += extra_data_count * DataLayout::compute_size_in_bytes(0); |
duke@435 | 739 | |
kvn@480 | 740 | // Add a cell to record information about modified arguments. |
kvn@480 | 741 | int arg_size = method->size_of_parameters(); |
kvn@480 | 742 | object_size += DataLayout::compute_size_in_bytes(arg_size+1); |
roland@5914 | 743 | |
duke@435 | 744 | return object_size; |
duke@435 | 745 | } |
duke@435 | 746 | |
coleenp@4037 | 747 | // Compute the size of the MethodData* necessary to store |
duke@435 | 748 | // profiling information about a given method. Size is in words |
coleenp@4037 | 749 | int MethodData::compute_allocation_size_in_words(methodHandle method) { |
duke@435 | 750 | int byte_size = compute_allocation_size_in_bytes(method); |
duke@435 | 751 | int word_size = align_size_up(byte_size, BytesPerWord) / BytesPerWord; |
duke@435 | 752 | return align_object_size(word_size); |
duke@435 | 753 | } |
duke@435 | 754 | |
duke@435 | 755 | // Initialize an individual data segment. Returns the size of |
duke@435 | 756 | // the segment in bytes. |
coleenp@4037 | 757 | int MethodData::initialize_data(BytecodeStream* stream, |
duke@435 | 758 | int data_index) { |
roland@4860 | 759 | #if defined(COMPILER1) && !defined(COMPILER2) |
roland@4860 | 760 | return 0; |
roland@4860 | 761 | #else |
duke@435 | 762 | int cell_count = -1; |
duke@435 | 763 | int tag = DataLayout::no_tag; |
duke@435 | 764 | DataLayout* data_layout = data_layout_at(data_index); |
duke@435 | 765 | Bytecodes::Code c = stream->code(); |
duke@435 | 766 | switch (c) { |
duke@435 | 767 | case Bytecodes::_checkcast: |
duke@435 | 768 | case Bytecodes::_instanceof: |
duke@435 | 769 | case Bytecodes::_aastore: |
duke@435 | 770 | if (TypeProfileCasts) { |
duke@435 | 771 | cell_count = ReceiverTypeData::static_cell_count(); |
duke@435 | 772 | tag = DataLayout::receiver_type_data_tag; |
duke@435 | 773 | } else { |
duke@435 | 774 | cell_count = BitData::static_cell_count(); |
duke@435 | 775 | tag = DataLayout::bit_data_tag; |
duke@435 | 776 | } |
duke@435 | 777 | break; |
duke@435 | 778 | case Bytecodes::_invokespecial: |
roland@5914 | 779 | case Bytecodes::_invokestatic: { |
roland@5914 | 780 | int counter_data_cell_count = CounterData::static_cell_count(); |
roland@5921 | 781 | if (profile_arguments_for_invoke(stream->method(), stream->bci()) || |
roland@5921 | 782 | profile_return_for_invoke(stream->method(), stream->bci())) { |
roland@5914 | 783 | cell_count = CallTypeData::compute_cell_count(stream); |
roland@5914 | 784 | } else { |
roland@5914 | 785 | cell_count = counter_data_cell_count; |
roland@5914 | 786 | } |
roland@5914 | 787 | if (cell_count > counter_data_cell_count) { |
roland@5914 | 788 | tag = DataLayout::call_type_data_tag; |
roland@5914 | 789 | } else { |
roland@5914 | 790 | tag = DataLayout::counter_data_tag; |
roland@5914 | 791 | } |
duke@435 | 792 | break; |
roland@5914 | 793 | } |
duke@435 | 794 | case Bytecodes::_goto: |
duke@435 | 795 | case Bytecodes::_goto_w: |
duke@435 | 796 | case Bytecodes::_jsr: |
duke@435 | 797 | case Bytecodes::_jsr_w: |
duke@435 | 798 | cell_count = JumpData::static_cell_count(); |
duke@435 | 799 | tag = DataLayout::jump_data_tag; |
duke@435 | 800 | break; |
duke@435 | 801 | case Bytecodes::_invokevirtual: |
roland@5914 | 802 | case Bytecodes::_invokeinterface: { |
roland@5914 | 803 | int virtual_call_data_cell_count = VirtualCallData::static_cell_count(); |
roland@5921 | 804 | if (profile_arguments_for_invoke(stream->method(), stream->bci()) || |
roland@5921 | 805 | profile_return_for_invoke(stream->method(), stream->bci())) { |
roland@5914 | 806 | cell_count = VirtualCallTypeData::compute_cell_count(stream); |
roland@5914 | 807 | } else { |
roland@5914 | 808 | cell_count = virtual_call_data_cell_count; |
roland@5914 | 809 | } |
roland@5914 | 810 | if (cell_count > virtual_call_data_cell_count) { |
roland@5914 | 811 | tag = DataLayout::virtual_call_type_data_tag; |
roland@5914 | 812 | } else { |
roland@5914 | 813 | tag = DataLayout::virtual_call_data_tag; |
roland@5914 | 814 | } |
duke@435 | 815 | break; |
roland@5914 | 816 | } |
roland@5914 | 817 | case Bytecodes::_invokedynamic: { |
jrose@1161 | 818 | // %%% should make a type profile for any invokedynamic that takes a ref argument |
roland@5914 | 819 | int counter_data_cell_count = CounterData::static_cell_count(); |
roland@5921 | 820 | if (profile_arguments_for_invoke(stream->method(), stream->bci()) || |
roland@5921 | 821 | profile_return_for_invoke(stream->method(), stream->bci())) { |
roland@5914 | 822 | cell_count = CallTypeData::compute_cell_count(stream); |
roland@5914 | 823 | } else { |
roland@5914 | 824 | cell_count = counter_data_cell_count; |
roland@5914 | 825 | } |
roland@5914 | 826 | if (cell_count > counter_data_cell_count) { |
roland@5914 | 827 | tag = DataLayout::call_type_data_tag; |
roland@5914 | 828 | } else { |
roland@5914 | 829 | tag = DataLayout::counter_data_tag; |
roland@5914 | 830 | } |
jrose@1161 | 831 | break; |
roland@5914 | 832 | } |
duke@435 | 833 | case Bytecodes::_ret: |
duke@435 | 834 | cell_count = RetData::static_cell_count(); |
duke@435 | 835 | tag = DataLayout::ret_data_tag; |
duke@435 | 836 | break; |
duke@435 | 837 | case Bytecodes::_ifeq: |
duke@435 | 838 | case Bytecodes::_ifne: |
duke@435 | 839 | case Bytecodes::_iflt: |
duke@435 | 840 | case Bytecodes::_ifge: |
duke@435 | 841 | case Bytecodes::_ifgt: |
duke@435 | 842 | case Bytecodes::_ifle: |
duke@435 | 843 | case Bytecodes::_if_icmpeq: |
duke@435 | 844 | case Bytecodes::_if_icmpne: |
duke@435 | 845 | case Bytecodes::_if_icmplt: |
duke@435 | 846 | case Bytecodes::_if_icmpge: |
duke@435 | 847 | case Bytecodes::_if_icmpgt: |
duke@435 | 848 | case Bytecodes::_if_icmple: |
duke@435 | 849 | case Bytecodes::_if_acmpeq: |
duke@435 | 850 | case Bytecodes::_if_acmpne: |
duke@435 | 851 | case Bytecodes::_ifnull: |
duke@435 | 852 | case Bytecodes::_ifnonnull: |
duke@435 | 853 | cell_count = BranchData::static_cell_count(); |
duke@435 | 854 | tag = DataLayout::branch_data_tag; |
duke@435 | 855 | break; |
duke@435 | 856 | case Bytecodes::_lookupswitch: |
duke@435 | 857 | case Bytecodes::_tableswitch: |
duke@435 | 858 | cell_count = MultiBranchData::compute_cell_count(stream); |
duke@435 | 859 | tag = DataLayout::multi_branch_data_tag; |
duke@435 | 860 | break; |
duke@435 | 861 | } |
duke@435 | 862 | assert(tag == DataLayout::multi_branch_data_tag || |
roland@5921 | 863 | ((MethodData::profile_arguments() || MethodData::profile_return()) && |
roland@5914 | 864 | (tag == DataLayout::call_type_data_tag || |
roland@5914 | 865 | tag == DataLayout::counter_data_tag || |
roland@5914 | 866 | tag == DataLayout::virtual_call_type_data_tag || |
roland@5914 | 867 | tag == DataLayout::virtual_call_data_tag)) || |
duke@435 | 868 | cell_count == bytecode_cell_count(c), "cell counts must agree"); |
duke@435 | 869 | if (cell_count >= 0) { |
duke@435 | 870 | assert(tag != DataLayout::no_tag, "bad tag"); |
duke@435 | 871 | assert(bytecode_has_profile(c), "agree w/ BHP"); |
duke@435 | 872 | data_layout->initialize(tag, stream->bci(), cell_count); |
duke@435 | 873 | return DataLayout::compute_size_in_bytes(cell_count); |
duke@435 | 874 | } else { |
duke@435 | 875 | assert(!bytecode_has_profile(c), "agree w/ !BHP"); |
duke@435 | 876 | return 0; |
duke@435 | 877 | } |
roland@4860 | 878 | #endif |
duke@435 | 879 | } |
duke@435 | 880 | |
duke@435 | 881 | // Get the data at an arbitrary (sort of) data index. |
coleenp@4037 | 882 | ProfileData* MethodData::data_at(int data_index) const { |
duke@435 | 883 | if (out_of_bounds(data_index)) { |
duke@435 | 884 | return NULL; |
duke@435 | 885 | } |
duke@435 | 886 | DataLayout* data_layout = data_layout_at(data_index); |
ysr@1376 | 887 | return data_layout->data_in(); |
ysr@1376 | 888 | } |
duke@435 | 889 | |
ysr@1376 | 890 | ProfileData* DataLayout::data_in() { |
ysr@1376 | 891 | switch (tag()) { |
duke@435 | 892 | case DataLayout::no_tag: |
duke@435 | 893 | default: |
duke@435 | 894 | ShouldNotReachHere(); |
duke@435 | 895 | return NULL; |
duke@435 | 896 | case DataLayout::bit_data_tag: |
ysr@1376 | 897 | return new BitData(this); |
duke@435 | 898 | case DataLayout::counter_data_tag: |
ysr@1376 | 899 | return new CounterData(this); |
duke@435 | 900 | case DataLayout::jump_data_tag: |
ysr@1376 | 901 | return new JumpData(this); |
duke@435 | 902 | case DataLayout::receiver_type_data_tag: |
ysr@1376 | 903 | return new ReceiverTypeData(this); |
duke@435 | 904 | case DataLayout::virtual_call_data_tag: |
ysr@1376 | 905 | return new VirtualCallData(this); |
duke@435 | 906 | case DataLayout::ret_data_tag: |
ysr@1376 | 907 | return new RetData(this); |
duke@435 | 908 | case DataLayout::branch_data_tag: |
ysr@1376 | 909 | return new BranchData(this); |
duke@435 | 910 | case DataLayout::multi_branch_data_tag: |
ysr@1376 | 911 | return new MultiBranchData(this); |
kvn@480 | 912 | case DataLayout::arg_info_data_tag: |
ysr@1376 | 913 | return new ArgInfoData(this); |
roland@5914 | 914 | case DataLayout::call_type_data_tag: |
roland@5914 | 915 | return new CallTypeData(this); |
roland@5914 | 916 | case DataLayout::virtual_call_type_data_tag: |
roland@5914 | 917 | return new VirtualCallTypeData(this); |
duke@435 | 918 | }; |
duke@435 | 919 | } |
duke@435 | 920 | |
duke@435 | 921 | // Iteration over data. |
coleenp@4037 | 922 | ProfileData* MethodData::next_data(ProfileData* current) const { |
duke@435 | 923 | int current_index = dp_to_di(current->dp()); |
duke@435 | 924 | int next_index = current_index + current->size_in_bytes(); |
duke@435 | 925 | ProfileData* next = data_at(next_index); |
duke@435 | 926 | return next; |
duke@435 | 927 | } |
duke@435 | 928 | |
duke@435 | 929 | // Give each of the data entries a chance to perform specific |
duke@435 | 930 | // data initialization. |
coleenp@4037 | 931 | void MethodData::post_initialize(BytecodeStream* stream) { |
duke@435 | 932 | ResourceMark rm; |
duke@435 | 933 | ProfileData* data; |
duke@435 | 934 | for (data = first_data(); is_valid(data); data = next_data(data)) { |
duke@435 | 935 | stream->set_start(data->bci()); |
duke@435 | 936 | stream->next(); |
duke@435 | 937 | data->post_initialize(stream, this); |
duke@435 | 938 | } |
duke@435 | 939 | } |
duke@435 | 940 | |
coleenp@4037 | 941 | // Initialize the MethodData* corresponding to a given method. |
coleenp@4037 | 942 | MethodData::MethodData(methodHandle method, int size, TRAPS) { |
coleenp@4037 | 943 | No_Safepoint_Verifier no_safepoint; // init function atomic wrt GC |
duke@435 | 944 | ResourceMark rm; |
duke@435 | 945 | // Set the method back-pointer. |
duke@435 | 946 | _method = method(); |
iveresov@2138 | 947 | |
iignatyev@4908 | 948 | init(); |
duke@435 | 949 | set_creation_mileage(mileage_of(method())); |
duke@435 | 950 | |
duke@435 | 951 | // Go through the bytecodes and allocate and initialize the |
duke@435 | 952 | // corresponding data cells. |
duke@435 | 953 | int data_size = 0; |
duke@435 | 954 | int empty_bc_count = 0; // number of bytecodes lacking data |
coleenp@4712 | 955 | _data[0] = 0; // apparently not set below. |
duke@435 | 956 | BytecodeStream stream(method); |
duke@435 | 957 | Bytecodes::Code c; |
duke@435 | 958 | while ((c = stream.next()) >= 0) { |
duke@435 | 959 | int size_in_bytes = initialize_data(&stream, data_size); |
duke@435 | 960 | data_size += size_in_bytes; |
duke@435 | 961 | if (size_in_bytes == 0) empty_bc_count += 1; |
duke@435 | 962 | } |
duke@435 | 963 | _data_size = data_size; |
duke@435 | 964 | int object_size = in_bytes(data_offset()) + data_size; |
duke@435 | 965 | |
duke@435 | 966 | // Add some extra DataLayout cells (at least one) to track stray traps. |
duke@435 | 967 | int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); |
kvn@480 | 968 | int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0); |
kvn@480 | 969 | |
kvn@480 | 970 | // Add a cell to record information about modified arguments. |
kvn@480 | 971 | // Set up _args_modified array after traps cells so that |
kvn@480 | 972 | // the code for traps cells works. |
kvn@480 | 973 | DataLayout *dp = data_layout_at(data_size + extra_size); |
kvn@480 | 974 | |
kvn@480 | 975 | int arg_size = method->size_of_parameters(); |
kvn@480 | 976 | dp->initialize(DataLayout::arg_info_data_tag, 0, arg_size+1); |
kvn@480 | 977 | |
kvn@480 | 978 | object_size += extra_size + DataLayout::compute_size_in_bytes(arg_size+1); |
duke@435 | 979 | |
duke@435 | 980 | // Set an initial hint. Don't use set_hint_di() because |
duke@435 | 981 | // first_di() may be out of bounds if data_size is 0. |
duke@435 | 982 | // In that situation, _hint_di is never used, but at |
duke@435 | 983 | // least well-defined. |
duke@435 | 984 | _hint_di = first_di(); |
duke@435 | 985 | |
duke@435 | 986 | post_initialize(&stream); |
duke@435 | 987 | |
coleenp@4037 | 988 | set_size(object_size); |
iignatyev@4908 | 989 | } |
coleenp@4712 | 990 | |
iignatyev@4908 | 991 | void MethodData::init() { |
iignatyev@4908 | 992 | _invocation_counter.init(); |
iignatyev@4908 | 993 | _backedge_counter.init(); |
iignatyev@4908 | 994 | _invocation_counter_start = 0; |
iignatyev@4908 | 995 | _backedge_counter_start = 0; |
iignatyev@4908 | 996 | _num_loops = 0; |
iignatyev@4908 | 997 | _num_blocks = 0; |
iignatyev@4908 | 998 | _highest_comp_level = 0; |
iignatyev@4908 | 999 | _highest_osr_comp_level = 0; |
iignatyev@4908 | 1000 | _would_profile = true; |
iignatyev@4908 | 1001 | |
iignatyev@4908 | 1002 | // Initialize flags and trap history. |
iignatyev@4908 | 1003 | _nof_decompiles = 0; |
iignatyev@4908 | 1004 | _nof_overflow_recompiles = 0; |
iignatyev@4908 | 1005 | _nof_overflow_traps = 0; |
iignatyev@4908 | 1006 | clear_escape_info(); |
iignatyev@4908 | 1007 | assert(sizeof(_trap_hist) % sizeof(HeapWord) == 0, "align"); |
iignatyev@4908 | 1008 | Copy::zero_to_words((HeapWord*) &_trap_hist, |
iignatyev@4908 | 1009 | sizeof(_trap_hist) / sizeof(HeapWord)); |
duke@435 | 1010 | } |
duke@435 | 1011 | |
duke@435 | 1012 | // Get a measure of how much mileage the method has on it. |
coleenp@4037 | 1013 | int MethodData::mileage_of(Method* method) { |
duke@435 | 1014 | int mileage = 0; |
iveresov@2138 | 1015 | if (TieredCompilation) { |
iveresov@2138 | 1016 | mileage = MAX2(method->invocation_count(), method->backedge_count()); |
iveresov@2138 | 1017 | } else { |
iveresov@2138 | 1018 | int iic = method->interpreter_invocation_count(); |
iveresov@2138 | 1019 | if (mileage < iic) mileage = iic; |
jiangli@4936 | 1020 | MethodCounters* mcs = method->method_counters(); |
jiangli@4936 | 1021 | if (mcs != NULL) { |
jiangli@4936 | 1022 | InvocationCounter* ic = mcs->invocation_counter(); |
jiangli@4936 | 1023 | InvocationCounter* bc = mcs->backedge_counter(); |
jiangli@4936 | 1024 | int icval = ic->count(); |
jiangli@4936 | 1025 | if (ic->carry()) icval += CompileThreshold; |
jiangli@4936 | 1026 | if (mileage < icval) mileage = icval; |
jiangli@4936 | 1027 | int bcval = bc->count(); |
jiangli@4936 | 1028 | if (bc->carry()) bcval += CompileThreshold; |
jiangli@4936 | 1029 | if (mileage < bcval) mileage = bcval; |
jiangli@4936 | 1030 | } |
iveresov@2138 | 1031 | } |
duke@435 | 1032 | return mileage; |
duke@435 | 1033 | } |
duke@435 | 1034 | |
coleenp@4037 | 1035 | bool MethodData::is_mature() const { |
iveresov@2138 | 1036 | return CompilationPolicy::policy()->is_mature(_method); |
duke@435 | 1037 | } |
duke@435 | 1038 | |
duke@435 | 1039 | // Translate a bci to its corresponding data index (di). |
coleenp@4037 | 1040 | address MethodData::bci_to_dp(int bci) { |
duke@435 | 1041 | ResourceMark rm; |
duke@435 | 1042 | ProfileData* data = data_before(bci); |
duke@435 | 1043 | ProfileData* prev = NULL; |
duke@435 | 1044 | for ( ; is_valid(data); data = next_data(data)) { |
duke@435 | 1045 | if (data->bci() >= bci) { |
duke@435 | 1046 | if (data->bci() == bci) set_hint_di(dp_to_di(data->dp())); |
duke@435 | 1047 | else if (prev != NULL) set_hint_di(dp_to_di(prev->dp())); |
duke@435 | 1048 | return data->dp(); |
duke@435 | 1049 | } |
duke@435 | 1050 | prev = data; |
duke@435 | 1051 | } |
duke@435 | 1052 | return (address)limit_data_position(); |
duke@435 | 1053 | } |
duke@435 | 1054 | |
duke@435 | 1055 | // Translate a bci to its corresponding data, or NULL. |
coleenp@4037 | 1056 | ProfileData* MethodData::bci_to_data(int bci) { |
duke@435 | 1057 | ProfileData* data = data_before(bci); |
duke@435 | 1058 | for ( ; is_valid(data); data = next_data(data)) { |
duke@435 | 1059 | if (data->bci() == bci) { |
duke@435 | 1060 | set_hint_di(dp_to_di(data->dp())); |
duke@435 | 1061 | return data; |
duke@435 | 1062 | } else if (data->bci() > bci) { |
duke@435 | 1063 | break; |
duke@435 | 1064 | } |
duke@435 | 1065 | } |
duke@435 | 1066 | return bci_to_extra_data(bci, false); |
duke@435 | 1067 | } |
duke@435 | 1068 | |
duke@435 | 1069 | // Translate a bci to its corresponding extra data, or NULL. |
coleenp@4037 | 1070 | ProfileData* MethodData::bci_to_extra_data(int bci, bool create_if_missing) { |
duke@435 | 1071 | DataLayout* dp = extra_data_base(); |
duke@435 | 1072 | DataLayout* end = extra_data_limit(); |
duke@435 | 1073 | DataLayout* avail = NULL; |
duke@435 | 1074 | for (; dp < end; dp = next_extra(dp)) { |
duke@435 | 1075 | // No need for "OrderAccess::load_acquire" ops, |
duke@435 | 1076 | // since the data structure is monotonic. |
duke@435 | 1077 | if (dp->tag() == DataLayout::no_tag) break; |
kvn@480 | 1078 | if (dp->tag() == DataLayout::arg_info_data_tag) { |
kvn@480 | 1079 | dp = end; // ArgInfoData is at the end of extra data section. |
kvn@480 | 1080 | break; |
kvn@480 | 1081 | } |
duke@435 | 1082 | if (dp->bci() == bci) { |
duke@435 | 1083 | assert(dp->tag() == DataLayout::bit_data_tag, "sane"); |
duke@435 | 1084 | return new BitData(dp); |
duke@435 | 1085 | } |
duke@435 | 1086 | } |
duke@435 | 1087 | if (create_if_missing && dp < end) { |
duke@435 | 1088 | // Allocate this one. There is no mutual exclusion, |
duke@435 | 1089 | // so two threads could allocate different BCIs to the |
duke@435 | 1090 | // same data layout. This means these extra data |
duke@435 | 1091 | // records, like most other MDO contents, must not be |
duke@435 | 1092 | // trusted too much. |
duke@435 | 1093 | DataLayout temp; |
duke@435 | 1094 | temp.initialize(DataLayout::bit_data_tag, bci, 0); |
duke@435 | 1095 | dp->release_set_header(temp.header()); |
duke@435 | 1096 | assert(dp->tag() == DataLayout::bit_data_tag, "sane"); |
duke@435 | 1097 | //NO: assert(dp->bci() == bci, "no concurrent allocation"); |
duke@435 | 1098 | return new BitData(dp); |
duke@435 | 1099 | } |
duke@435 | 1100 | return NULL; |
duke@435 | 1101 | } |
duke@435 | 1102 | |
coleenp@4037 | 1103 | ArgInfoData *MethodData::arg_info() { |
kvn@480 | 1104 | DataLayout* dp = extra_data_base(); |
kvn@480 | 1105 | DataLayout* end = extra_data_limit(); |
kvn@480 | 1106 | for (; dp < end; dp = next_extra(dp)) { |
kvn@480 | 1107 | if (dp->tag() == DataLayout::arg_info_data_tag) |
kvn@480 | 1108 | return new ArgInfoData(dp); |
kvn@480 | 1109 | } |
kvn@480 | 1110 | return NULL; |
kvn@480 | 1111 | } |
kvn@480 | 1112 | |
coleenp@4037 | 1113 | // Printing |
coleenp@4037 | 1114 | |
duke@435 | 1115 | #ifndef PRODUCT |
coleenp@4037 | 1116 | |
coleenp@4037 | 1117 | void MethodData::print_on(outputStream* st) const { |
coleenp@4037 | 1118 | assert(is_methodData(), "should be method data"); |
coleenp@4037 | 1119 | st->print("method data for "); |
coleenp@4037 | 1120 | method()->print_value_on(st); |
coleenp@4037 | 1121 | st->cr(); |
coleenp@4037 | 1122 | print_data_on(st); |
coleenp@4037 | 1123 | } |
coleenp@4037 | 1124 | |
coleenp@4037 | 1125 | #endif //PRODUCT |
coleenp@4037 | 1126 | |
coleenp@4037 | 1127 | void MethodData::print_value_on(outputStream* st) const { |
coleenp@4037 | 1128 | assert(is_methodData(), "should be method data"); |
coleenp@4037 | 1129 | st->print("method data for "); |
coleenp@4037 | 1130 | method()->print_value_on(st); |
coleenp@4037 | 1131 | } |
coleenp@4037 | 1132 | |
coleenp@4037 | 1133 | #ifndef PRODUCT |
coleenp@4037 | 1134 | void MethodData::print_data_on(outputStream* st) const { |
duke@435 | 1135 | ResourceMark rm; |
duke@435 | 1136 | ProfileData* data = first_data(); |
duke@435 | 1137 | for ( ; is_valid(data); data = next_data(data)) { |
duke@435 | 1138 | st->print("%d", dp_to_di(data->dp())); |
duke@435 | 1139 | st->fill_to(6); |
duke@435 | 1140 | data->print_data_on(st); |
duke@435 | 1141 | } |
kvn@480 | 1142 | st->print_cr("--- Extra data:"); |
duke@435 | 1143 | DataLayout* dp = extra_data_base(); |
duke@435 | 1144 | DataLayout* end = extra_data_limit(); |
duke@435 | 1145 | for (; dp < end; dp = next_extra(dp)) { |
duke@435 | 1146 | // No need for "OrderAccess::load_acquire" ops, |
duke@435 | 1147 | // since the data structure is monotonic. |
kvn@480 | 1148 | if (dp->tag() == DataLayout::no_tag) continue; |
kvn@480 | 1149 | if (dp->tag() == DataLayout::bit_data_tag) { |
kvn@480 | 1150 | data = new BitData(dp); |
kvn@480 | 1151 | } else { |
kvn@480 | 1152 | assert(dp->tag() == DataLayout::arg_info_data_tag, "must be BitData or ArgInfo"); |
kvn@480 | 1153 | data = new ArgInfoData(dp); |
kvn@480 | 1154 | dp = end; // ArgInfoData is at the end of extra data section. |
kvn@480 | 1155 | } |
duke@435 | 1156 | st->print("%d", dp_to_di(data->dp())); |
duke@435 | 1157 | st->fill_to(6); |
duke@435 | 1158 | data->print_data_on(st); |
duke@435 | 1159 | } |
duke@435 | 1160 | } |
duke@435 | 1161 | #endif |
duke@435 | 1162 | |
acorn@4497 | 1163 | #if INCLUDE_SERVICES |
acorn@4497 | 1164 | // Size Statistics |
acorn@4497 | 1165 | void MethodData::collect_statistics(KlassSizeStats *sz) const { |
acorn@4497 | 1166 | int n = sz->count(this); |
acorn@4497 | 1167 | sz->_method_data_bytes += n; |
acorn@4497 | 1168 | sz->_method_all_bytes += n; |
acorn@4497 | 1169 | sz->_rw_bytes += n; |
acorn@4497 | 1170 | } |
acorn@4497 | 1171 | #endif // INCLUDE_SERVICES |
coleenp@4037 | 1172 | |
coleenp@4037 | 1173 | // Verification |
coleenp@4037 | 1174 | |
coleenp@4037 | 1175 | void MethodData::verify_on(outputStream* st) { |
coleenp@4037 | 1176 | guarantee(is_methodData(), "object must be method data"); |
coleenp@4037 | 1177 | // guarantee(m->is_perm(), "should be in permspace"); |
coleenp@4037 | 1178 | this->verify_data_on(st); |
coleenp@4037 | 1179 | } |
coleenp@4037 | 1180 | |
coleenp@4037 | 1181 | void MethodData::verify_data_on(outputStream* st) { |
duke@435 | 1182 | NEEDS_CLEANUP; |
duke@435 | 1183 | // not yet implemented. |
duke@435 | 1184 | } |
roland@5914 | 1185 | |
roland@5914 | 1186 | bool MethodData::profile_jsr292(methodHandle m, int bci) { |
roland@5914 | 1187 | if (m->is_compiled_lambda_form()) { |
roland@5914 | 1188 | return true; |
roland@5914 | 1189 | } |
roland@5914 | 1190 | |
roland@5914 | 1191 | Bytecode_invoke inv(m , bci); |
roland@5914 | 1192 | return inv.is_invokedynamic() || inv.is_invokehandle(); |
roland@5914 | 1193 | } |
roland@5914 | 1194 | |
roland@5914 | 1195 | int MethodData::profile_arguments_flag() { |
roland@5921 | 1196 | return TypeProfileLevel % 10; |
roland@5914 | 1197 | } |
roland@5914 | 1198 | |
roland@5914 | 1199 | bool MethodData::profile_arguments() { |
roland@5914 | 1200 | return profile_arguments_flag() > no_type_profile && profile_arguments_flag() <= type_profile_all; |
roland@5914 | 1201 | } |
roland@5914 | 1202 | |
roland@5914 | 1203 | bool MethodData::profile_arguments_jsr292_only() { |
roland@5914 | 1204 | return profile_arguments_flag() == type_profile_jsr292; |
roland@5914 | 1205 | } |
roland@5914 | 1206 | |
roland@5914 | 1207 | bool MethodData::profile_all_arguments() { |
roland@5914 | 1208 | return profile_arguments_flag() == type_profile_all; |
roland@5914 | 1209 | } |
roland@5914 | 1210 | |
roland@5914 | 1211 | bool MethodData::profile_arguments_for_invoke(methodHandle m, int bci) { |
roland@5914 | 1212 | if (!profile_arguments()) { |
roland@5914 | 1213 | return false; |
roland@5914 | 1214 | } |
roland@5914 | 1215 | |
roland@5914 | 1216 | if (profile_all_arguments()) { |
roland@5914 | 1217 | return true; |
roland@5914 | 1218 | } |
roland@5914 | 1219 | |
roland@5914 | 1220 | assert(profile_arguments_jsr292_only(), "inconsistent"); |
roland@5914 | 1221 | return profile_jsr292(m, bci); |
roland@5914 | 1222 | } |
roland@5914 | 1223 | |
roland@5921 | 1224 | int MethodData::profile_return_flag() { |
roland@5921 | 1225 | return TypeProfileLevel / 10; |
roland@5921 | 1226 | } |
roland@5921 | 1227 | |
roland@5921 | 1228 | bool MethodData::profile_return() { |
roland@5921 | 1229 | return profile_return_flag() > no_type_profile && profile_return_flag() <= type_profile_all; |
roland@5921 | 1230 | } |
roland@5921 | 1231 | |
roland@5921 | 1232 | bool MethodData::profile_return_jsr292_only() { |
roland@5921 | 1233 | return profile_return_flag() == type_profile_jsr292; |
roland@5921 | 1234 | } |
roland@5921 | 1235 | |
roland@5921 | 1236 | bool MethodData::profile_all_return() { |
roland@5921 | 1237 | return profile_return_flag() == type_profile_all; |
roland@5921 | 1238 | } |
roland@5921 | 1239 | |
roland@5921 | 1240 | bool MethodData::profile_return_for_invoke(methodHandle m, int bci) { |
roland@5921 | 1241 | if (!profile_return()) { |
roland@5921 | 1242 | return false; |
roland@5921 | 1243 | } |
roland@5921 | 1244 | |
roland@5921 | 1245 | if (profile_all_return()) { |
roland@5921 | 1246 | return true; |
roland@5921 | 1247 | } |
roland@5921 | 1248 | |
roland@5921 | 1249 | assert(profile_return_jsr292_only(), "inconsistent"); |
roland@5921 | 1250 | return profile_jsr292(m, bci); |
roland@5921 | 1251 | } |