src/share/vm/opto/runtime.hpp

Tue, 09 Oct 2012 10:11:38 +0200

author
roland
date
Tue, 09 Oct 2012 10:11:38 +0200
changeset 4159
8e47bac5643a
parent 4037
da91efe96a93
child 4205
a3ecd773a7b9
permissions
-rw-r--r--

7054512: Compress class pointers after perm gen removal
Summary: support of compress class pointers in the compilers.
Reviewed-by: kvn, twisti

duke@435 1 /*
rbackman@3709 2 * Copyright (c) 1998, 2012, 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"
stefank@2314 32 #include "runtime/deoptimization.hpp"
stefank@2314 33 #include "runtime/vframe.hpp"
stefank@2314 34
duke@435 35 //------------------------------OptoRuntime------------------------------------
duke@435 36 // Opto compiler runtime routines
duke@435 37 //
duke@435 38 // These are all generated from Ideal graphs. They are called with the
duke@435 39 // Java calling convention. Internally they call C++. They are made once at
duke@435 40 // startup time and Opto compiles calls to them later.
duke@435 41 // Things are broken up into quads: the signature they will be called with,
duke@435 42 // the address of the generated code, the corresponding C++ code and an
duke@435 43 // nmethod.
duke@435 44
duke@435 45 // The signature (returned by "xxx_Type()") is used at startup time by the
duke@435 46 // Generator to make the generated code "xxx_Java". Opto compiles calls
duke@435 47 // to the generated code "xxx_Java". When the compiled code gets executed,
duke@435 48 // it calls the C++ code "xxx_C". The generated nmethod is saved in the
duke@435 49 // CodeCache. Exception handlers use the nmethod to get the callee-save
duke@435 50 // register OopMaps.
duke@435 51 class CallInfo;
duke@435 52
duke@435 53 //
duke@435 54 // NamedCounters are tagged counters which can be used for profiling
duke@435 55 // code in various ways. Currently they are used by the lock coarsening code
duke@435 56 //
duke@435 57
zgu@3900 58 class NamedCounter : public CHeapObj<mtCompiler> {
duke@435 59 public:
duke@435 60 enum CounterTag {
duke@435 61 NoTag,
duke@435 62 LockCounter,
duke@435 63 EliminatedLockCounter,
duke@435 64 BiasedLockingCounter
duke@435 65 };
duke@435 66
duke@435 67 private:
duke@435 68 const char * _name;
duke@435 69 int _count;
duke@435 70 CounterTag _tag;
duke@435 71 NamedCounter* _next;
duke@435 72
duke@435 73 public:
duke@435 74 NamedCounter(const char *n, CounterTag tag = NoTag):
duke@435 75 _name(n),
duke@435 76 _count(0),
duke@435 77 _next(NULL),
duke@435 78 _tag(tag) {}
duke@435 79
duke@435 80 const char * name() const { return _name; }
duke@435 81 int count() const { return _count; }
duke@435 82 address addr() { return (address)&_count; }
duke@435 83 CounterTag tag() const { return _tag; }
duke@435 84 void set_tag(CounterTag tag) { _tag = tag; }
duke@435 85
duke@435 86 NamedCounter* next() const { return _next; }
duke@435 87 void set_next(NamedCounter* next) {
duke@435 88 assert(_next == NULL, "already set");
duke@435 89 _next = next;
duke@435 90 }
duke@435 91
duke@435 92 };
duke@435 93
duke@435 94 class BiasedLockingNamedCounter : public NamedCounter {
duke@435 95 private:
duke@435 96 BiasedLockingCounters _counters;
duke@435 97
duke@435 98 public:
duke@435 99 BiasedLockingNamedCounter(const char *n) :
duke@435 100 NamedCounter(n, BiasedLockingCounter), _counters() {}
duke@435 101
duke@435 102 BiasedLockingCounters* counters() { return &_counters; }
duke@435 103 };
duke@435 104
duke@435 105 typedef const TypeFunc*(*TypeFunc_generator)();
duke@435 106
duke@435 107 class OptoRuntime : public AllStatic {
duke@435 108 friend class Matcher; // allow access to stub names
duke@435 109
duke@435 110 private:
duke@435 111 // define stubs
duke@435 112 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 113
duke@435 114 // References to generated stubs
duke@435 115 static address _new_instance_Java;
duke@435 116 static address _new_array_Java;
kvn@3157 117 static address _new_array_nozero_Java;
duke@435 118 static address _multianewarray2_Java;
duke@435 119 static address _multianewarray3_Java;
duke@435 120 static address _multianewarray4_Java;
duke@435 121 static address _multianewarray5_Java;
iveresov@3002 122 static address _multianewarrayN_Java;
ysr@777 123 static address _g1_wb_pre_Java;
ysr@777 124 static address _g1_wb_post_Java;
duke@435 125 static address _vtable_must_compile_Java;
duke@435 126 static address _complete_monitor_locking_Java;
duke@435 127 static address _rethrow_Java;
duke@435 128
duke@435 129 static address _slow_arraycopy_Java;
duke@435 130 static address _register_finalizer_Java;
duke@435 131
duke@435 132 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 133 static address _zap_dead_Java_locals_Java;
duke@435 134 static address _zap_dead_native_locals_Java;
duke@435 135 # endif
duke@435 136
duke@435 137
duke@435 138 //
duke@435 139 // Implementation of runtime methods
duke@435 140 // =================================
duke@435 141
duke@435 142 // Allocate storage for a Java instance.
coleenp@4037 143 static void new_instance_C(Klass* instance_klass, JavaThread *thread);
duke@435 144
duke@435 145 // Allocate storage for a objArray or typeArray
coleenp@4037 146 static void new_array_C(Klass* array_klass, int len, JavaThread *thread);
coleenp@4037 147 static void new_array_nozero_C(Klass* array_klass, int len, JavaThread *thread);
duke@435 148
ysr@1601 149 // Post-slow-path-allocation, pre-initializing-stores step for
ysr@1601 150 // implementing ReduceInitialCardMarks
ysr@1601 151 static void new_store_pre_barrier(JavaThread* thread);
duke@435 152
duke@435 153 // Allocate storage for a multi-dimensional arrays
duke@435 154 // Note: needs to be fixed for arbitrary number of dimensions
coleenp@4037 155 static void multianewarray2_C(Klass* klass, int len1, int len2, JavaThread *thread);
coleenp@4037 156 static void multianewarray3_C(Klass* klass, int len1, int len2, int len3, JavaThread *thread);
coleenp@4037 157 static void multianewarray4_C(Klass* klass, int len1, int len2, int len3, int len4, JavaThread *thread);
coleenp@4037 158 static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread *thread);
coleenp@4037 159 static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread *thread);
ysr@777 160 static void g1_wb_pre_C(oopDesc* orig, JavaThread* thread);
ysr@777 161 static void g1_wb_post_C(void* card_addr, JavaThread* thread);
duke@435 162
duke@435 163 public:
duke@435 164 // Slow-path Locking and Unlocking
duke@435 165 static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
duke@435 166 static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock);
duke@435 167
duke@435 168 private:
duke@435 169
duke@435 170 // Implicit exception support
duke@435 171 static void throw_null_exception_C(JavaThread* thread);
duke@435 172
duke@435 173 // Exception handling
duke@435 174 static address handle_exception_C (JavaThread* thread);
duke@435 175 static address handle_exception_C_helper(JavaThread* thread, nmethod*& nm);
duke@435 176 static address rethrow_C (oopDesc* exception, JavaThread *thread, address return_pc );
duke@435 177 static void deoptimize_caller_frame (JavaThread *thread, bool doit);
kvn@3259 178 static bool is_deoptimized_caller_frame (JavaThread *thread);
duke@435 179
duke@435 180 // CodeBlob support
duke@435 181 // ===================================================================
duke@435 182
duke@435 183 static ExceptionBlob* _exception_blob;
duke@435 184 static void generate_exception_blob();
duke@435 185
duke@435 186 static void register_finalizer(oopDesc* obj, JavaThread* thread);
duke@435 187
duke@435 188 // zaping dead locals, either from Java frames or from native frames
duke@435 189 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 190 static void zap_dead_Java_locals_C( JavaThread* thread);
duke@435 191 static void zap_dead_native_locals_C( JavaThread* thread);
duke@435 192
duke@435 193 static void zap_dead_java_or_native_locals( JavaThread*, bool (*)(frame*));
duke@435 194
duke@435 195 public:
duke@435 196 static int ZapDeadCompiledLocals_count;
duke@435 197
duke@435 198 # endif
duke@435 199
duke@435 200
duke@435 201 public:
duke@435 202
duke@435 203 static bool is_callee_saved_register(MachRegisterNumbers reg);
duke@435 204
duke@435 205 // One time only generate runtime code stubs
duke@435 206 static void generate(ciEnv* env);
duke@435 207
duke@435 208 // Returns the name of a stub
duke@435 209 static const char* stub_name(address entry);
duke@435 210
duke@435 211 // access to runtime stubs entry points for java code
duke@435 212 static address new_instance_Java() { return _new_instance_Java; }
duke@435 213 static address new_array_Java() { return _new_array_Java; }
kvn@3157 214 static address new_array_nozero_Java() { return _new_array_nozero_Java; }
duke@435 215 static address multianewarray2_Java() { return _multianewarray2_Java; }
duke@435 216 static address multianewarray3_Java() { return _multianewarray3_Java; }
duke@435 217 static address multianewarray4_Java() { return _multianewarray4_Java; }
duke@435 218 static address multianewarray5_Java() { return _multianewarray5_Java; }
iveresov@3002 219 static address multianewarrayN_Java() { return _multianewarrayN_Java; }
ysr@777 220 static address g1_wb_pre_Java() { return _g1_wb_pre_Java; }
ysr@777 221 static address g1_wb_post_Java() { return _g1_wb_post_Java; }
duke@435 222 static address vtable_must_compile_stub() { return _vtable_must_compile_Java; }
duke@435 223 static address complete_monitor_locking_Java() { return _complete_monitor_locking_Java; }
duke@435 224
duke@435 225 static address slow_arraycopy_Java() { return _slow_arraycopy_Java; }
duke@435 226 static address register_finalizer_Java() { return _register_finalizer_Java; }
duke@435 227
duke@435 228
duke@435 229 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 230 static address zap_dead_locals_stub(bool is_native) { return is_native
duke@435 231 ? _zap_dead_native_locals_Java
duke@435 232 : _zap_dead_Java_locals_Java; }
duke@435 233 static MachNode* node_to_call_zap_dead_locals(Node* n, int block_num, bool is_native);
duke@435 234 # endif
duke@435 235
duke@435 236 static ExceptionBlob* exception_blob() { return _exception_blob; }
duke@435 237
duke@435 238 // Leaf routines helping with method data update
duke@435 239 static void profile_receiver_type_C(DataLayout* data, oopDesc* receiver);
duke@435 240
duke@435 241 // Implicit exception support
duke@435 242 static void throw_div0_exception_C (JavaThread* thread);
duke@435 243 static void throw_stack_overflow_error_C(JavaThread* thread);
duke@435 244
duke@435 245 // Exception handling
duke@435 246 static address rethrow_stub() { return _rethrow_Java; }
duke@435 247
duke@435 248
duke@435 249 // Type functions
duke@435 250 // ======================================================
duke@435 251
duke@435 252 static const TypeFunc* new_instance_Type(); // object allocation (slow case)
duke@435 253 static const TypeFunc* new_array_Type (); // [a]newarray (slow case)
duke@435 254 static const TypeFunc* multianewarray_Type(int ndim); // multianewarray
duke@435 255 static const TypeFunc* multianewarray2_Type(); // multianewarray
duke@435 256 static const TypeFunc* multianewarray3_Type(); // multianewarray
duke@435 257 static const TypeFunc* multianewarray4_Type(); // multianewarray
duke@435 258 static const TypeFunc* multianewarray5_Type(); // multianewarray
iveresov@3002 259 static const TypeFunc* multianewarrayN_Type(); // multianewarray
ysr@777 260 static const TypeFunc* g1_wb_pre_Type();
ysr@777 261 static const TypeFunc* g1_wb_post_Type();
duke@435 262 static const TypeFunc* complete_monitor_enter_Type();
duke@435 263 static const TypeFunc* complete_monitor_exit_Type();
duke@435 264 static const TypeFunc* uncommon_trap_Type();
duke@435 265 static const TypeFunc* athrow_Type();
duke@435 266 static const TypeFunc* rethrow_Type();
duke@435 267 static const TypeFunc* Math_D_D_Type(); // sin,cos & friends
duke@435 268 static const TypeFunc* Math_DD_D_Type(); // mod,pow & friends
duke@435 269 static const TypeFunc* modf_Type();
duke@435 270 static const TypeFunc* l2f_Type();
rbackman@3709 271 static const TypeFunc* void_long_Type();
duke@435 272
duke@435 273 static const TypeFunc* flush_windows_Type();
duke@435 274
duke@435 275 // arraycopy routine types
duke@435 276 static const TypeFunc* fast_arraycopy_Type(); // bit-blasters
duke@435 277 static const TypeFunc* checkcast_arraycopy_Type();
duke@435 278 static const TypeFunc* generic_arraycopy_Type();
duke@435 279 static const TypeFunc* slow_arraycopy_Type(); // the full routine
duke@435 280
never@2118 281 static const TypeFunc* array_fill_Type();
never@2118 282
duke@435 283 // leaf on stack replacement interpreter accessor types
duke@435 284 static const TypeFunc* osr_end_Type();
duke@435 285
duke@435 286 // leaf methodData routine types
duke@435 287 static const TypeFunc* profile_receiver_type_Type();
duke@435 288
duke@435 289 // leaf on stack replacement interpreter accessor types
duke@435 290 static const TypeFunc* fetch_int_Type();
duke@435 291 static const TypeFunc* fetch_long_Type();
duke@435 292 static const TypeFunc* fetch_float_Type();
duke@435 293 static const TypeFunc* fetch_double_Type();
duke@435 294 static const TypeFunc* fetch_oop_Type();
duke@435 295 static const TypeFunc* fetch_monitor_Type();
duke@435 296
duke@435 297 static const TypeFunc* register_finalizer_Type();
duke@435 298
duke@435 299 // Dtrace support
duke@435 300 static const TypeFunc* dtrace_method_entry_exit_Type();
duke@435 301 static const TypeFunc* dtrace_object_alloc_Type();
duke@435 302
duke@435 303 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 304 static const TypeFunc* zap_dead_locals_Type();
duke@435 305 # endif
duke@435 306
duke@435 307 private:
duke@435 308 static NamedCounter * volatile _named_counters;
duke@435 309
duke@435 310 public:
duke@435 311 // helper function which creates a named counter labeled with the
duke@435 312 // if they are available
duke@435 313 static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
duke@435 314
duke@435 315 // dumps all the named counters
duke@435 316 static void print_named_counters();
duke@435 317
duke@435 318 };
stefank@2314 319
stefank@2314 320 #endif // SHARE_VM_OPTO_RUNTIME_HPP

mercurial