src/share/vm/opto/runtime.cpp

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 10026
8c95980d0b66
parent 9806
758c07667682
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f

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

mercurial