src/share/vm/opto/runtime.hpp

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

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

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

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

mercurial