src/share/vm/opto/runtime.hpp

Fri, 11 Jul 2014 19:51:36 -0400

author
drchase
date
Fri, 11 Jul 2014 19:51:36 -0400
changeset 7161
fc2c88ea11a9
parent 7027
b20a35eae442
child 7152
166d744df0de
permissions
-rw-r--r--

8036588: VerifyFieldClosure fails instanceKlass:3133
Summary: Changed deopt live-pointer test to use returns-object instead of live-and-returns-object
Reviewed-by: iveresov, kvn, jrose

duke@435 1 /*
kvn@7027 2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_OPTO_RUNTIME_HPP
stefank@2314 26 #define SHARE_VM_OPTO_RUNTIME_HPP
stefank@2314 27
stefank@2314 28 #include "code/codeBlob.hpp"
stefank@2314 29 #include "opto/machnode.hpp"
stefank@2314 30 #include "opto/type.hpp"
stefank@2314 31 #include "runtime/biasedLocking.hpp"
kvn@6429 32 #include "runtime/rtmLocking.hpp"
stefank@2314 33 #include "runtime/deoptimization.hpp"
stefank@2314 34 #include "runtime/vframe.hpp"
stefank@2314 35
duke@435 36 //------------------------------OptoRuntime------------------------------------
duke@435 37 // Opto compiler runtime routines
duke@435 38 //
duke@435 39 // These are all generated from Ideal graphs. They are called with the
duke@435 40 // Java calling convention. Internally they call C++. They are made once at
duke@435 41 // startup time and Opto compiles calls to them later.
duke@435 42 // Things are broken up into quads: the signature they will be called with,
duke@435 43 // the address of the generated code, the corresponding C++ code and an
duke@435 44 // nmethod.
duke@435 45
duke@435 46 // The signature (returned by "xxx_Type()") is used at startup time by the
duke@435 47 // Generator to make the generated code "xxx_Java". Opto compiles calls
duke@435 48 // to the generated code "xxx_Java". When the compiled code gets executed,
duke@435 49 // it calls the C++ code "xxx_C". The generated nmethod is saved in the
duke@435 50 // CodeCache. Exception handlers use the nmethod to get the callee-save
duke@435 51 // register OopMaps.
duke@435 52 class CallInfo;
duke@435 53
duke@435 54 //
duke@435 55 // NamedCounters are tagged counters which can be used for profiling
duke@435 56 // code in various ways. Currently they are used by the lock coarsening code
duke@435 57 //
duke@435 58
zgu@3900 59 class NamedCounter : public CHeapObj<mtCompiler> {
duke@435 60 public:
duke@435 61 enum CounterTag {
duke@435 62 NoTag,
duke@435 63 LockCounter,
duke@435 64 EliminatedLockCounter,
kvn@6429 65 BiasedLockingCounter,
kvn@6429 66 RTMLockingCounter
duke@435 67 };
duke@435 68
duke@435 69 private:
duke@435 70 const char * _name;
duke@435 71 int _count;
duke@435 72 CounterTag _tag;
duke@435 73 NamedCounter* _next;
duke@435 74
duke@435 75 public:
duke@435 76 NamedCounter(const char *n, CounterTag tag = NoTag):
duke@435 77 _name(n),
duke@435 78 _count(0),
duke@435 79 _next(NULL),
duke@435 80 _tag(tag) {}
duke@435 81
duke@435 82 const char * name() const { return _name; }
duke@435 83 int count() const { return _count; }
duke@435 84 address addr() { return (address)&_count; }
duke@435 85 CounterTag tag() const { return _tag; }
duke@435 86 void set_tag(CounterTag tag) { _tag = tag; }
duke@435 87
duke@435 88 NamedCounter* next() const { return _next; }
duke@435 89 void set_next(NamedCounter* next) {
kvn@6429 90 assert(_next == NULL || next == NULL, "already set");
duke@435 91 _next = next;
duke@435 92 }
duke@435 93
duke@435 94 };
duke@435 95
duke@435 96 class BiasedLockingNamedCounter : public NamedCounter {
duke@435 97 private:
duke@435 98 BiasedLockingCounters _counters;
duke@435 99
duke@435 100 public:
duke@435 101 BiasedLockingNamedCounter(const char *n) :
duke@435 102 NamedCounter(n, BiasedLockingCounter), _counters() {}
duke@435 103
duke@435 104 BiasedLockingCounters* counters() { return &_counters; }
duke@435 105 };
duke@435 106
kvn@6429 107
kvn@6429 108 class RTMLockingNamedCounter : public NamedCounter {
kvn@6429 109 private:
kvn@6429 110 RTMLockingCounters _counters;
kvn@6429 111
kvn@6429 112 public:
kvn@6429 113 RTMLockingNamedCounter(const char *n) :
kvn@6429 114 NamedCounter(n, RTMLockingCounter), _counters() {}
kvn@6429 115
kvn@6429 116 RTMLockingCounters* counters() { return &_counters; }
kvn@6429 117 };
kvn@6429 118
duke@435 119 typedef const TypeFunc*(*TypeFunc_generator)();
duke@435 120
duke@435 121 class OptoRuntime : public AllStatic {
duke@435 122 friend class Matcher; // allow access to stub names
duke@435 123
duke@435 124 private:
duke@435 125 // define stubs
duke@435 126 static address generate_stub(ciEnv* ci_env, TypeFunc_generator gen, address C_function, const char *name, int is_fancy_jump, bool pass_tls, bool save_arguments, bool return_pc);
duke@435 127
duke@435 128 // References to generated stubs
duke@435 129 static address _new_instance_Java;
duke@435 130 static address _new_array_Java;
kvn@3157 131 static address _new_array_nozero_Java;
duke@435 132 static address _multianewarray2_Java;
duke@435 133 static address _multianewarray3_Java;
duke@435 134 static address _multianewarray4_Java;
duke@435 135 static address _multianewarray5_Java;
iveresov@3002 136 static address _multianewarrayN_Java;
ysr@777 137 static address _g1_wb_pre_Java;
ysr@777 138 static address _g1_wb_post_Java;
duke@435 139 static address _vtable_must_compile_Java;
duke@435 140 static address _complete_monitor_locking_Java;
duke@435 141 static address _rethrow_Java;
duke@435 142
duke@435 143 static address _slow_arraycopy_Java;
duke@435 144 static address _register_finalizer_Java;
duke@435 145
duke@435 146 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 147 static address _zap_dead_Java_locals_Java;
duke@435 148 static address _zap_dead_native_locals_Java;
duke@435 149 # endif
duke@435 150
duke@435 151
duke@435 152 //
duke@435 153 // Implementation of runtime methods
duke@435 154 // =================================
duke@435 155
duke@435 156 // Allocate storage for a Java instance.
coleenp@4037 157 static void new_instance_C(Klass* instance_klass, JavaThread *thread);
duke@435 158
duke@435 159 // Allocate storage for a objArray or typeArray
coleenp@4037 160 static void new_array_C(Klass* array_klass, int len, JavaThread *thread);
coleenp@4037 161 static void new_array_nozero_C(Klass* array_klass, int len, JavaThread *thread);
duke@435 162
ysr@1601 163 // Post-slow-path-allocation, pre-initializing-stores step for
ysr@1601 164 // implementing ReduceInitialCardMarks
ysr@1601 165 static void new_store_pre_barrier(JavaThread* thread);
duke@435 166
duke@435 167 // Allocate storage for a multi-dimensional arrays
duke@435 168 // Note: needs to be fixed for arbitrary number of dimensions
coleenp@4037 169 static void multianewarray2_C(Klass* klass, int len1, int len2, JavaThread *thread);
coleenp@4037 170 static void multianewarray3_C(Klass* klass, int len1, int len2, int len3, JavaThread *thread);
coleenp@4037 171 static void multianewarray4_C(Klass* klass, int len1, int len2, int len3, int len4, JavaThread *thread);
coleenp@4037 172 static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread *thread);
coleenp@4037 173 static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread *thread);
ysr@777 174 static void g1_wb_pre_C(oopDesc* orig, JavaThread* thread);
ysr@777 175 static void g1_wb_post_C(void* card_addr, JavaThread* thread);
duke@435 176
duke@435 177 public:
duke@435 178 // Slow-path Locking and Unlocking
duke@435 179 static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
duke@435 180 static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock);
duke@435 181
duke@435 182 private:
duke@435 183
duke@435 184 // Implicit exception support
duke@435 185 static void throw_null_exception_C(JavaThread* thread);
duke@435 186
duke@435 187 // Exception handling
duke@435 188 static address handle_exception_C (JavaThread* thread);
duke@435 189 static address handle_exception_C_helper(JavaThread* thread, nmethod*& nm);
duke@435 190 static address rethrow_C (oopDesc* exception, JavaThread *thread, address return_pc );
kvn@4364 191 static void deoptimize_caller_frame (JavaThread *thread);
duke@435 192 static void deoptimize_caller_frame (JavaThread *thread, bool doit);
kvn@3259 193 static bool is_deoptimized_caller_frame (JavaThread *thread);
duke@435 194
duke@435 195 // CodeBlob support
duke@435 196 // ===================================================================
duke@435 197
duke@435 198 static ExceptionBlob* _exception_blob;
duke@435 199 static void generate_exception_blob();
duke@435 200
duke@435 201 static void register_finalizer(oopDesc* obj, JavaThread* thread);
duke@435 202
duke@435 203 // zaping dead locals, either from Java frames or from native frames
duke@435 204 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 205 static void zap_dead_Java_locals_C( JavaThread* thread);
duke@435 206 static void zap_dead_native_locals_C( JavaThread* thread);
duke@435 207
duke@435 208 static void zap_dead_java_or_native_locals( JavaThread*, bool (*)(frame*));
duke@435 209
duke@435 210 public:
duke@435 211 static int ZapDeadCompiledLocals_count;
duke@435 212
duke@435 213 # endif
duke@435 214
duke@435 215
duke@435 216 public:
duke@435 217
duke@435 218 static bool is_callee_saved_register(MachRegisterNumbers reg);
duke@435 219
anoll@5919 220 // One time only generate runtime code stubs. Returns true
anoll@5919 221 // when runtime stubs have been generated successfully and
anoll@5919 222 // false otherwise.
anoll@5919 223 static bool generate(ciEnv* env);
duke@435 224
duke@435 225 // Returns the name of a stub
duke@435 226 static const char* stub_name(address entry);
duke@435 227
duke@435 228 // access to runtime stubs entry points for java code
duke@435 229 static address new_instance_Java() { return _new_instance_Java; }
duke@435 230 static address new_array_Java() { return _new_array_Java; }
kvn@3157 231 static address new_array_nozero_Java() { return _new_array_nozero_Java; }
duke@435 232 static address multianewarray2_Java() { return _multianewarray2_Java; }
duke@435 233 static address multianewarray3_Java() { return _multianewarray3_Java; }
duke@435 234 static address multianewarray4_Java() { return _multianewarray4_Java; }
duke@435 235 static address multianewarray5_Java() { return _multianewarray5_Java; }
iveresov@3002 236 static address multianewarrayN_Java() { return _multianewarrayN_Java; }
ysr@777 237 static address g1_wb_pre_Java() { return _g1_wb_pre_Java; }
ysr@777 238 static address g1_wb_post_Java() { return _g1_wb_post_Java; }
duke@435 239 static address vtable_must_compile_stub() { return _vtable_must_compile_Java; }
duke@435 240 static address complete_monitor_locking_Java() { return _complete_monitor_locking_Java; }
duke@435 241
duke@435 242 static address slow_arraycopy_Java() { return _slow_arraycopy_Java; }
duke@435 243 static address register_finalizer_Java() { return _register_finalizer_Java; }
duke@435 244
duke@435 245
duke@435 246 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 247 static address zap_dead_locals_stub(bool is_native) { return is_native
duke@435 248 ? _zap_dead_native_locals_Java
duke@435 249 : _zap_dead_Java_locals_Java; }
duke@435 250 static MachNode* node_to_call_zap_dead_locals(Node* n, int block_num, bool is_native);
duke@435 251 # endif
duke@435 252
duke@435 253 static ExceptionBlob* exception_blob() { return _exception_blob; }
duke@435 254
duke@435 255 // Leaf routines helping with method data update
duke@435 256 static void profile_receiver_type_C(DataLayout* data, oopDesc* receiver);
duke@435 257
duke@435 258 // Implicit exception support
duke@435 259 static void throw_div0_exception_C (JavaThread* thread);
duke@435 260 static void throw_stack_overflow_error_C(JavaThread* thread);
duke@435 261
duke@435 262 // Exception handling
duke@435 263 static address rethrow_stub() { return _rethrow_Java; }
duke@435 264
duke@435 265
duke@435 266 // Type functions
duke@435 267 // ======================================================
duke@435 268
duke@435 269 static const TypeFunc* new_instance_Type(); // object allocation (slow case)
duke@435 270 static const TypeFunc* new_array_Type (); // [a]newarray (slow case)
duke@435 271 static const TypeFunc* multianewarray_Type(int ndim); // multianewarray
duke@435 272 static const TypeFunc* multianewarray2_Type(); // multianewarray
duke@435 273 static const TypeFunc* multianewarray3_Type(); // multianewarray
duke@435 274 static const TypeFunc* multianewarray4_Type(); // multianewarray
duke@435 275 static const TypeFunc* multianewarray5_Type(); // multianewarray
iveresov@3002 276 static const TypeFunc* multianewarrayN_Type(); // multianewarray
ysr@777 277 static const TypeFunc* g1_wb_pre_Type();
ysr@777 278 static const TypeFunc* g1_wb_post_Type();
duke@435 279 static const TypeFunc* complete_monitor_enter_Type();
duke@435 280 static const TypeFunc* complete_monitor_exit_Type();
duke@435 281 static const TypeFunc* uncommon_trap_Type();
duke@435 282 static const TypeFunc* athrow_Type();
duke@435 283 static const TypeFunc* rethrow_Type();
duke@435 284 static const TypeFunc* Math_D_D_Type(); // sin,cos & friends
duke@435 285 static const TypeFunc* Math_DD_D_Type(); // mod,pow & friends
duke@435 286 static const TypeFunc* modf_Type();
duke@435 287 static const TypeFunc* l2f_Type();
rbackman@3709 288 static const TypeFunc* void_long_Type();
duke@435 289
duke@435 290 static const TypeFunc* flush_windows_Type();
duke@435 291
duke@435 292 // arraycopy routine types
duke@435 293 static const TypeFunc* fast_arraycopy_Type(); // bit-blasters
duke@435 294 static const TypeFunc* checkcast_arraycopy_Type();
duke@435 295 static const TypeFunc* generic_arraycopy_Type();
duke@435 296 static const TypeFunc* slow_arraycopy_Type(); // the full routine
duke@435 297
never@2118 298 static const TypeFunc* array_fill_Type();
never@2118 299
kvn@4205 300 static const TypeFunc* aescrypt_block_Type();
kvn@4205 301 static const TypeFunc* cipherBlockChaining_aescrypt_Type();
kvn@4205 302
kvn@7027 303 static const TypeFunc* sha_implCompress_Type();
kvn@7027 304 static const TypeFunc* digestBase_implCompressMB_Type();
kvn@7027 305
drchase@5353 306 static const TypeFunc* updateBytesCRC32_Type();
drchase@5353 307
duke@435 308 // leaf on stack replacement interpreter accessor types
duke@435 309 static const TypeFunc* osr_end_Type();
duke@435 310
duke@435 311 // leaf methodData routine types
duke@435 312 static const TypeFunc* profile_receiver_type_Type();
duke@435 313
duke@435 314 // leaf on stack replacement interpreter accessor types
duke@435 315 static const TypeFunc* fetch_int_Type();
duke@435 316 static const TypeFunc* fetch_long_Type();
duke@435 317 static const TypeFunc* fetch_float_Type();
duke@435 318 static const TypeFunc* fetch_double_Type();
duke@435 319 static const TypeFunc* fetch_oop_Type();
duke@435 320 static const TypeFunc* fetch_monitor_Type();
duke@435 321
duke@435 322 static const TypeFunc* register_finalizer_Type();
duke@435 323
duke@435 324 // Dtrace support
duke@435 325 static const TypeFunc* dtrace_method_entry_exit_Type();
duke@435 326 static const TypeFunc* dtrace_object_alloc_Type();
duke@435 327
duke@435 328 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 329 static const TypeFunc* zap_dead_locals_Type();
duke@435 330 # endif
duke@435 331
duke@435 332 private:
duke@435 333 static NamedCounter * volatile _named_counters;
duke@435 334
duke@435 335 public:
duke@435 336 // helper function which creates a named counter labeled with the
duke@435 337 // if they are available
duke@435 338 static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
duke@435 339
duke@435 340 // dumps all the named counters
duke@435 341 static void print_named_counters();
duke@435 342
duke@435 343 };
stefank@2314 344
stefank@2314 345 #endif // SHARE_VM_OPTO_RUNTIME_HPP

mercurial