Tue, 17 Oct 2017 12:58:25 +0800
merge
aoqi@0 | 1 | /* |
dlong@7598 | 2 | * Copyright (c) 1998, 2015, 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@1 | 25 | /* |
aoqi@1 | 26 | * This file has been modified by Loongson Technology in 2015. These |
aoqi@1 | 27 | * modifications are Copyright (c) 2015 Loongson Technology, and are made |
aoqi@1 | 28 | * available on the same license terms set forth above. |
aoqi@1 | 29 | */ |
aoqi@1 | 30 | |
aoqi@0 | 31 | #include "precompiled.hpp" |
aoqi@0 | 32 | #include "classfile/systemDictionary.hpp" |
aoqi@0 | 33 | #include "classfile/vmSymbols.hpp" |
aoqi@0 | 34 | #include "code/compiledIC.hpp" |
aoqi@0 | 35 | #include "code/icBuffer.hpp" |
aoqi@0 | 36 | #include "code/nmethod.hpp" |
aoqi@0 | 37 | #include "code/pcDesc.hpp" |
aoqi@0 | 38 | #include "code/scopeDesc.hpp" |
aoqi@0 | 39 | #include "code/vtableStubs.hpp" |
aoqi@0 | 40 | #include "compiler/compileBroker.hpp" |
aoqi@0 | 41 | #include "compiler/compilerOracle.hpp" |
aoqi@0 | 42 | #include "compiler/oopMap.hpp" |
aoqi@0 | 43 | #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" |
aoqi@0 | 44 | #include "gc_implementation/g1/heapRegion.hpp" |
aoqi@0 | 45 | #include "gc_interface/collectedHeap.hpp" |
aoqi@0 | 46 | #include "interpreter/bytecode.hpp" |
aoqi@0 | 47 | #include "interpreter/interpreter.hpp" |
aoqi@0 | 48 | #include "interpreter/linkResolver.hpp" |
aoqi@0 | 49 | #include "memory/barrierSet.hpp" |
aoqi@0 | 50 | #include "memory/gcLocker.inline.hpp" |
aoqi@0 | 51 | #include "memory/oopFactory.hpp" |
aoqi@0 | 52 | #include "oops/objArrayKlass.hpp" |
aoqi@0 | 53 | #include "oops/oop.inline.hpp" |
aoqi@0 | 54 | #include "opto/addnode.hpp" |
aoqi@0 | 55 | #include "opto/callnode.hpp" |
aoqi@0 | 56 | #include "opto/cfgnode.hpp" |
aoqi@0 | 57 | #include "opto/connode.hpp" |
aoqi@0 | 58 | #include "opto/graphKit.hpp" |
aoqi@0 | 59 | #include "opto/machnode.hpp" |
aoqi@0 | 60 | #include "opto/matcher.hpp" |
aoqi@0 | 61 | #include "opto/memnode.hpp" |
aoqi@0 | 62 | #include "opto/mulnode.hpp" |
aoqi@0 | 63 | #include "opto/runtime.hpp" |
aoqi@0 | 64 | #include "opto/subnode.hpp" |
aoqi@0 | 65 | #include "runtime/fprofiler.hpp" |
aoqi@0 | 66 | #include "runtime/handles.inline.hpp" |
aoqi@0 | 67 | #include "runtime/interfaceSupport.hpp" |
aoqi@0 | 68 | #include "runtime/javaCalls.hpp" |
aoqi@0 | 69 | #include "runtime/sharedRuntime.hpp" |
aoqi@0 | 70 | #include "runtime/signature.hpp" |
aoqi@0 | 71 | #include "runtime/threadCritical.hpp" |
aoqi@0 | 72 | #include "runtime/vframe.hpp" |
aoqi@0 | 73 | #include "runtime/vframeArray.hpp" |
aoqi@0 | 74 | #include "runtime/vframe_hp.hpp" |
aoqi@0 | 75 | #include "utilities/copy.hpp" |
aoqi@0 | 76 | #include "utilities/preserveException.hpp" |
dlong@7598 | 77 | #if defined AD_MD_HPP |
dlong@7598 | 78 | # include AD_MD_HPP |
dlong@7598 | 79 | #elif defined TARGET_ARCH_MODEL_x86_32 |
aoqi@0 | 80 | # include "adfiles/ad_x86_32.hpp" |
dlong@7598 | 81 | #elif defined TARGET_ARCH_MODEL_x86_64 |
aoqi@0 | 82 | # include "adfiles/ad_x86_64.hpp" |
dlong@7598 | 83 | #elif defined TARGET_ARCH_MODEL_sparc |
kvn@7152 | 84 | # include "adfiles/ad_sparc.hpp" |
dlong@7598 | 85 | #elif defined TARGET_ARCH_MODEL_zero |
kvn@7152 | 86 | # include "adfiles/ad_zero.hpp" |
dlong@7598 | 87 | #elif defined TARGET_ARCH_MODEL_ppc_64 |
kvn@7152 | 88 | # include "adfiles/ad_ppc_64.hpp" |
aoqi@7994 | 89 | #elif defined TARGET_ARCH_MODEL_mips_64 |
aoqi@1 | 90 | # include "adfiles/ad_mips_64.hpp" |
aoqi@1 | 91 | #endif |
aoqi@0 | 92 | |
aoqi@0 | 93 | |
aoqi@0 | 94 | // For debugging purposes: |
aoqi@0 | 95 | // To force FullGCALot inside a runtime function, add the following two lines |
aoqi@0 | 96 | // |
aoqi@0 | 97 | // Universe::release_fullgc_alot_dummy(); |
aoqi@0 | 98 | // MarkSweep::invoke(0, "Debugging"); |
aoqi@0 | 99 | // |
aoqi@0 | 100 | // At command line specify the parameters: -XX:+FullGCALot -XX:FullGCALotStart=100000000 |
aoqi@0 | 101 | |
aoqi@0 | 102 | |
aoqi@0 | 103 | |
aoqi@0 | 104 | |
aoqi@0 | 105 | // Compiled code entry points |
aoqi@0 | 106 | address OptoRuntime::_new_instance_Java = NULL; |
aoqi@0 | 107 | address OptoRuntime::_new_array_Java = NULL; |
aoqi@0 | 108 | address OptoRuntime::_new_array_nozero_Java = NULL; |
aoqi@0 | 109 | address OptoRuntime::_multianewarray2_Java = NULL; |
aoqi@0 | 110 | address OptoRuntime::_multianewarray3_Java = NULL; |
aoqi@0 | 111 | address OptoRuntime::_multianewarray4_Java = NULL; |
aoqi@0 | 112 | address OptoRuntime::_multianewarray5_Java = NULL; |
aoqi@0 | 113 | address OptoRuntime::_multianewarrayN_Java = NULL; |
aoqi@0 | 114 | address OptoRuntime::_g1_wb_pre_Java = NULL; |
aoqi@0 | 115 | address OptoRuntime::_g1_wb_post_Java = NULL; |
aoqi@0 | 116 | address OptoRuntime::_vtable_must_compile_Java = NULL; |
aoqi@0 | 117 | address OptoRuntime::_complete_monitor_locking_Java = NULL; |
aoqi@0 | 118 | address OptoRuntime::_rethrow_Java = NULL; |
aoqi@0 | 119 | |
aoqi@0 | 120 | address OptoRuntime::_slow_arraycopy_Java = NULL; |
aoqi@0 | 121 | address OptoRuntime::_register_finalizer_Java = NULL; |
aoqi@0 | 122 | |
aoqi@0 | 123 | # ifdef ENABLE_ZAP_DEAD_LOCALS |
aoqi@0 | 124 | address OptoRuntime::_zap_dead_Java_locals_Java = NULL; |
aoqi@0 | 125 | address OptoRuntime::_zap_dead_native_locals_Java = NULL; |
aoqi@0 | 126 | # endif |
aoqi@0 | 127 | |
aoqi@0 | 128 | ExceptionBlob* OptoRuntime::_exception_blob; |
aoqi@0 | 129 | |
aoqi@0 | 130 | // This should be called in an assertion at the start of OptoRuntime routines |
aoqi@0 | 131 | // which are entered from compiled code (all of them) |
aoqi@0 | 132 | #ifdef ASSERT |
aoqi@0 | 133 | static bool check_compiled_frame(JavaThread* thread) { |
aoqi@0 | 134 | assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code"); |
aoqi@0 | 135 | RegisterMap map(thread, false); |
aoqi@0 | 136 | frame caller = thread->last_frame().sender(&map); |
aoqi@0 | 137 | assert(caller.is_compiled_frame(), "not being called from compiled like code"); |
aoqi@0 | 138 | return true; |
aoqi@0 | 139 | } |
aoqi@0 | 140 | #endif // ASSERT |
aoqi@0 | 141 | |
aoqi@0 | 142 | |
aoqi@0 | 143 | #define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, save_arg_regs, return_pc) \ |
aoqi@0 | 144 | var = generate_stub(env, type_func_gen, CAST_FROM_FN_PTR(address, c_func), #var, fancy_jump, pass_tls, save_arg_regs, return_pc); \ |
aoqi@0 | 145 | if (var == NULL) { return false; } |
aoqi@0 | 146 | |
aoqi@0 | 147 | bool OptoRuntime::generate(ciEnv* env) { |
aoqi@0 | 148 | |
aoqi@0 | 149 | generate_exception_blob(); |
aoqi@0 | 150 | |
aoqi@0 | 151 | // Note: tls: Means fetching the return oop out of the thread-local storage |
aoqi@0 | 152 | // |
aoqi@0 | 153 | // variable/name type-function-gen , runtime method ,fncy_jp, tls,save_args,retpc |
aoqi@0 | 154 | // ------------------------------------------------------------------------------------------------------------------------------- |
aoqi@0 | 155 | gen(env, _new_instance_Java , new_instance_Type , new_instance_C , 0 , true , false, false); |
aoqi@0 | 156 | gen(env, _new_array_Java , new_array_Type , new_array_C , 0 , true , false, false); |
aoqi@0 | 157 | gen(env, _new_array_nozero_Java , new_array_Type , new_array_nozero_C , 0 , true , false, false); |
aoqi@0 | 158 | gen(env, _multianewarray2_Java , multianewarray2_Type , multianewarray2_C , 0 , true , false, false); |
aoqi@0 | 159 | gen(env, _multianewarray3_Java , multianewarray3_Type , multianewarray3_C , 0 , true , false, false); |
aoqi@0 | 160 | gen(env, _multianewarray4_Java , multianewarray4_Type , multianewarray4_C , 0 , true , false, false); |
aoqi@0 | 161 | gen(env, _multianewarray5_Java , multianewarray5_Type , multianewarray5_C , 0 , true , false, false); |
aoqi@0 | 162 | gen(env, _multianewarrayN_Java , multianewarrayN_Type , multianewarrayN_C , 0 , true , false, false); |
aoqi@0 | 163 | gen(env, _g1_wb_pre_Java , g1_wb_pre_Type , SharedRuntime::g1_wb_pre , 0 , false, false, false); |
aoqi@0 | 164 | gen(env, _g1_wb_post_Java , g1_wb_post_Type , SharedRuntime::g1_wb_post , 0 , false, false, false); |
aoqi@0 | 165 | gen(env, _complete_monitor_locking_Java , complete_monitor_enter_Type , SharedRuntime::complete_monitor_locking_C, 0, false, false, false); |
aoqi@0 | 166 | gen(env, _rethrow_Java , rethrow_Type , rethrow_C , 2 , true , false, true ); |
aoqi@0 | 167 | |
aoqi@0 | 168 | gen(env, _slow_arraycopy_Java , slow_arraycopy_Type , SharedRuntime::slow_arraycopy_C , 0 , false, false, false); |
aoqi@0 | 169 | gen(env, _register_finalizer_Java , register_finalizer_Type , register_finalizer , 0 , false, false, false); |
aoqi@0 | 170 | |
aoqi@0 | 171 | # ifdef ENABLE_ZAP_DEAD_LOCALS |
aoqi@0 | 172 | gen(env, _zap_dead_Java_locals_Java , zap_dead_locals_Type , zap_dead_Java_locals_C , 0 , false, true , false ); |
aoqi@0 | 173 | gen(env, _zap_dead_native_locals_Java , zap_dead_locals_Type , zap_dead_native_locals_C , 0 , false, true , false ); |
aoqi@0 | 174 | # endif |
aoqi@0 | 175 | return true; |
aoqi@0 | 176 | } |
aoqi@0 | 177 | |
aoqi@0 | 178 | #undef gen |
aoqi@0 | 179 | |
aoqi@0 | 180 | |
aoqi@0 | 181 | // Helper method to do generation of RunTimeStub's |
aoqi@0 | 182 | address OptoRuntime::generate_stub( ciEnv* env, |
aoqi@0 | 183 | TypeFunc_generator gen, address C_function, |
aoqi@0 | 184 | const char *name, int is_fancy_jump, |
aoqi@0 | 185 | bool pass_tls, |
aoqi@0 | 186 | bool save_argument_registers, |
aoqi@0 | 187 | bool return_pc ) { |
aoqi@0 | 188 | ResourceMark rm; |
aoqi@0 | 189 | Compile C( env, gen, C_function, name, is_fancy_jump, pass_tls, save_argument_registers, return_pc ); |
aoqi@0 | 190 | return C.stub_entry_point(); |
aoqi@0 | 191 | } |
aoqi@0 | 192 | |
aoqi@0 | 193 | const char* OptoRuntime::stub_name(address entry) { |
aoqi@0 | 194 | #ifndef PRODUCT |
aoqi@0 | 195 | CodeBlob* cb = CodeCache::find_blob(entry); |
aoqi@0 | 196 | RuntimeStub* rs =(RuntimeStub *)cb; |
aoqi@0 | 197 | assert(rs != NULL && rs->is_runtime_stub(), "not a runtime stub"); |
aoqi@0 | 198 | return rs->name(); |
aoqi@0 | 199 | #else |
aoqi@0 | 200 | // Fast implementation for product mode (maybe it should be inlined too) |
aoqi@0 | 201 | return "runtime stub"; |
aoqi@0 | 202 | #endif |
aoqi@0 | 203 | } |
aoqi@0 | 204 | |
aoqi@0 | 205 | |
aoqi@0 | 206 | //============================================================================= |
aoqi@0 | 207 | // Opto compiler runtime routines |
aoqi@0 | 208 | //============================================================================= |
aoqi@0 | 209 | |
aoqi@0 | 210 | |
aoqi@0 | 211 | //=============================allocation====================================== |
aoqi@0 | 212 | // We failed the fast-path allocation. Now we need to do a scavenge or GC |
aoqi@0 | 213 | // and try allocation again. |
aoqi@0 | 214 | |
aoqi@0 | 215 | void OptoRuntime::new_store_pre_barrier(JavaThread* thread) { |
aoqi@0 | 216 | // After any safepoint, just before going back to compiled code, |
aoqi@0 | 217 | // we inform the GC that we will be doing initializing writes to |
aoqi@0 | 218 | // this object in the future without emitting card-marks, so |
aoqi@0 | 219 | // GC may take any compensating steps. |
aoqi@0 | 220 | // NOTE: Keep this code consistent with GraphKit::store_barrier. |
aoqi@0 | 221 | |
aoqi@0 | 222 | oop new_obj = thread->vm_result(); |
aoqi@0 | 223 | if (new_obj == NULL) return; |
aoqi@0 | 224 | |
aoqi@0 | 225 | assert(Universe::heap()->can_elide_tlab_store_barriers(), |
aoqi@0 | 226 | "compiler must check this first"); |
aoqi@0 | 227 | // GC may decide to give back a safer copy of new_obj. |
aoqi@0 | 228 | new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj); |
aoqi@0 | 229 | thread->set_vm_result(new_obj); |
aoqi@0 | 230 | } |
aoqi@0 | 231 | |
aoqi@0 | 232 | // object allocation |
aoqi@0 | 233 | JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, JavaThread* thread)) |
aoqi@0 | 234 | JRT_BLOCK; |
aoqi@0 | 235 | #ifndef PRODUCT |
aoqi@0 | 236 | SharedRuntime::_new_instance_ctr++; // new instance requires GC |
aoqi@0 | 237 | #endif |
aoqi@0 | 238 | assert(check_compiled_frame(thread), "incorrect caller"); |
aoqi@0 | 239 | |
aoqi@0 | 240 | // These checks are cheap to make and support reflective allocation. |
aoqi@0 | 241 | int lh = klass->layout_helper(); |
aoqi@0 | 242 | if (Klass::layout_helper_needs_slow_path(lh) |
aoqi@0 | 243 | || !InstanceKlass::cast(klass)->is_initialized()) { |
aoqi@0 | 244 | KlassHandle kh(THREAD, klass); |
aoqi@0 | 245 | kh->check_valid_for_instantiation(false, THREAD); |
aoqi@0 | 246 | if (!HAS_PENDING_EXCEPTION) { |
aoqi@0 | 247 | InstanceKlass::cast(kh())->initialize(THREAD); |
aoqi@0 | 248 | } |
aoqi@0 | 249 | if (!HAS_PENDING_EXCEPTION) { |
aoqi@0 | 250 | klass = kh(); |
aoqi@0 | 251 | } else { |
aoqi@0 | 252 | klass = NULL; |
aoqi@0 | 253 | } |
aoqi@0 | 254 | } |
aoqi@0 | 255 | |
aoqi@0 | 256 | if (klass != NULL) { |
aoqi@0 | 257 | // Scavenge and allocate an instance. |
aoqi@0 | 258 | oop result = InstanceKlass::cast(klass)->allocate_instance(THREAD); |
aoqi@0 | 259 | thread->set_vm_result(result); |
aoqi@0 | 260 | |
aoqi@0 | 261 | // Pass oops back through thread local storage. Our apparent type to Java |
aoqi@0 | 262 | // is that we return an oop, but we can block on exit from this routine and |
aoqi@0 | 263 | // a GC can trash the oop in C's return register. The generated stub will |
aoqi@0 | 264 | // fetch the oop from TLS after any possible GC. |
aoqi@0 | 265 | } |
aoqi@0 | 266 | |
aoqi@0 | 267 | deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); |
aoqi@0 | 268 | JRT_BLOCK_END; |
aoqi@0 | 269 | |
aoqi@0 | 270 | if (GraphKit::use_ReduceInitialCardMarks()) { |
aoqi@0 | 271 | // inform GC that we won't do card marks for initializing writes. |
aoqi@0 | 272 | new_store_pre_barrier(thread); |
aoqi@0 | 273 | } |
aoqi@0 | 274 | JRT_END |
aoqi@0 | 275 | |
aoqi@0 | 276 | |
aoqi@0 | 277 | // array allocation |
aoqi@0 | 278 | JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, JavaThread *thread)) |
aoqi@0 | 279 | JRT_BLOCK; |
aoqi@0 | 280 | #ifndef PRODUCT |
aoqi@0 | 281 | SharedRuntime::_new_array_ctr++; // new array requires GC |
aoqi@0 | 282 | #endif |
aoqi@0 | 283 | assert(check_compiled_frame(thread), "incorrect caller"); |
aoqi@0 | 284 | |
aoqi@0 | 285 | // Scavenge and allocate an instance. |
aoqi@0 | 286 | oop result; |
aoqi@0 | 287 | |
aoqi@0 | 288 | if (array_type->oop_is_typeArray()) { |
aoqi@0 | 289 | // The oopFactory likes to work with the element type. |
aoqi@0 | 290 | // (We could bypass the oopFactory, since it doesn't add much value.) |
aoqi@0 | 291 | BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type(); |
aoqi@0 | 292 | result = oopFactory::new_typeArray(elem_type, len, THREAD); |
aoqi@0 | 293 | } else { |
aoqi@0 | 294 | // Although the oopFactory likes to work with the elem_type, |
aoqi@0 | 295 | // the compiler prefers the array_type, since it must already have |
aoqi@0 | 296 | // that latter value in hand for the fast path. |
aoqi@0 | 297 | Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass(); |
aoqi@0 | 298 | result = oopFactory::new_objArray(elem_type, len, THREAD); |
aoqi@0 | 299 | } |
aoqi@0 | 300 | |
aoqi@0 | 301 | // Pass oops back through thread local storage. Our apparent type to Java |
aoqi@0 | 302 | // is that we return an oop, but we can block on exit from this routine and |
aoqi@0 | 303 | // a GC can trash the oop in C's return register. The generated stub will |
aoqi@0 | 304 | // fetch the oop from TLS after any possible GC. |
aoqi@0 | 305 | deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); |
aoqi@0 | 306 | thread->set_vm_result(result); |
aoqi@0 | 307 | JRT_BLOCK_END; |
aoqi@0 | 308 | |
aoqi@0 | 309 | if (GraphKit::use_ReduceInitialCardMarks()) { |
aoqi@0 | 310 | // inform GC that we won't do card marks for initializing writes. |
aoqi@0 | 311 | new_store_pre_barrier(thread); |
aoqi@0 | 312 | } |
aoqi@0 | 313 | JRT_END |
aoqi@0 | 314 | |
aoqi@0 | 315 | // array allocation without zeroing |
aoqi@0 | 316 | JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread *thread)) |
aoqi@0 | 317 | JRT_BLOCK; |
aoqi@0 | 318 | #ifndef PRODUCT |
aoqi@0 | 319 | SharedRuntime::_new_array_ctr++; // new array requires GC |
aoqi@0 | 320 | #endif |
aoqi@0 | 321 | assert(check_compiled_frame(thread), "incorrect caller"); |
aoqi@0 | 322 | |
aoqi@0 | 323 | // Scavenge and allocate an instance. |
aoqi@0 | 324 | oop result; |
aoqi@0 | 325 | |
aoqi@0 | 326 | assert(array_type->oop_is_typeArray(), "should be called only for type array"); |
aoqi@0 | 327 | // The oopFactory likes to work with the element type. |
aoqi@0 | 328 | BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type(); |
aoqi@0 | 329 | result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD); |
aoqi@0 | 330 | |
aoqi@0 | 331 | // Pass oops back through thread local storage. Our apparent type to Java |
aoqi@0 | 332 | // is that we return an oop, but we can block on exit from this routine and |
aoqi@0 | 333 | // a GC can trash the oop in C's return register. The generated stub will |
aoqi@0 | 334 | // fetch the oop from TLS after any possible GC. |
aoqi@0 | 335 | deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); |
aoqi@0 | 336 | thread->set_vm_result(result); |
aoqi@0 | 337 | JRT_BLOCK_END; |
aoqi@0 | 338 | |
aoqi@0 | 339 | if (GraphKit::use_ReduceInitialCardMarks()) { |
aoqi@0 | 340 | // inform GC that we won't do card marks for initializing writes. |
aoqi@0 | 341 | new_store_pre_barrier(thread); |
aoqi@0 | 342 | } |
aoqi@0 | 343 | |
aoqi@0 | 344 | oop result = thread->vm_result(); |
aoqi@0 | 345 | if ((len > 0) && (result != NULL) && |
aoqi@0 | 346 | is_deoptimized_caller_frame(thread)) { |
aoqi@0 | 347 | // Zero array here if the caller is deoptimized. |
aoqi@0 | 348 | int size = ((typeArrayOop)result)->object_size(); |
aoqi@0 | 349 | BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type(); |
aoqi@0 | 350 | const size_t hs = arrayOopDesc::header_size(elem_type); |
aoqi@0 | 351 | // Align to next 8 bytes to avoid trashing arrays's length. |
aoqi@0 | 352 | const size_t aligned_hs = align_object_offset(hs); |
aoqi@0 | 353 | HeapWord* obj = (HeapWord*)result; |
aoqi@0 | 354 | if (aligned_hs > hs) { |
aoqi@0 | 355 | Copy::zero_to_words(obj+hs, aligned_hs-hs); |
aoqi@0 | 356 | } |
aoqi@0 | 357 | // Optimized zeroing. |
aoqi@0 | 358 | Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs); |
aoqi@0 | 359 | } |
aoqi@0 | 360 | |
aoqi@0 | 361 | JRT_END |
aoqi@0 | 362 | |
aoqi@0 | 363 | // Note: multianewarray for one dimension is handled inline by GraphKit::new_array. |
aoqi@0 | 364 | |
aoqi@0 | 365 | // multianewarray for 2 dimensions |
aoqi@0 | 366 | JRT_ENTRY(void, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread *thread)) |
aoqi@0 | 367 | #ifndef PRODUCT |
aoqi@0 | 368 | SharedRuntime::_multi2_ctr++; // multianewarray for 1 dimension |
aoqi@0 | 369 | #endif |
aoqi@0 | 370 | assert(check_compiled_frame(thread), "incorrect caller"); |
aoqi@0 | 371 | assert(elem_type->is_klass(), "not a class"); |
aoqi@0 | 372 | jint dims[2]; |
aoqi@0 | 373 | dims[0] = len1; |
aoqi@0 | 374 | dims[1] = len2; |
aoqi@0 | 375 | oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD); |
aoqi@0 | 376 | deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); |
aoqi@0 | 377 | thread->set_vm_result(obj); |
aoqi@0 | 378 | JRT_END |
aoqi@0 | 379 | |
aoqi@0 | 380 | // multianewarray for 3 dimensions |
aoqi@0 | 381 | JRT_ENTRY(void, OptoRuntime::multianewarray3_C(Klass* elem_type, int len1, int len2, int len3, JavaThread *thread)) |
aoqi@0 | 382 | #ifndef PRODUCT |
aoqi@0 | 383 | SharedRuntime::_multi3_ctr++; // multianewarray for 1 dimension |
aoqi@0 | 384 | #endif |
aoqi@0 | 385 | assert(check_compiled_frame(thread), "incorrect caller"); |
aoqi@0 | 386 | assert(elem_type->is_klass(), "not a class"); |
aoqi@0 | 387 | jint dims[3]; |
aoqi@0 | 388 | dims[0] = len1; |
aoqi@0 | 389 | dims[1] = len2; |
aoqi@0 | 390 | dims[2] = len3; |
aoqi@0 | 391 | oop obj = ArrayKlass::cast(elem_type)->multi_allocate(3, dims, THREAD); |
aoqi@0 | 392 | deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); |
aoqi@0 | 393 | thread->set_vm_result(obj); |
aoqi@0 | 394 | JRT_END |
aoqi@0 | 395 | |
aoqi@0 | 396 | // multianewarray for 4 dimensions |
aoqi@0 | 397 | JRT_ENTRY(void, OptoRuntime::multianewarray4_C(Klass* elem_type, int len1, int len2, int len3, int len4, JavaThread *thread)) |
aoqi@0 | 398 | #ifndef PRODUCT |
aoqi@0 | 399 | SharedRuntime::_multi4_ctr++; // multianewarray for 1 dimension |
aoqi@0 | 400 | #endif |
aoqi@0 | 401 | assert(check_compiled_frame(thread), "incorrect caller"); |
aoqi@0 | 402 | assert(elem_type->is_klass(), "not a class"); |
aoqi@0 | 403 | jint dims[4]; |
aoqi@0 | 404 | dims[0] = len1; |
aoqi@0 | 405 | dims[1] = len2; |
aoqi@0 | 406 | dims[2] = len3; |
aoqi@0 | 407 | dims[3] = len4; |
aoqi@0 | 408 | oop obj = ArrayKlass::cast(elem_type)->multi_allocate(4, dims, THREAD); |
aoqi@0 | 409 | deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); |
aoqi@0 | 410 | thread->set_vm_result(obj); |
aoqi@0 | 411 | JRT_END |
aoqi@0 | 412 | |
aoqi@0 | 413 | // multianewarray for 5 dimensions |
aoqi@0 | 414 | JRT_ENTRY(void, OptoRuntime::multianewarray5_C(Klass* elem_type, int len1, int len2, int len3, int len4, int len5, JavaThread *thread)) |
aoqi@0 | 415 | #ifndef PRODUCT |
aoqi@0 | 416 | SharedRuntime::_multi5_ctr++; // multianewarray for 1 dimension |
aoqi@0 | 417 | #endif |
aoqi@0 | 418 | assert(check_compiled_frame(thread), "incorrect caller"); |
aoqi@0 | 419 | assert(elem_type->is_klass(), "not a class"); |
aoqi@0 | 420 | jint dims[5]; |
aoqi@0 | 421 | dims[0] = len1; |
aoqi@0 | 422 | dims[1] = len2; |
aoqi@0 | 423 | dims[2] = len3; |
aoqi@0 | 424 | dims[3] = len4; |
aoqi@0 | 425 | dims[4] = len5; |
aoqi@0 | 426 | oop obj = ArrayKlass::cast(elem_type)->multi_allocate(5, dims, THREAD); |
aoqi@0 | 427 | deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); |
aoqi@0 | 428 | thread->set_vm_result(obj); |
aoqi@0 | 429 | JRT_END |
aoqi@0 | 430 | |
aoqi@0 | 431 | JRT_ENTRY(void, OptoRuntime::multianewarrayN_C(Klass* elem_type, arrayOopDesc* dims, JavaThread *thread)) |
aoqi@0 | 432 | assert(check_compiled_frame(thread), "incorrect caller"); |
aoqi@0 | 433 | assert(elem_type->is_klass(), "not a class"); |
aoqi@0 | 434 | assert(oop(dims)->is_typeArray(), "not an array"); |
aoqi@0 | 435 | |
aoqi@0 | 436 | ResourceMark rm; |
aoqi@0 | 437 | jint len = dims->length(); |
aoqi@0 | 438 | assert(len > 0, "Dimensions array should contain data"); |
aoqi@0 | 439 | jint *j_dims = typeArrayOop(dims)->int_at_addr(0); |
aoqi@0 | 440 | jint *c_dims = NEW_RESOURCE_ARRAY(jint, len); |
aoqi@0 | 441 | Copy::conjoint_jints_atomic(j_dims, c_dims, len); |
aoqi@0 | 442 | |
aoqi@0 | 443 | oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD); |
aoqi@0 | 444 | deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); |
aoqi@0 | 445 | thread->set_vm_result(obj); |
aoqi@0 | 446 | JRT_END |
aoqi@0 | 447 | |
aoqi@0 | 448 | |
aoqi@0 | 449 | const TypeFunc *OptoRuntime::new_instance_Type() { |
aoqi@0 | 450 | // create input type (domain) |
aoqi@0 | 451 | const Type **fields = TypeTuple::fields(1); |
aoqi@0 | 452 | fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated |
aoqi@0 | 453 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 454 | |
aoqi@0 | 455 | // create result type (range) |
aoqi@0 | 456 | fields = TypeTuple::fields(1); |
aoqi@0 | 457 | fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop |
aoqi@0 | 458 | |
aoqi@0 | 459 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 460 | |
aoqi@0 | 461 | return TypeFunc::make(domain, range); |
aoqi@0 | 462 | } |
aoqi@0 | 463 | |
aoqi@0 | 464 | |
aoqi@0 | 465 | const TypeFunc *OptoRuntime::athrow_Type() { |
aoqi@0 | 466 | // create input type (domain) |
aoqi@0 | 467 | const Type **fields = TypeTuple::fields(1); |
aoqi@0 | 468 | fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated |
aoqi@0 | 469 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 470 | |
aoqi@0 | 471 | // create result type (range) |
aoqi@0 | 472 | fields = TypeTuple::fields(0); |
aoqi@0 | 473 | |
aoqi@0 | 474 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); |
aoqi@0 | 475 | |
aoqi@0 | 476 | return TypeFunc::make(domain, range); |
aoqi@0 | 477 | } |
aoqi@0 | 478 | |
aoqi@0 | 479 | |
aoqi@0 | 480 | const TypeFunc *OptoRuntime::new_array_Type() { |
aoqi@0 | 481 | // create input type (domain) |
aoqi@0 | 482 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 483 | fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass |
aoqi@0 | 484 | fields[TypeFunc::Parms+1] = TypeInt::INT; // array size |
aoqi@0 | 485 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); |
aoqi@0 | 486 | |
aoqi@0 | 487 | // create result type (range) |
aoqi@0 | 488 | fields = TypeTuple::fields(1); |
aoqi@0 | 489 | fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop |
aoqi@0 | 490 | |
aoqi@0 | 491 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 492 | |
aoqi@0 | 493 | return TypeFunc::make(domain, range); |
aoqi@0 | 494 | } |
aoqi@0 | 495 | |
aoqi@0 | 496 | const TypeFunc *OptoRuntime::multianewarray_Type(int ndim) { |
aoqi@0 | 497 | // create input type (domain) |
aoqi@0 | 498 | const int nargs = ndim + 1; |
aoqi@0 | 499 | const Type **fields = TypeTuple::fields(nargs); |
aoqi@0 | 500 | fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass |
aoqi@0 | 501 | for( int i = 1; i < nargs; i++ ) |
aoqi@0 | 502 | fields[TypeFunc::Parms + i] = TypeInt::INT; // array size |
aoqi@0 | 503 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+nargs, fields); |
aoqi@0 | 504 | |
aoqi@0 | 505 | // create result type (range) |
aoqi@0 | 506 | fields = TypeTuple::fields(1); |
aoqi@0 | 507 | fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop |
aoqi@0 | 508 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 509 | |
aoqi@0 | 510 | return TypeFunc::make(domain, range); |
aoqi@0 | 511 | } |
aoqi@0 | 512 | |
aoqi@0 | 513 | const TypeFunc *OptoRuntime::multianewarray2_Type() { |
aoqi@0 | 514 | return multianewarray_Type(2); |
aoqi@0 | 515 | } |
aoqi@0 | 516 | |
aoqi@0 | 517 | const TypeFunc *OptoRuntime::multianewarray3_Type() { |
aoqi@0 | 518 | return multianewarray_Type(3); |
aoqi@0 | 519 | } |
aoqi@0 | 520 | |
aoqi@0 | 521 | const TypeFunc *OptoRuntime::multianewarray4_Type() { |
aoqi@0 | 522 | return multianewarray_Type(4); |
aoqi@0 | 523 | } |
aoqi@0 | 524 | |
aoqi@0 | 525 | const TypeFunc *OptoRuntime::multianewarray5_Type() { |
aoqi@0 | 526 | return multianewarray_Type(5); |
aoqi@0 | 527 | } |
aoqi@0 | 528 | |
aoqi@0 | 529 | const TypeFunc *OptoRuntime::multianewarrayN_Type() { |
aoqi@0 | 530 | // create input type (domain) |
aoqi@0 | 531 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 532 | fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass |
aoqi@0 | 533 | fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // array of dim sizes |
aoqi@0 | 534 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); |
aoqi@0 | 535 | |
aoqi@0 | 536 | // create result type (range) |
aoqi@0 | 537 | fields = TypeTuple::fields(1); |
aoqi@0 | 538 | fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop |
aoqi@0 | 539 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 540 | |
aoqi@0 | 541 | return TypeFunc::make(domain, range); |
aoqi@0 | 542 | } |
aoqi@0 | 543 | |
aoqi@0 | 544 | const TypeFunc *OptoRuntime::g1_wb_pre_Type() { |
aoqi@0 | 545 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 546 | fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value |
aoqi@0 | 547 | fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread |
aoqi@0 | 548 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); |
aoqi@0 | 549 | |
aoqi@0 | 550 | // create result type (range) |
aoqi@0 | 551 | fields = TypeTuple::fields(0); |
aoqi@0 | 552 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); |
aoqi@0 | 553 | |
aoqi@0 | 554 | return TypeFunc::make(domain, range); |
aoqi@0 | 555 | } |
aoqi@0 | 556 | |
aoqi@0 | 557 | const TypeFunc *OptoRuntime::g1_wb_post_Type() { |
aoqi@0 | 558 | |
aoqi@0 | 559 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 560 | fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Card addr |
aoqi@0 | 561 | fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread |
aoqi@0 | 562 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); |
aoqi@0 | 563 | |
aoqi@0 | 564 | // create result type (range) |
aoqi@0 | 565 | fields = TypeTuple::fields(0); |
aoqi@0 | 566 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); |
aoqi@0 | 567 | |
aoqi@0 | 568 | return TypeFunc::make(domain, range); |
aoqi@0 | 569 | } |
aoqi@0 | 570 | |
aoqi@0 | 571 | const TypeFunc *OptoRuntime::uncommon_trap_Type() { |
aoqi@0 | 572 | // create input type (domain) |
aoqi@0 | 573 | const Type **fields = TypeTuple::fields(1); |
aoqi@0 | 574 | // Symbol* name of class to be loaded |
aoqi@0 | 575 | fields[TypeFunc::Parms+0] = TypeInt::INT; |
aoqi@0 | 576 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 577 | |
aoqi@0 | 578 | // create result type (range) |
aoqi@0 | 579 | fields = TypeTuple::fields(0); |
aoqi@0 | 580 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); |
aoqi@0 | 581 | |
aoqi@0 | 582 | return TypeFunc::make(domain, range); |
aoqi@0 | 583 | } |
aoqi@0 | 584 | |
aoqi@0 | 585 | # ifdef ENABLE_ZAP_DEAD_LOCALS |
aoqi@0 | 586 | // Type used for stub generation for zap_dead_locals. |
aoqi@0 | 587 | // No inputs or outputs |
aoqi@0 | 588 | const TypeFunc *OptoRuntime::zap_dead_locals_Type() { |
aoqi@0 | 589 | // create input type (domain) |
aoqi@0 | 590 | const Type **fields = TypeTuple::fields(0); |
aoqi@0 | 591 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms,fields); |
aoqi@0 | 592 | |
aoqi@0 | 593 | // create result type (range) |
aoqi@0 | 594 | fields = TypeTuple::fields(0); |
aoqi@0 | 595 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms,fields); |
aoqi@0 | 596 | |
aoqi@0 | 597 | return TypeFunc::make(domain,range); |
aoqi@0 | 598 | } |
aoqi@0 | 599 | # endif |
aoqi@0 | 600 | |
aoqi@0 | 601 | |
aoqi@0 | 602 | //----------------------------------------------------------------------------- |
aoqi@0 | 603 | // Monitor Handling |
aoqi@0 | 604 | const TypeFunc *OptoRuntime::complete_monitor_enter_Type() { |
aoqi@0 | 605 | // create input type (domain) |
aoqi@0 | 606 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 607 | fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked |
aoqi@0 | 608 | fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock |
aoqi@0 | 609 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); |
aoqi@0 | 610 | |
aoqi@0 | 611 | // create result type (range) |
aoqi@0 | 612 | fields = TypeTuple::fields(0); |
aoqi@0 | 613 | |
aoqi@0 | 614 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); |
aoqi@0 | 615 | |
aoqi@0 | 616 | return TypeFunc::make(domain,range); |
aoqi@0 | 617 | } |
aoqi@0 | 618 | |
aoqi@0 | 619 | |
aoqi@0 | 620 | //----------------------------------------------------------------------------- |
aoqi@0 | 621 | const TypeFunc *OptoRuntime::complete_monitor_exit_Type() { |
aoqi@0 | 622 | // create input type (domain) |
aoqi@0 | 623 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 624 | fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked |
aoqi@0 | 625 | fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock |
aoqi@0 | 626 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); |
aoqi@0 | 627 | |
aoqi@0 | 628 | // create result type (range) |
aoqi@0 | 629 | fields = TypeTuple::fields(0); |
aoqi@0 | 630 | |
aoqi@0 | 631 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); |
aoqi@0 | 632 | |
aoqi@0 | 633 | return TypeFunc::make(domain,range); |
aoqi@0 | 634 | } |
aoqi@0 | 635 | |
aoqi@0 | 636 | const TypeFunc* OptoRuntime::flush_windows_Type() { |
aoqi@0 | 637 | // create input type (domain) |
aoqi@0 | 638 | const Type** fields = TypeTuple::fields(1); |
aoqi@0 | 639 | fields[TypeFunc::Parms+0] = NULL; // void |
aoqi@0 | 640 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields); |
aoqi@0 | 641 | |
aoqi@0 | 642 | // create result type |
aoqi@0 | 643 | fields = TypeTuple::fields(1); |
aoqi@0 | 644 | fields[TypeFunc::Parms+0] = NULL; // void |
aoqi@0 | 645 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); |
aoqi@0 | 646 | |
aoqi@0 | 647 | return TypeFunc::make(domain, range); |
aoqi@0 | 648 | } |
aoqi@0 | 649 | |
aoqi@0 | 650 | const TypeFunc* OptoRuntime::l2f_Type() { |
aoqi@0 | 651 | // create input type (domain) |
aoqi@0 | 652 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 653 | fields[TypeFunc::Parms+0] = TypeLong::LONG; |
aoqi@0 | 654 | fields[TypeFunc::Parms+1] = Type::HALF; |
aoqi@0 | 655 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); |
aoqi@0 | 656 | |
aoqi@0 | 657 | // create result type (range) |
aoqi@0 | 658 | fields = TypeTuple::fields(1); |
aoqi@0 | 659 | fields[TypeFunc::Parms+0] = Type::FLOAT; |
aoqi@0 | 660 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 661 | |
aoqi@0 | 662 | return TypeFunc::make(domain, range); |
aoqi@0 | 663 | } |
aoqi@0 | 664 | |
aoqi@0 | 665 | const TypeFunc* OptoRuntime::modf_Type() { |
aoqi@0 | 666 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 667 | fields[TypeFunc::Parms+0] = Type::FLOAT; |
aoqi@0 | 668 | fields[TypeFunc::Parms+1] = Type::FLOAT; |
aoqi@0 | 669 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); |
aoqi@0 | 670 | |
aoqi@0 | 671 | // create result type (range) |
aoqi@0 | 672 | fields = TypeTuple::fields(1); |
aoqi@0 | 673 | fields[TypeFunc::Parms+0] = Type::FLOAT; |
aoqi@0 | 674 | |
aoqi@0 | 675 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 676 | |
aoqi@0 | 677 | return TypeFunc::make(domain, range); |
aoqi@0 | 678 | } |
aoqi@0 | 679 | |
aoqi@0 | 680 | const TypeFunc *OptoRuntime::Math_D_D_Type() { |
aoqi@0 | 681 | // create input type (domain) |
aoqi@0 | 682 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 683 | // Symbol* name of class to be loaded |
aoqi@0 | 684 | fields[TypeFunc::Parms+0] = Type::DOUBLE; |
aoqi@0 | 685 | fields[TypeFunc::Parms+1] = Type::HALF; |
aoqi@0 | 686 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); |
aoqi@0 | 687 | |
aoqi@0 | 688 | // create result type (range) |
aoqi@0 | 689 | fields = TypeTuple::fields(2); |
aoqi@0 | 690 | fields[TypeFunc::Parms+0] = Type::DOUBLE; |
aoqi@0 | 691 | fields[TypeFunc::Parms+1] = Type::HALF; |
aoqi@0 | 692 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields); |
aoqi@0 | 693 | |
aoqi@0 | 694 | return TypeFunc::make(domain, range); |
aoqi@0 | 695 | } |
aoqi@0 | 696 | |
aoqi@0 | 697 | const TypeFunc* OptoRuntime::Math_DD_D_Type() { |
aoqi@0 | 698 | const Type **fields = TypeTuple::fields(4); |
aoqi@0 | 699 | fields[TypeFunc::Parms+0] = Type::DOUBLE; |
aoqi@0 | 700 | fields[TypeFunc::Parms+1] = Type::HALF; |
aoqi@0 | 701 | fields[TypeFunc::Parms+2] = Type::DOUBLE; |
aoqi@0 | 702 | fields[TypeFunc::Parms+3] = Type::HALF; |
aoqi@0 | 703 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+4, fields); |
aoqi@0 | 704 | |
aoqi@0 | 705 | // create result type (range) |
aoqi@0 | 706 | fields = TypeTuple::fields(2); |
aoqi@0 | 707 | fields[TypeFunc::Parms+0] = Type::DOUBLE; |
aoqi@0 | 708 | fields[TypeFunc::Parms+1] = Type::HALF; |
aoqi@0 | 709 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields); |
aoqi@0 | 710 | |
aoqi@0 | 711 | return TypeFunc::make(domain, range); |
aoqi@0 | 712 | } |
aoqi@0 | 713 | |
aoqi@0 | 714 | //-------------- currentTimeMillis, currentTimeNanos, etc |
aoqi@0 | 715 | |
aoqi@0 | 716 | const TypeFunc* OptoRuntime::void_long_Type() { |
aoqi@0 | 717 | // create input type (domain) |
aoqi@0 | 718 | const Type **fields = TypeTuple::fields(0); |
aoqi@0 | 719 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields); |
aoqi@0 | 720 | |
aoqi@0 | 721 | // create result type (range) |
aoqi@0 | 722 | fields = TypeTuple::fields(2); |
aoqi@0 | 723 | fields[TypeFunc::Parms+0] = TypeLong::LONG; |
aoqi@0 | 724 | fields[TypeFunc::Parms+1] = Type::HALF; |
aoqi@0 | 725 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields); |
aoqi@0 | 726 | |
aoqi@0 | 727 | return TypeFunc::make(domain, range); |
aoqi@0 | 728 | } |
aoqi@0 | 729 | |
aoqi@0 | 730 | // arraycopy stub variations: |
aoqi@0 | 731 | enum ArrayCopyType { |
aoqi@0 | 732 | ac_fast, // void(ptr, ptr, size_t) |
aoqi@0 | 733 | ac_checkcast, // int(ptr, ptr, size_t, size_t, ptr) |
aoqi@0 | 734 | ac_slow, // void(ptr, int, ptr, int, int) |
aoqi@0 | 735 | ac_generic // int(ptr, int, ptr, int, int) |
aoqi@0 | 736 | }; |
aoqi@0 | 737 | |
aoqi@0 | 738 | static const TypeFunc* make_arraycopy_Type(ArrayCopyType act) { |
aoqi@0 | 739 | // create input type (domain) |
aoqi@0 | 740 | int num_args = (act == ac_fast ? 3 : 5); |
aoqi@0 | 741 | int num_size_args = (act == ac_fast ? 1 : act == ac_checkcast ? 2 : 0); |
aoqi@0 | 742 | int argcnt = num_args; |
aoqi@0 | 743 | LP64_ONLY(argcnt += num_size_args); // halfwords for lengths |
aoqi@0 | 744 | const Type** fields = TypeTuple::fields(argcnt); |
aoqi@0 | 745 | int argp = TypeFunc::Parms; |
aoqi@0 | 746 | fields[argp++] = TypePtr::NOTNULL; // src |
aoqi@0 | 747 | if (num_size_args == 0) { |
aoqi@0 | 748 | fields[argp++] = TypeInt::INT; // src_pos |
aoqi@0 | 749 | } |
aoqi@0 | 750 | fields[argp++] = TypePtr::NOTNULL; // dest |
aoqi@0 | 751 | if (num_size_args == 0) { |
aoqi@0 | 752 | fields[argp++] = TypeInt::INT; // dest_pos |
aoqi@0 | 753 | fields[argp++] = TypeInt::INT; // length |
aoqi@0 | 754 | } |
aoqi@0 | 755 | while (num_size_args-- > 0) { |
aoqi@0 | 756 | fields[argp++] = TypeX_X; // size in whatevers (size_t) |
aoqi@0 | 757 | LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length |
aoqi@0 | 758 | } |
aoqi@0 | 759 | if (act == ac_checkcast) { |
aoqi@0 | 760 | fields[argp++] = TypePtr::NOTNULL; // super_klass |
aoqi@0 | 761 | } |
aoqi@0 | 762 | assert(argp == TypeFunc::Parms+argcnt, "correct decoding of act"); |
aoqi@0 | 763 | const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); |
aoqi@0 | 764 | |
aoqi@0 | 765 | // create result type if needed |
aoqi@0 | 766 | int retcnt = (act == ac_checkcast || act == ac_generic ? 1 : 0); |
aoqi@0 | 767 | fields = TypeTuple::fields(1); |
aoqi@0 | 768 | if (retcnt == 0) |
aoqi@0 | 769 | fields[TypeFunc::Parms+0] = NULL; // void |
aoqi@0 | 770 | else |
aoqi@0 | 771 | fields[TypeFunc::Parms+0] = TypeInt::INT; // status result, if needed |
aoqi@0 | 772 | const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+retcnt, fields); |
aoqi@0 | 773 | return TypeFunc::make(domain, range); |
aoqi@0 | 774 | } |
aoqi@0 | 775 | |
aoqi@0 | 776 | const TypeFunc* OptoRuntime::fast_arraycopy_Type() { |
aoqi@0 | 777 | // This signature is simple: Two base pointers and a size_t. |
aoqi@0 | 778 | return make_arraycopy_Type(ac_fast); |
aoqi@0 | 779 | } |
aoqi@0 | 780 | |
aoqi@0 | 781 | const TypeFunc* OptoRuntime::checkcast_arraycopy_Type() { |
aoqi@0 | 782 | // An extension of fast_arraycopy_Type which adds type checking. |
aoqi@0 | 783 | return make_arraycopy_Type(ac_checkcast); |
aoqi@0 | 784 | } |
aoqi@0 | 785 | |
aoqi@0 | 786 | const TypeFunc* OptoRuntime::slow_arraycopy_Type() { |
aoqi@0 | 787 | // This signature is exactly the same as System.arraycopy. |
aoqi@0 | 788 | // There are no intptr_t (int/long) arguments. |
aoqi@0 | 789 | return make_arraycopy_Type(ac_slow); |
aoqi@0 | 790 | } |
aoqi@0 | 791 | |
aoqi@0 | 792 | const TypeFunc* OptoRuntime::generic_arraycopy_Type() { |
aoqi@0 | 793 | // This signature is like System.arraycopy, except that it returns status. |
aoqi@0 | 794 | return make_arraycopy_Type(ac_generic); |
aoqi@0 | 795 | } |
aoqi@0 | 796 | |
aoqi@0 | 797 | |
aoqi@0 | 798 | const TypeFunc* OptoRuntime::array_fill_Type() { |
aoqi@0 | 799 | const Type** fields; |
aoqi@0 | 800 | int argp = TypeFunc::Parms; |
aoqi@0 | 801 | if (CCallingConventionRequiresIntsAsLongs) { |
aoqi@0 | 802 | // create input type (domain): pointer, int, size_t |
aoqi@0 | 803 | fields = TypeTuple::fields(3 LP64_ONLY( + 2)); |
aoqi@0 | 804 | fields[argp++] = TypePtr::NOTNULL; |
aoqi@0 | 805 | fields[argp++] = TypeLong::LONG; |
aoqi@0 | 806 | fields[argp++] = Type::HALF; |
aoqi@0 | 807 | } else { |
aoqi@0 | 808 | // create input type (domain): pointer, int, size_t |
aoqi@0 | 809 | fields = TypeTuple::fields(3 LP64_ONLY( + 1)); |
aoqi@0 | 810 | fields[argp++] = TypePtr::NOTNULL; |
aoqi@0 | 811 | fields[argp++] = TypeInt::INT; |
aoqi@0 | 812 | } |
aoqi@0 | 813 | fields[argp++] = TypeX_X; // size in whatevers (size_t) |
aoqi@0 | 814 | LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length |
aoqi@0 | 815 | const TypeTuple *domain = TypeTuple::make(argp, fields); |
aoqi@0 | 816 | |
aoqi@0 | 817 | // create result type |
aoqi@0 | 818 | fields = TypeTuple::fields(1); |
aoqi@0 | 819 | fields[TypeFunc::Parms+0] = NULL; // void |
aoqi@0 | 820 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); |
aoqi@0 | 821 | |
aoqi@0 | 822 | return TypeFunc::make(domain, range); |
aoqi@0 | 823 | } |
aoqi@0 | 824 | |
aoqi@0 | 825 | // for aescrypt encrypt/decrypt operations, just three pointers returning void (length is constant) |
aoqi@0 | 826 | const TypeFunc* OptoRuntime::aescrypt_block_Type() { |
aoqi@0 | 827 | // create input type (domain) |
aoqi@0 | 828 | int num_args = 3; |
aoqi@0 | 829 | if (Matcher::pass_original_key_for_aes()) { |
aoqi@0 | 830 | num_args = 4; |
aoqi@0 | 831 | } |
aoqi@0 | 832 | int argcnt = num_args; |
aoqi@0 | 833 | const Type** fields = TypeTuple::fields(argcnt); |
aoqi@0 | 834 | int argp = TypeFunc::Parms; |
aoqi@0 | 835 | fields[argp++] = TypePtr::NOTNULL; // src |
aoqi@0 | 836 | fields[argp++] = TypePtr::NOTNULL; // dest |
aoqi@0 | 837 | fields[argp++] = TypePtr::NOTNULL; // k array |
aoqi@0 | 838 | if (Matcher::pass_original_key_for_aes()) { |
aoqi@0 | 839 | fields[argp++] = TypePtr::NOTNULL; // original k array |
aoqi@0 | 840 | } |
aoqi@0 | 841 | assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); |
aoqi@0 | 842 | const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); |
aoqi@0 | 843 | |
aoqi@0 | 844 | // no result type needed |
aoqi@0 | 845 | fields = TypeTuple::fields(1); |
aoqi@0 | 846 | fields[TypeFunc::Parms+0] = NULL; // void |
aoqi@0 | 847 | const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); |
aoqi@0 | 848 | return TypeFunc::make(domain, range); |
aoqi@0 | 849 | } |
aoqi@0 | 850 | |
aoqi@0 | 851 | /** |
aoqi@0 | 852 | * int updateBytesCRC32(int crc, byte* b, int len) |
aoqi@0 | 853 | */ |
aoqi@0 | 854 | const TypeFunc* OptoRuntime::updateBytesCRC32_Type() { |
aoqi@0 | 855 | // create input type (domain) |
aoqi@0 | 856 | int num_args = 3; |
aoqi@0 | 857 | int argcnt = num_args; |
aoqi@0 | 858 | const Type** fields = TypeTuple::fields(argcnt); |
aoqi@0 | 859 | int argp = TypeFunc::Parms; |
aoqi@0 | 860 | fields[argp++] = TypeInt::INT; // crc |
aoqi@0 | 861 | fields[argp++] = TypePtr::NOTNULL; // src |
aoqi@0 | 862 | fields[argp++] = TypeInt::INT; // len |
aoqi@0 | 863 | assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); |
aoqi@0 | 864 | const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); |
aoqi@0 | 865 | |
aoqi@0 | 866 | // result type needed |
aoqi@0 | 867 | fields = TypeTuple::fields(1); |
aoqi@0 | 868 | fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result |
aoqi@0 | 869 | const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 870 | return TypeFunc::make(domain, range); |
aoqi@0 | 871 | } |
aoqi@0 | 872 | |
aoqi@0 | 873 | // for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int |
aoqi@0 | 874 | const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() { |
aoqi@0 | 875 | // create input type (domain) |
aoqi@0 | 876 | int num_args = 5; |
aoqi@0 | 877 | if (Matcher::pass_original_key_for_aes()) { |
aoqi@0 | 878 | num_args = 6; |
aoqi@0 | 879 | } |
aoqi@0 | 880 | int argcnt = num_args; |
aoqi@0 | 881 | const Type** fields = TypeTuple::fields(argcnt); |
aoqi@0 | 882 | int argp = TypeFunc::Parms; |
aoqi@0 | 883 | fields[argp++] = TypePtr::NOTNULL; // src |
aoqi@0 | 884 | fields[argp++] = TypePtr::NOTNULL; // dest |
aoqi@0 | 885 | fields[argp++] = TypePtr::NOTNULL; // k array |
aoqi@0 | 886 | fields[argp++] = TypePtr::NOTNULL; // r array |
aoqi@0 | 887 | fields[argp++] = TypeInt::INT; // src len |
aoqi@0 | 888 | if (Matcher::pass_original_key_for_aes()) { |
aoqi@0 | 889 | fields[argp++] = TypePtr::NOTNULL; // original k array |
aoqi@0 | 890 | } |
aoqi@0 | 891 | assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); |
aoqi@0 | 892 | const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); |
aoqi@0 | 893 | |
aoqi@0 | 894 | // returning cipher len (int) |
aoqi@0 | 895 | fields = TypeTuple::fields(1); |
aoqi@0 | 896 | fields[TypeFunc::Parms+0] = TypeInt::INT; |
aoqi@0 | 897 | const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 898 | return TypeFunc::make(domain, range); |
aoqi@0 | 899 | } |
aoqi@0 | 900 | |
kvn@7027 | 901 | /* |
kvn@7027 | 902 | * void implCompress(byte[] buf, int ofs) |
kvn@7027 | 903 | */ |
kvn@7027 | 904 | const TypeFunc* OptoRuntime::sha_implCompress_Type() { |
kvn@7027 | 905 | // create input type (domain) |
kvn@7027 | 906 | int num_args = 2; |
kvn@7027 | 907 | int argcnt = num_args; |
kvn@7027 | 908 | const Type** fields = TypeTuple::fields(argcnt); |
kvn@7027 | 909 | int argp = TypeFunc::Parms; |
kvn@7027 | 910 | fields[argp++] = TypePtr::NOTNULL; // buf |
kvn@7027 | 911 | fields[argp++] = TypePtr::NOTNULL; // state |
kvn@7027 | 912 | assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); |
kvn@7027 | 913 | const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); |
kvn@7027 | 914 | |
kvn@7027 | 915 | // no result type needed |
kvn@7027 | 916 | fields = TypeTuple::fields(1); |
kvn@7027 | 917 | fields[TypeFunc::Parms+0] = NULL; // void |
kvn@7027 | 918 | const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); |
kvn@7027 | 919 | return TypeFunc::make(domain, range); |
kvn@7027 | 920 | } |
kvn@7027 | 921 | |
kvn@7027 | 922 | /* |
kvn@7027 | 923 | * int implCompressMultiBlock(byte[] b, int ofs, int limit) |
kvn@7027 | 924 | */ |
kvn@7027 | 925 | const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type() { |
kvn@7027 | 926 | // create input type (domain) |
kvn@7027 | 927 | int num_args = 4; |
kvn@7027 | 928 | int argcnt = num_args; |
kvn@7027 | 929 | const Type** fields = TypeTuple::fields(argcnt); |
kvn@7027 | 930 | int argp = TypeFunc::Parms; |
kvn@7027 | 931 | fields[argp++] = TypePtr::NOTNULL; // buf |
kvn@7027 | 932 | fields[argp++] = TypePtr::NOTNULL; // state |
kvn@7027 | 933 | fields[argp++] = TypeInt::INT; // ofs |
kvn@7027 | 934 | fields[argp++] = TypeInt::INT; // limit |
kvn@7027 | 935 | assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); |
kvn@7027 | 936 | const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); |
kvn@7027 | 937 | |
kvn@7027 | 938 | // returning ofs (int) |
kvn@7027 | 939 | fields = TypeTuple::fields(1); |
kvn@7027 | 940 | fields[TypeFunc::Parms+0] = TypeInt::INT; // ofs |
kvn@7027 | 941 | const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); |
kvn@7027 | 942 | return TypeFunc::make(domain, range); |
kvn@7027 | 943 | } |
kvn@7027 | 944 | |
kvn@7152 | 945 | const TypeFunc* OptoRuntime::multiplyToLen_Type() { |
kvn@7152 | 946 | // create input type (domain) |
kvn@7152 | 947 | int num_args = 6; |
kvn@7152 | 948 | int argcnt = num_args; |
kvn@7152 | 949 | const Type** fields = TypeTuple::fields(argcnt); |
kvn@7152 | 950 | int argp = TypeFunc::Parms; |
kvn@7152 | 951 | fields[argp++] = TypePtr::NOTNULL; // x |
kvn@7152 | 952 | fields[argp++] = TypeInt::INT; // xlen |
kvn@7152 | 953 | fields[argp++] = TypePtr::NOTNULL; // y |
kvn@7152 | 954 | fields[argp++] = TypeInt::INT; // ylen |
kvn@7152 | 955 | fields[argp++] = TypePtr::NOTNULL; // z |
kvn@7152 | 956 | fields[argp++] = TypeInt::INT; // zlen |
kvn@7152 | 957 | assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); |
kvn@7152 | 958 | const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); |
kvn@7152 | 959 | |
kvn@7152 | 960 | // no result type needed |
kvn@7152 | 961 | fields = TypeTuple::fields(1); |
kvn@7152 | 962 | fields[TypeFunc::Parms+0] = NULL; |
kvn@7152 | 963 | const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); |
kvn@7152 | 964 | return TypeFunc::make(domain, range); |
kvn@7152 | 965 | } |
kvn@7152 | 966 | |
kvn@7152 | 967 | |
kvn@7152 | 968 | |
aoqi@0 | 969 | //------------- Interpreter state access for on stack replacement |
aoqi@0 | 970 | const TypeFunc* OptoRuntime::osr_end_Type() { |
aoqi@0 | 971 | // create input type (domain) |
aoqi@0 | 972 | const Type **fields = TypeTuple::fields(1); |
aoqi@0 | 973 | fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // OSR temp buf |
aoqi@0 | 974 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 975 | |
aoqi@0 | 976 | // create result type |
aoqi@0 | 977 | fields = TypeTuple::fields(1); |
aoqi@0 | 978 | // fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // locked oop |
aoqi@0 | 979 | fields[TypeFunc::Parms+0] = NULL; // void |
aoqi@0 | 980 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); |
aoqi@0 | 981 | return TypeFunc::make(domain, range); |
aoqi@0 | 982 | } |
aoqi@0 | 983 | |
aoqi@0 | 984 | //-------------- methodData update helpers |
aoqi@0 | 985 | |
aoqi@0 | 986 | const TypeFunc* OptoRuntime::profile_receiver_type_Type() { |
aoqi@0 | 987 | // create input type (domain) |
aoqi@0 | 988 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 989 | fields[TypeFunc::Parms+0] = TypeAryPtr::NOTNULL; // methodData pointer |
aoqi@0 | 990 | fields[TypeFunc::Parms+1] = TypeInstPtr::BOTTOM; // receiver oop |
aoqi@0 | 991 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); |
aoqi@0 | 992 | |
aoqi@0 | 993 | // create result type |
aoqi@0 | 994 | fields = TypeTuple::fields(1); |
aoqi@0 | 995 | fields[TypeFunc::Parms+0] = NULL; // void |
aoqi@0 | 996 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); |
aoqi@0 | 997 | return TypeFunc::make(domain,range); |
aoqi@0 | 998 | } |
aoqi@0 | 999 | |
aoqi@0 | 1000 | JRT_LEAF(void, OptoRuntime::profile_receiver_type_C(DataLayout* data, oopDesc* receiver)) |
aoqi@0 | 1001 | if (receiver == NULL) return; |
aoqi@0 | 1002 | Klass* receiver_klass = receiver->klass(); |
aoqi@0 | 1003 | |
aoqi@0 | 1004 | intptr_t* mdp = ((intptr_t*)(data)) + DataLayout::header_size_in_cells(); |
aoqi@0 | 1005 | int empty_row = -1; // free row, if any is encountered |
aoqi@0 | 1006 | |
aoqi@0 | 1007 | // ReceiverTypeData* vc = new ReceiverTypeData(mdp); |
aoqi@0 | 1008 | for (uint row = 0; row < ReceiverTypeData::row_limit(); row++) { |
aoqi@0 | 1009 | // if (vc->receiver(row) == receiver_klass) |
aoqi@0 | 1010 | int receiver_off = ReceiverTypeData::receiver_cell_index(row); |
aoqi@0 | 1011 | intptr_t row_recv = *(mdp + receiver_off); |
aoqi@0 | 1012 | if (row_recv == (intptr_t) receiver_klass) { |
aoqi@0 | 1013 | // vc->set_receiver_count(row, vc->receiver_count(row) + DataLayout::counter_increment); |
aoqi@0 | 1014 | int count_off = ReceiverTypeData::receiver_count_cell_index(row); |
aoqi@0 | 1015 | *(mdp + count_off) += DataLayout::counter_increment; |
aoqi@0 | 1016 | return; |
aoqi@0 | 1017 | } else if (row_recv == 0) { |
aoqi@0 | 1018 | // else if (vc->receiver(row) == NULL) |
aoqi@0 | 1019 | empty_row = (int) row; |
aoqi@0 | 1020 | } |
aoqi@0 | 1021 | } |
aoqi@0 | 1022 | |
aoqi@0 | 1023 | if (empty_row != -1) { |
aoqi@0 | 1024 | int receiver_off = ReceiverTypeData::receiver_cell_index(empty_row); |
aoqi@0 | 1025 | // vc->set_receiver(empty_row, receiver_klass); |
aoqi@0 | 1026 | *(mdp + receiver_off) = (intptr_t) receiver_klass; |
aoqi@0 | 1027 | // vc->set_receiver_count(empty_row, DataLayout::counter_increment); |
aoqi@0 | 1028 | int count_off = ReceiverTypeData::receiver_count_cell_index(empty_row); |
aoqi@0 | 1029 | *(mdp + count_off) = DataLayout::counter_increment; |
aoqi@0 | 1030 | } else { |
aoqi@0 | 1031 | // Receiver did not match any saved receiver and there is no empty row for it. |
aoqi@0 | 1032 | // Increment total counter to indicate polymorphic case. |
aoqi@0 | 1033 | intptr_t* count_p = (intptr_t*)(((byte*)(data)) + in_bytes(CounterData::count_offset())); |
aoqi@0 | 1034 | *count_p += DataLayout::counter_increment; |
aoqi@0 | 1035 | } |
aoqi@0 | 1036 | JRT_END |
aoqi@0 | 1037 | |
aoqi@0 | 1038 | //------------------------------------------------------------------------------------- |
aoqi@0 | 1039 | // register policy |
aoqi@0 | 1040 | |
aoqi@0 | 1041 | bool OptoRuntime::is_callee_saved_register(MachRegisterNumbers reg) { |
aoqi@0 | 1042 | assert(reg >= 0 && reg < _last_Mach_Reg, "must be a machine register"); |
aoqi@0 | 1043 | switch (register_save_policy[reg]) { |
aoqi@0 | 1044 | case 'C': return false; //SOC |
aoqi@0 | 1045 | case 'E': return true ; //SOE |
aoqi@0 | 1046 | case 'N': return false; //NS |
aoqi@0 | 1047 | case 'A': return false; //AS |
aoqi@0 | 1048 | } |
aoqi@0 | 1049 | ShouldNotReachHere(); |
aoqi@0 | 1050 | return false; |
aoqi@0 | 1051 | } |
aoqi@0 | 1052 | |
aoqi@0 | 1053 | //----------------------------------------------------------------------- |
aoqi@0 | 1054 | // Exceptions |
aoqi@0 | 1055 | // |
aoqi@0 | 1056 | |
aoqi@0 | 1057 | static void trace_exception(oop exception_oop, address exception_pc, const char* msg) PRODUCT_RETURN; |
aoqi@0 | 1058 | |
aoqi@0 | 1059 | // The method is an entry that is always called by a C++ method not |
aoqi@0 | 1060 | // directly from compiled code. Compiled code will call the C++ method following. |
aoqi@0 | 1061 | // We can't allow async exception to be installed during exception processing. |
aoqi@0 | 1062 | JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* thread, nmethod* &nm)) |
aoqi@0 | 1063 | |
aoqi@0 | 1064 | // Do not confuse exception_oop with pending_exception. The exception_oop |
aoqi@0 | 1065 | // is only used to pass arguments into the method. Not for general |
aoqi@0 | 1066 | // exception handling. DO NOT CHANGE IT to use pending_exception, since |
aoqi@0 | 1067 | // the runtime stubs checks this on exit. |
aoqi@0 | 1068 | assert(thread->exception_oop() != NULL, "exception oop is found"); |
aoqi@0 | 1069 | address handler_address = NULL; |
aoqi@0 | 1070 | |
aoqi@0 | 1071 | Handle exception(thread, thread->exception_oop()); |
aoqi@0 | 1072 | address pc = thread->exception_pc(); |
aoqi@0 | 1073 | |
aoqi@0 | 1074 | // Clear out the exception oop and pc since looking up an |
aoqi@0 | 1075 | // exception handler can cause class loading, which might throw an |
aoqi@0 | 1076 | // exception and those fields are expected to be clear during |
aoqi@0 | 1077 | // normal bytecode execution. |
aoqi@0 | 1078 | thread->clear_exception_oop_and_pc(); |
aoqi@0 | 1079 | |
aoqi@0 | 1080 | if (TraceExceptions) { |
aoqi@0 | 1081 | trace_exception(exception(), pc, ""); |
aoqi@0 | 1082 | } |
aoqi@0 | 1083 | |
aoqi@0 | 1084 | // for AbortVMOnException flag |
aoqi@0 | 1085 | NOT_PRODUCT(Exceptions::debug_check_abort(exception)); |
aoqi@0 | 1086 | |
aoqi@0 | 1087 | #ifdef ASSERT |
aoqi@0 | 1088 | if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { |
aoqi@0 | 1089 | // should throw an exception here |
aoqi@0 | 1090 | ShouldNotReachHere(); |
aoqi@0 | 1091 | } |
aoqi@0 | 1092 | #endif |
aoqi@0 | 1093 | |
aoqi@0 | 1094 | // new exception handling: this method is entered only from adapters |
aoqi@0 | 1095 | // exceptions from compiled java methods are handled in compiled code |
aoqi@0 | 1096 | // using rethrow node |
aoqi@0 | 1097 | |
aoqi@0 | 1098 | nm = CodeCache::find_nmethod(pc); |
aoqi@0 | 1099 | assert(nm != NULL, "No NMethod found"); |
aoqi@0 | 1100 | if (nm->is_native_method()) { |
aoqi@0 | 1101 | fatal("Native method should not have path to exception handling"); |
aoqi@0 | 1102 | } else { |
aoqi@0 | 1103 | // we are switching to old paradigm: search for exception handler in caller_frame |
aoqi@0 | 1104 | // instead in exception handler of caller_frame.sender() |
aoqi@0 | 1105 | |
aoqi@0 | 1106 | if (JvmtiExport::can_post_on_exceptions()) { |
aoqi@0 | 1107 | // "Full-speed catching" is not necessary here, |
aoqi@0 | 1108 | // since we're notifying the VM on every catch. |
aoqi@0 | 1109 | // Force deoptimization and the rest of the lookup |
aoqi@0 | 1110 | // will be fine. |
aoqi@0 | 1111 | deoptimize_caller_frame(thread); |
aoqi@0 | 1112 | } |
aoqi@0 | 1113 | |
aoqi@0 | 1114 | // Check the stack guard pages. If enabled, look for handler in this frame; |
aoqi@0 | 1115 | // otherwise, forcibly unwind the frame. |
aoqi@0 | 1116 | // |
aoqi@0 | 1117 | // 4826555: use default current sp for reguard_stack instead of &nm: it's more accurate. |
aoqi@0 | 1118 | bool force_unwind = !thread->reguard_stack(); |
aoqi@0 | 1119 | bool deopting = false; |
aoqi@0 | 1120 | if (nm->is_deopt_pc(pc)) { |
aoqi@0 | 1121 | deopting = true; |
aoqi@0 | 1122 | RegisterMap map(thread, false); |
aoqi@0 | 1123 | frame deoptee = thread->last_frame().sender(&map); |
aoqi@0 | 1124 | assert(deoptee.is_deoptimized_frame(), "must be deopted"); |
aoqi@0 | 1125 | // Adjust the pc back to the original throwing pc |
aoqi@0 | 1126 | pc = deoptee.pc(); |
aoqi@0 | 1127 | } |
aoqi@0 | 1128 | |
aoqi@0 | 1129 | // If we are forcing an unwind because of stack overflow then deopt is |
aoqi@0 | 1130 | // irrelevant since we are throwing the frame away anyway. |
aoqi@0 | 1131 | |
aoqi@0 | 1132 | if (deopting && !force_unwind) { |
aoqi@0 | 1133 | handler_address = SharedRuntime::deopt_blob()->unpack_with_exception(); |
aoqi@0 | 1134 | } else { |
aoqi@0 | 1135 | |
aoqi@0 | 1136 | handler_address = |
aoqi@0 | 1137 | force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc); |
aoqi@0 | 1138 | |
aoqi@0 | 1139 | if (handler_address == NULL) { |
aoqi@0 | 1140 | Handle original_exception(thread, exception()); |
aoqi@0 | 1141 | handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true); |
aoqi@0 | 1142 | assert (handler_address != NULL, "must have compiled handler"); |
aoqi@0 | 1143 | // Update the exception cache only when the unwind was not forced |
aoqi@0 | 1144 | // and there didn't happen another exception during the computation of the |
aoqi@0 | 1145 | // compiled exception handler. |
aoqi@0 | 1146 | if (!force_unwind && original_exception() == exception()) { |
aoqi@0 | 1147 | nm->add_handler_for_exception_and_pc(exception,pc,handler_address); |
aoqi@0 | 1148 | } |
aoqi@0 | 1149 | } else { |
aoqi@0 | 1150 | assert(handler_address == SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true), "Must be the same"); |
aoqi@0 | 1151 | } |
aoqi@0 | 1152 | } |
aoqi@0 | 1153 | |
aoqi@0 | 1154 | thread->set_exception_pc(pc); |
aoqi@0 | 1155 | thread->set_exception_handler_pc(handler_address); |
aoqi@0 | 1156 | |
aoqi@0 | 1157 | // Check if the exception PC is a MethodHandle call site. |
aoqi@0 | 1158 | thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); |
aoqi@0 | 1159 | } |
aoqi@0 | 1160 | |
aoqi@0 | 1161 | // Restore correct return pc. Was saved above. |
aoqi@0 | 1162 | thread->set_exception_oop(exception()); |
aoqi@0 | 1163 | return handler_address; |
aoqi@0 | 1164 | |
aoqi@0 | 1165 | JRT_END |
aoqi@0 | 1166 | |
aoqi@0 | 1167 | // We are entering here from exception_blob |
aoqi@0 | 1168 | // If there is a compiled exception handler in this method, we will continue there; |
aoqi@0 | 1169 | // otherwise we will unwind the stack and continue at the caller of top frame method |
aoqi@0 | 1170 | // Note we enter without the usual JRT wrapper. We will call a helper routine that |
aoqi@0 | 1171 | // will do the normal VM entry. We do it this way so that we can see if the nmethod |
aoqi@0 | 1172 | // we looked up the handler for has been deoptimized in the meantime. If it has been |
aoqi@0 | 1173 | // we must not use the handler and instead return the deopt blob. |
aoqi@0 | 1174 | address OptoRuntime::handle_exception_C(JavaThread* thread) { |
aoqi@0 | 1175 | // |
aoqi@0 | 1176 | // We are in Java not VM and in debug mode we have a NoHandleMark |
aoqi@0 | 1177 | // |
aoqi@0 | 1178 | #ifndef PRODUCT |
aoqi@0 | 1179 | SharedRuntime::_find_handler_ctr++; // find exception handler |
aoqi@0 | 1180 | #endif |
aoqi@0 | 1181 | debug_only(NoHandleMark __hm;) |
aoqi@0 | 1182 | nmethod* nm = NULL; |
aoqi@0 | 1183 | address handler_address = NULL; |
aoqi@0 | 1184 | { |
aoqi@0 | 1185 | // Enter the VM |
aoqi@0 | 1186 | |
aoqi@0 | 1187 | ResetNoHandleMark rnhm; |
aoqi@0 | 1188 | handler_address = handle_exception_C_helper(thread, nm); |
aoqi@0 | 1189 | } |
aoqi@0 | 1190 | |
aoqi@0 | 1191 | // Back in java: Use no oops, DON'T safepoint |
aoqi@0 | 1192 | |
aoqi@0 | 1193 | // Now check to see if the handler we are returning is in a now |
aoqi@0 | 1194 | // deoptimized frame |
aoqi@0 | 1195 | |
aoqi@0 | 1196 | if (nm != NULL) { |
aoqi@0 | 1197 | RegisterMap map(thread, false); |
aoqi@0 | 1198 | frame caller = thread->last_frame().sender(&map); |
aoqi@0 | 1199 | #ifdef ASSERT |
aoqi@0 | 1200 | assert(caller.is_compiled_frame(), "must be"); |
aoqi@0 | 1201 | #endif // ASSERT |
aoqi@0 | 1202 | if (caller.is_deoptimized_frame()) { |
aoqi@0 | 1203 | handler_address = SharedRuntime::deopt_blob()->unpack_with_exception(); |
aoqi@0 | 1204 | } |
aoqi@0 | 1205 | } |
aoqi@0 | 1206 | return handler_address; |
aoqi@0 | 1207 | } |
aoqi@0 | 1208 | |
aoqi@0 | 1209 | //------------------------------rethrow---------------------------------------- |
aoqi@0 | 1210 | // We get here after compiled code has executed a 'RethrowNode'. The callee |
aoqi@0 | 1211 | // is either throwing or rethrowing an exception. The callee-save registers |
aoqi@0 | 1212 | // have been restored, synchronized objects have been unlocked and the callee |
aoqi@0 | 1213 | // stack frame has been removed. The return address was passed in. |
aoqi@0 | 1214 | // Exception oop is passed as the 1st argument. This routine is then called |
aoqi@0 | 1215 | // from the stub. On exit, we know where to jump in the caller's code. |
aoqi@0 | 1216 | // After this C code exits, the stub will pop his frame and end in a jump |
aoqi@0 | 1217 | // (instead of a return). We enter the caller's default handler. |
aoqi@0 | 1218 | // |
aoqi@0 | 1219 | // This must be JRT_LEAF: |
aoqi@0 | 1220 | // - caller will not change its state as we cannot block on exit, |
aoqi@0 | 1221 | // therefore raw_exception_handler_for_return_address is all it takes |
aoqi@0 | 1222 | // to handle deoptimized blobs |
aoqi@0 | 1223 | // |
aoqi@0 | 1224 | // However, there needs to be a safepoint check in the middle! So compiled |
aoqi@0 | 1225 | // safepoints are completely watertight. |
aoqi@0 | 1226 | // |
aoqi@0 | 1227 | // Thus, it cannot be a leaf since it contains the No_GC_Verifier. |
aoqi@0 | 1228 | // |
aoqi@0 | 1229 | // *THIS IS NOT RECOMMENDED PROGRAMMING STYLE* |
aoqi@0 | 1230 | // |
aoqi@0 | 1231 | address OptoRuntime::rethrow_C(oopDesc* exception, JavaThread* thread, address ret_pc) { |
aoqi@0 | 1232 | #ifndef PRODUCT |
aoqi@0 | 1233 | SharedRuntime::_rethrow_ctr++; // count rethrows |
aoqi@0 | 1234 | #endif |
aoqi@0 | 1235 | assert (exception != NULL, "should have thrown a NULLPointerException"); |
aoqi@0 | 1236 | #ifdef ASSERT |
aoqi@0 | 1237 | if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { |
aoqi@0 | 1238 | // should throw an exception here |
aoqi@0 | 1239 | ShouldNotReachHere(); |
aoqi@0 | 1240 | } |
aoqi@0 | 1241 | #endif |
aoqi@0 | 1242 | |
aoqi@0 | 1243 | thread->set_vm_result(exception); |
aoqi@0 | 1244 | // Frame not compiled (handles deoptimization blob) |
aoqi@0 | 1245 | return SharedRuntime::raw_exception_handler_for_return_address(thread, ret_pc); |
aoqi@0 | 1246 | } |
aoqi@0 | 1247 | |
aoqi@0 | 1248 | |
aoqi@0 | 1249 | const TypeFunc *OptoRuntime::rethrow_Type() { |
aoqi@0 | 1250 | // create input type (domain) |
aoqi@0 | 1251 | const Type **fields = TypeTuple::fields(1); |
aoqi@0 | 1252 | fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop |
aoqi@0 | 1253 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields); |
aoqi@0 | 1254 | |
aoqi@0 | 1255 | // create result type (range) |
aoqi@0 | 1256 | fields = TypeTuple::fields(1); |
aoqi@0 | 1257 | fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop |
aoqi@0 | 1258 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); |
aoqi@0 | 1259 | |
aoqi@0 | 1260 | return TypeFunc::make(domain, range); |
aoqi@0 | 1261 | } |
aoqi@0 | 1262 | |
aoqi@0 | 1263 | |
aoqi@0 | 1264 | void OptoRuntime::deoptimize_caller_frame(JavaThread *thread, bool doit) { |
aoqi@0 | 1265 | // Deoptimize the caller before continuing, as the compiled |
aoqi@0 | 1266 | // exception handler table may not be valid. |
aoqi@0 | 1267 | if (!StressCompiledExceptionHandlers && doit) { |
aoqi@0 | 1268 | deoptimize_caller_frame(thread); |
aoqi@0 | 1269 | } |
aoqi@0 | 1270 | } |
aoqi@0 | 1271 | |
aoqi@0 | 1272 | void OptoRuntime::deoptimize_caller_frame(JavaThread *thread) { |
aoqi@0 | 1273 | // Called from within the owner thread, so no need for safepoint |
aoqi@0 | 1274 | RegisterMap reg_map(thread); |
aoqi@0 | 1275 | frame stub_frame = thread->last_frame(); |
aoqi@0 | 1276 | assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check"); |
aoqi@0 | 1277 | frame caller_frame = stub_frame.sender(®_map); |
aoqi@0 | 1278 | |
aoqi@0 | 1279 | // Deoptimize the caller frame. |
aoqi@0 | 1280 | Deoptimization::deoptimize_frame(thread, caller_frame.id()); |
aoqi@0 | 1281 | } |
aoqi@0 | 1282 | |
aoqi@0 | 1283 | |
aoqi@0 | 1284 | bool OptoRuntime::is_deoptimized_caller_frame(JavaThread *thread) { |
aoqi@0 | 1285 | // Called from within the owner thread, so no need for safepoint |
aoqi@0 | 1286 | RegisterMap reg_map(thread); |
aoqi@0 | 1287 | frame stub_frame = thread->last_frame(); |
aoqi@0 | 1288 | assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check"); |
aoqi@0 | 1289 | frame caller_frame = stub_frame.sender(®_map); |
aoqi@0 | 1290 | return caller_frame.is_deoptimized_frame(); |
aoqi@0 | 1291 | } |
aoqi@0 | 1292 | |
aoqi@0 | 1293 | |
aoqi@0 | 1294 | const TypeFunc *OptoRuntime::register_finalizer_Type() { |
aoqi@0 | 1295 | // create input type (domain) |
aoqi@0 | 1296 | const Type **fields = TypeTuple::fields(1); |
aoqi@0 | 1297 | fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // oop; Receiver |
aoqi@0 | 1298 | // // The JavaThread* is passed to each routine as the last argument |
aoqi@0 | 1299 | // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // JavaThread *; Executing thread |
aoqi@0 | 1300 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields); |
aoqi@0 | 1301 | |
aoqi@0 | 1302 | // create result type (range) |
aoqi@0 | 1303 | fields = TypeTuple::fields(0); |
aoqi@0 | 1304 | |
aoqi@0 | 1305 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); |
aoqi@0 | 1306 | |
aoqi@0 | 1307 | return TypeFunc::make(domain,range); |
aoqi@0 | 1308 | } |
aoqi@0 | 1309 | |
aoqi@0 | 1310 | |
aoqi@0 | 1311 | //----------------------------------------------------------------------------- |
aoqi@0 | 1312 | // Dtrace support. entry and exit probes have the same signature |
aoqi@0 | 1313 | const TypeFunc *OptoRuntime::dtrace_method_entry_exit_Type() { |
aoqi@0 | 1314 | // create input type (domain) |
aoqi@0 | 1315 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 1316 | fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage |
aoqi@0 | 1317 | fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM; // Method*; Method we are entering |
aoqi@0 | 1318 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); |
aoqi@0 | 1319 | |
aoqi@0 | 1320 | // create result type (range) |
aoqi@0 | 1321 | fields = TypeTuple::fields(0); |
aoqi@0 | 1322 | |
aoqi@0 | 1323 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); |
aoqi@0 | 1324 | |
aoqi@0 | 1325 | return TypeFunc::make(domain,range); |
aoqi@0 | 1326 | } |
aoqi@0 | 1327 | |
aoqi@0 | 1328 | const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() { |
aoqi@0 | 1329 | // create input type (domain) |
aoqi@0 | 1330 | const Type **fields = TypeTuple::fields(2); |
aoqi@0 | 1331 | fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage |
aoqi@0 | 1332 | fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // oop; newly allocated object |
aoqi@0 | 1333 | |
aoqi@0 | 1334 | const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); |
aoqi@0 | 1335 | |
aoqi@0 | 1336 | // create result type (range) |
aoqi@0 | 1337 | fields = TypeTuple::fields(0); |
aoqi@0 | 1338 | |
aoqi@0 | 1339 | const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); |
aoqi@0 | 1340 | |
aoqi@0 | 1341 | return TypeFunc::make(domain,range); |
aoqi@0 | 1342 | } |
aoqi@0 | 1343 | |
aoqi@0 | 1344 | |
aoqi@0 | 1345 | JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer(oopDesc* obj, JavaThread* thread)) |
aoqi@0 | 1346 | assert(obj->is_oop(), "must be a valid oop"); |
aoqi@0 | 1347 | assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise"); |
aoqi@0 | 1348 | InstanceKlass::register_finalizer(instanceOop(obj), CHECK); |
aoqi@0 | 1349 | JRT_END |
aoqi@0 | 1350 | |
aoqi@0 | 1351 | //----------------------------------------------------------------------------- |
aoqi@0 | 1352 | |
aoqi@0 | 1353 | NamedCounter * volatile OptoRuntime::_named_counters = NULL; |
aoqi@0 | 1354 | |
aoqi@0 | 1355 | // |
aoqi@0 | 1356 | // dump the collected NamedCounters. |
aoqi@0 | 1357 | // |
aoqi@0 | 1358 | void OptoRuntime::print_named_counters() { |
aoqi@0 | 1359 | int total_lock_count = 0; |
aoqi@0 | 1360 | int eliminated_lock_count = 0; |
aoqi@0 | 1361 | |
aoqi@0 | 1362 | NamedCounter* c = _named_counters; |
aoqi@0 | 1363 | while (c) { |
aoqi@0 | 1364 | if (c->tag() == NamedCounter::LockCounter || c->tag() == NamedCounter::EliminatedLockCounter) { |
aoqi@0 | 1365 | int count = c->count(); |
aoqi@0 | 1366 | if (count > 0) { |
aoqi@0 | 1367 | bool eliminated = c->tag() == NamedCounter::EliminatedLockCounter; |
aoqi@0 | 1368 | if (Verbose) { |
aoqi@0 | 1369 | tty->print_cr("%d %s%s", count, c->name(), eliminated ? " (eliminated)" : ""); |
aoqi@0 | 1370 | } |
aoqi@0 | 1371 | total_lock_count += count; |
aoqi@0 | 1372 | if (eliminated) { |
aoqi@0 | 1373 | eliminated_lock_count += count; |
aoqi@0 | 1374 | } |
aoqi@0 | 1375 | } |
aoqi@0 | 1376 | } else if (c->tag() == NamedCounter::BiasedLockingCounter) { |
aoqi@0 | 1377 | BiasedLockingCounters* blc = ((BiasedLockingNamedCounter*)c)->counters(); |
aoqi@0 | 1378 | if (blc->nonzero()) { |
aoqi@0 | 1379 | tty->print_cr("%s", c->name()); |
aoqi@0 | 1380 | blc->print_on(tty); |
aoqi@0 | 1381 | } |
aoqi@0 | 1382 | #if INCLUDE_RTM_OPT |
aoqi@0 | 1383 | } else if (c->tag() == NamedCounter::RTMLockingCounter) { |
aoqi@0 | 1384 | RTMLockingCounters* rlc = ((RTMLockingNamedCounter*)c)->counters(); |
aoqi@0 | 1385 | if (rlc->nonzero()) { |
aoqi@0 | 1386 | tty->print_cr("%s", c->name()); |
aoqi@0 | 1387 | rlc->print_on(tty); |
aoqi@0 | 1388 | } |
aoqi@0 | 1389 | #endif |
aoqi@0 | 1390 | } |
aoqi@0 | 1391 | c = c->next(); |
aoqi@0 | 1392 | } |
aoqi@0 | 1393 | if (total_lock_count > 0) { |
aoqi@0 | 1394 | tty->print_cr("dynamic locks: %d", total_lock_count); |
aoqi@0 | 1395 | if (eliminated_lock_count) { |
aoqi@0 | 1396 | tty->print_cr("eliminated locks: %d (%d%%)", eliminated_lock_count, |
aoqi@0 | 1397 | (int)(eliminated_lock_count * 100.0 / total_lock_count)); |
aoqi@0 | 1398 | } |
aoqi@0 | 1399 | } |
aoqi@0 | 1400 | } |
aoqi@0 | 1401 | |
aoqi@0 | 1402 | // |
aoqi@0 | 1403 | // Allocate a new NamedCounter. The JVMState is used to generate the |
aoqi@0 | 1404 | // name which consists of method@line for the inlining tree. |
aoqi@0 | 1405 | // |
aoqi@0 | 1406 | |
aoqi@0 | 1407 | NamedCounter* OptoRuntime::new_named_counter(JVMState* youngest_jvms, NamedCounter::CounterTag tag) { |
aoqi@0 | 1408 | int max_depth = youngest_jvms->depth(); |
aoqi@0 | 1409 | |
aoqi@0 | 1410 | // Visit scopes from youngest to oldest. |
aoqi@0 | 1411 | bool first = true; |
aoqi@0 | 1412 | stringStream st; |
aoqi@0 | 1413 | for (int depth = max_depth; depth >= 1; depth--) { |
aoqi@0 | 1414 | JVMState* jvms = youngest_jvms->of_depth(depth); |
aoqi@0 | 1415 | ciMethod* m = jvms->has_method() ? jvms->method() : NULL; |
aoqi@0 | 1416 | if (!first) { |
aoqi@0 | 1417 | st.print(" "); |
aoqi@0 | 1418 | } else { |
aoqi@0 | 1419 | first = false; |
aoqi@0 | 1420 | } |
aoqi@0 | 1421 | int bci = jvms->bci(); |
aoqi@0 | 1422 | if (bci < 0) bci = 0; |
aoqi@0 | 1423 | st.print("%s.%s@%d", m->holder()->name()->as_utf8(), m->name()->as_utf8(), bci); |
aoqi@0 | 1424 | // To print linenumbers instead of bci use: m->line_number_from_bci(bci) |
aoqi@0 | 1425 | } |
aoqi@0 | 1426 | NamedCounter* c; |
aoqi@0 | 1427 | if (tag == NamedCounter::BiasedLockingCounter) { |
aoqi@0 | 1428 | c = new BiasedLockingNamedCounter(strdup(st.as_string())); |
aoqi@0 | 1429 | } else if (tag == NamedCounter::RTMLockingCounter) { |
aoqi@0 | 1430 | c = new RTMLockingNamedCounter(strdup(st.as_string())); |
aoqi@0 | 1431 | } else { |
aoqi@0 | 1432 | c = new NamedCounter(strdup(st.as_string()), tag); |
aoqi@0 | 1433 | } |
aoqi@0 | 1434 | |
aoqi@0 | 1435 | // atomically add the new counter to the head of the list. We only |
aoqi@0 | 1436 | // add counters so this is safe. |
aoqi@0 | 1437 | NamedCounter* head; |
aoqi@0 | 1438 | do { |
aoqi@0 | 1439 | c->set_next(NULL); |
aoqi@0 | 1440 | head = _named_counters; |
aoqi@0 | 1441 | c->set_next(head); |
aoqi@0 | 1442 | } while (Atomic::cmpxchg_ptr(c, &_named_counters, head) != head); |
aoqi@0 | 1443 | return c; |
aoqi@0 | 1444 | } |
aoqi@0 | 1445 | |
aoqi@0 | 1446 | //----------------------------------------------------------------------------- |
aoqi@0 | 1447 | // Non-product code |
aoqi@0 | 1448 | #ifndef PRODUCT |
aoqi@0 | 1449 | |
aoqi@0 | 1450 | int trace_exception_counter = 0; |
aoqi@0 | 1451 | static void trace_exception(oop exception_oop, address exception_pc, const char* msg) { |
aoqi@0 | 1452 | ttyLocker ttyl; |
aoqi@0 | 1453 | trace_exception_counter++; |
aoqi@0 | 1454 | tty->print("%d [Exception (%s): ", trace_exception_counter, msg); |
aoqi@0 | 1455 | exception_oop->print_value(); |
aoqi@0 | 1456 | tty->print(" in "); |
aoqi@0 | 1457 | CodeBlob* blob = CodeCache::find_blob(exception_pc); |
aoqi@0 | 1458 | if (blob->is_nmethod()) { |
aoqi@0 | 1459 | nmethod* nm = blob->as_nmethod_or_null(); |
aoqi@0 | 1460 | nm->method()->print_value(); |
aoqi@0 | 1461 | } else if (blob->is_runtime_stub()) { |
aoqi@0 | 1462 | tty->print("<runtime-stub>"); |
aoqi@0 | 1463 | } else { |
aoqi@0 | 1464 | tty->print("<unknown>"); |
aoqi@0 | 1465 | } |
aoqi@0 | 1466 | tty->print(" at " INTPTR_FORMAT, p2i(exception_pc)); |
aoqi@0 | 1467 | tty->print_cr("]"); |
aoqi@0 | 1468 | } |
aoqi@0 | 1469 | |
aoqi@0 | 1470 | #endif // PRODUCT |
aoqi@0 | 1471 | |
aoqi@0 | 1472 | |
aoqi@0 | 1473 | # ifdef ENABLE_ZAP_DEAD_LOCALS |
aoqi@0 | 1474 | // Called from call sites in compiled code with oop maps (actually safepoints) |
aoqi@0 | 1475 | // Zaps dead locals in first java frame. |
aoqi@0 | 1476 | // Is entry because may need to lock to generate oop maps |
aoqi@0 | 1477 | // Currently, only used for compiler frames, but someday may be used |
aoqi@0 | 1478 | // for interpreter frames, too. |
aoqi@0 | 1479 | |
aoqi@0 | 1480 | int OptoRuntime::ZapDeadCompiledLocals_count = 0; |
aoqi@0 | 1481 | |
aoqi@0 | 1482 | // avoid pointers to member funcs with these helpers |
aoqi@0 | 1483 | static bool is_java_frame( frame* f) { return f->is_java_frame(); } |
aoqi@0 | 1484 | static bool is_native_frame(frame* f) { return f->is_native_frame(); } |
aoqi@0 | 1485 | |
aoqi@0 | 1486 | |
aoqi@0 | 1487 | void OptoRuntime::zap_dead_java_or_native_locals(JavaThread* thread, |
aoqi@0 | 1488 | bool (*is_this_the_right_frame_to_zap)(frame*)) { |
aoqi@0 | 1489 | assert(JavaThread::current() == thread, "is this needed?"); |
aoqi@0 | 1490 | |
aoqi@0 | 1491 | if ( !ZapDeadCompiledLocals ) return; |
aoqi@0 | 1492 | |
aoqi@0 | 1493 | bool skip = false; |
aoqi@0 | 1494 | |
aoqi@0 | 1495 | if ( ZapDeadCompiledLocalsFirst == 0 ) ; // nothing special |
aoqi@0 | 1496 | else if ( ZapDeadCompiledLocalsFirst > ZapDeadCompiledLocals_count ) skip = true; |
aoqi@0 | 1497 | else if ( ZapDeadCompiledLocalsFirst == ZapDeadCompiledLocals_count ) |
aoqi@0 | 1498 | warning("starting zapping after skipping"); |
aoqi@0 | 1499 | |
aoqi@0 | 1500 | if ( ZapDeadCompiledLocalsLast == -1 ) ; // nothing special |
aoqi@0 | 1501 | else if ( ZapDeadCompiledLocalsLast < ZapDeadCompiledLocals_count ) skip = true; |
aoqi@0 | 1502 | else if ( ZapDeadCompiledLocalsLast == ZapDeadCompiledLocals_count ) |
aoqi@0 | 1503 | warning("about to zap last zap"); |
aoqi@0 | 1504 | |
aoqi@0 | 1505 | ++ZapDeadCompiledLocals_count; // counts skipped zaps, too |
aoqi@0 | 1506 | |
aoqi@0 | 1507 | if ( skip ) return; |
aoqi@0 | 1508 | |
aoqi@0 | 1509 | // find java frame and zap it |
aoqi@0 | 1510 | |
aoqi@0 | 1511 | for (StackFrameStream sfs(thread); !sfs.is_done(); sfs.next()) { |
aoqi@0 | 1512 | if (is_this_the_right_frame_to_zap(sfs.current()) ) { |
aoqi@0 | 1513 | sfs.current()->zap_dead_locals(thread, sfs.register_map()); |
aoqi@0 | 1514 | return; |
aoqi@0 | 1515 | } |
aoqi@0 | 1516 | } |
aoqi@0 | 1517 | warning("no frame found to zap in zap_dead_Java_locals_C"); |
aoqi@0 | 1518 | } |
aoqi@0 | 1519 | |
aoqi@0 | 1520 | JRT_LEAF(void, OptoRuntime::zap_dead_Java_locals_C(JavaThread* thread)) |
aoqi@0 | 1521 | zap_dead_java_or_native_locals(thread, is_java_frame); |
aoqi@0 | 1522 | JRT_END |
aoqi@0 | 1523 | |
aoqi@0 | 1524 | // The following does not work because for one thing, the |
aoqi@0 | 1525 | // thread state is wrong; it expects java, but it is native. |
aoqi@0 | 1526 | // Also, the invariants in a native stub are different and |
aoqi@0 | 1527 | // I'm not sure it is safe to have a MachCalRuntimeDirectNode |
aoqi@0 | 1528 | // in there. |
aoqi@0 | 1529 | // So for now, we do not zap in native stubs. |
aoqi@0 | 1530 | |
aoqi@0 | 1531 | JRT_LEAF(void, OptoRuntime::zap_dead_native_locals_C(JavaThread* thread)) |
aoqi@0 | 1532 | zap_dead_java_or_native_locals(thread, is_native_frame); |
aoqi@0 | 1533 | JRT_END |
aoqi@0 | 1534 | |
aoqi@0 | 1535 | # endif |