src/share/vm/opto/runtime.hpp

Tue, 02 Sep 2008 15:03:05 -0700

author
never
date
Tue, 02 Sep 2008 15:03:05 -0700
changeset 753
60bc5071073f
parent 435
a61af66fc99e
child 777
37f87013dfd8
permissions
-rw-r--r--

6738933: assert with base pointers must match with compressed oops enabled
Reviewed-by: kvn, rasbold

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

mercurial