src/share/vm/opto/runtime.hpp

Wed, 13 Jan 2010 15:26:39 -0800

author
ysr
date
Wed, 13 Jan 2010 15:26:39 -0800
changeset 1601
7b0e9cba0307
parent 1462
39b01ab7035a
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6896647: card marks can be deferred too long
Summary: Deferred card marks are now flushed during the gc prologue. Parallel[Scavege,OldGC] and SerialGC no longer defer card marks generated by COMPILER2 as a result of ReduceInitialCardMarks. For these cases, introduced a diagnostic option to defer the card marks, only for the purposes of testing and diagnostics. CMS and G1 continue to defer card marks. Potential performance concern related to single-threaded flushing of deferred card marks in the gc prologue will be addressed in the future.
Reviewed-by: never, johnc

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;
ysr@777 111 static address _g1_wb_pre_Java;
ysr@777 112 static address _g1_wb_post_Java;
duke@435 113 static address _vtable_must_compile_Java;
duke@435 114 static address _complete_monitor_locking_Java;
duke@435 115 static address _rethrow_Java;
duke@435 116
duke@435 117 static address _slow_arraycopy_Java;
duke@435 118 static address _register_finalizer_Java;
duke@435 119
duke@435 120 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 121 static address _zap_dead_Java_locals_Java;
duke@435 122 static address _zap_dead_native_locals_Java;
duke@435 123 # endif
duke@435 124
duke@435 125
duke@435 126 //
duke@435 127 // Implementation of runtime methods
duke@435 128 // =================================
duke@435 129
duke@435 130 // Allocate storage for a Java instance.
duke@435 131 static void new_instance_C(klassOopDesc* instance_klass, JavaThread *thread);
duke@435 132
duke@435 133 // Allocate storage for a objArray or typeArray
duke@435 134 static void new_array_C(klassOopDesc* array_klass, int len, JavaThread *thread);
duke@435 135
ysr@1601 136 // Post-slow-path-allocation, pre-initializing-stores step for
ysr@1601 137 // implementing ReduceInitialCardMarks
ysr@1601 138 static void new_store_pre_barrier(JavaThread* thread);
duke@435 139
duke@435 140 // Allocate storage for a multi-dimensional arrays
duke@435 141 // Note: needs to be fixed for arbitrary number of dimensions
duke@435 142 static void multianewarray2_C(klassOopDesc* klass, int len1, int len2, JavaThread *thread);
duke@435 143 static void multianewarray3_C(klassOopDesc* klass, int len1, int len2, int len3, JavaThread *thread);
duke@435 144 static void multianewarray4_C(klassOopDesc* klass, int len1, int len2, int len3, int len4, JavaThread *thread);
duke@435 145 static void multianewarray5_C(klassOopDesc* klass, int len1, int len2, int len3, int len4, int len5, JavaThread *thread);
ysr@777 146 static void g1_wb_pre_C(oopDesc* orig, JavaThread* thread);
ysr@777 147 static void g1_wb_post_C(void* card_addr, JavaThread* thread);
duke@435 148
duke@435 149 public:
duke@435 150 // Slow-path Locking and Unlocking
duke@435 151 static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
duke@435 152 static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock);
duke@435 153
duke@435 154 private:
duke@435 155
duke@435 156 // Implicit exception support
duke@435 157 static void throw_null_exception_C(JavaThread* thread);
duke@435 158
duke@435 159 // Exception handling
duke@435 160 static address handle_exception_C (JavaThread* thread);
duke@435 161 static address handle_exception_C_helper(JavaThread* thread, nmethod*& nm);
duke@435 162 static address rethrow_C (oopDesc* exception, JavaThread *thread, address return_pc );
duke@435 163 static void deoptimize_caller_frame (JavaThread *thread, bool doit);
duke@435 164
duke@435 165 // CodeBlob support
duke@435 166 // ===================================================================
duke@435 167
duke@435 168 static ExceptionBlob* _exception_blob;
duke@435 169 static void generate_exception_blob();
duke@435 170
duke@435 171 static void register_finalizer(oopDesc* obj, JavaThread* thread);
duke@435 172
duke@435 173 // zaping dead locals, either from Java frames or from native frames
duke@435 174 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 175 static void zap_dead_Java_locals_C( JavaThread* thread);
duke@435 176 static void zap_dead_native_locals_C( JavaThread* thread);
duke@435 177
duke@435 178 static void zap_dead_java_or_native_locals( JavaThread*, bool (*)(frame*));
duke@435 179
duke@435 180 public:
duke@435 181 static int ZapDeadCompiledLocals_count;
duke@435 182
duke@435 183 # endif
duke@435 184
duke@435 185
duke@435 186 public:
duke@435 187
duke@435 188 static bool is_callee_saved_register(MachRegisterNumbers reg);
duke@435 189
duke@435 190 // One time only generate runtime code stubs
duke@435 191 static void generate(ciEnv* env);
duke@435 192
duke@435 193 // Returns the name of a stub
duke@435 194 static const char* stub_name(address entry);
duke@435 195
duke@435 196 // access to runtime stubs entry points for java code
duke@435 197 static address new_instance_Java() { return _new_instance_Java; }
duke@435 198 static address new_array_Java() { return _new_array_Java; }
duke@435 199 static address multianewarray2_Java() { return _multianewarray2_Java; }
duke@435 200 static address multianewarray3_Java() { return _multianewarray3_Java; }
duke@435 201 static address multianewarray4_Java() { return _multianewarray4_Java; }
duke@435 202 static address multianewarray5_Java() { return _multianewarray5_Java; }
ysr@777 203 static address g1_wb_pre_Java() { return _g1_wb_pre_Java; }
ysr@777 204 static address g1_wb_post_Java() { return _g1_wb_post_Java; }
duke@435 205 static address vtable_must_compile_stub() { return _vtable_must_compile_Java; }
duke@435 206 static address complete_monitor_locking_Java() { return _complete_monitor_locking_Java; }
duke@435 207
duke@435 208 static address slow_arraycopy_Java() { return _slow_arraycopy_Java; }
duke@435 209 static address register_finalizer_Java() { return _register_finalizer_Java; }
duke@435 210
duke@435 211
duke@435 212 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 213 static address zap_dead_locals_stub(bool is_native) { return is_native
duke@435 214 ? _zap_dead_native_locals_Java
duke@435 215 : _zap_dead_Java_locals_Java; }
duke@435 216 static MachNode* node_to_call_zap_dead_locals(Node* n, int block_num, bool is_native);
duke@435 217 # endif
duke@435 218
duke@435 219 static ExceptionBlob* exception_blob() { return _exception_blob; }
duke@435 220
duke@435 221 // Leaf routines helping with method data update
duke@435 222 static void profile_receiver_type_C(DataLayout* data, oopDesc* receiver);
duke@435 223
duke@435 224 // Implicit exception support
duke@435 225 static void throw_div0_exception_C (JavaThread* thread);
duke@435 226 static void throw_stack_overflow_error_C(JavaThread* thread);
duke@435 227
duke@435 228 // Exception handling
duke@435 229 static address rethrow_stub() { return _rethrow_Java; }
duke@435 230
duke@435 231
duke@435 232 // Type functions
duke@435 233 // ======================================================
duke@435 234
duke@435 235 static const TypeFunc* new_instance_Type(); // object allocation (slow case)
duke@435 236 static const TypeFunc* new_array_Type (); // [a]newarray (slow case)
duke@435 237 static const TypeFunc* multianewarray_Type(int ndim); // multianewarray
duke@435 238 static const TypeFunc* multianewarray2_Type(); // multianewarray
duke@435 239 static const TypeFunc* multianewarray3_Type(); // multianewarray
duke@435 240 static const TypeFunc* multianewarray4_Type(); // multianewarray
duke@435 241 static const TypeFunc* multianewarray5_Type(); // multianewarray
ysr@777 242 static const TypeFunc* g1_wb_pre_Type();
ysr@777 243 static const TypeFunc* g1_wb_post_Type();
duke@435 244 static const TypeFunc* complete_monitor_enter_Type();
duke@435 245 static const TypeFunc* complete_monitor_exit_Type();
duke@435 246 static const TypeFunc* uncommon_trap_Type();
duke@435 247 static const TypeFunc* athrow_Type();
duke@435 248 static const TypeFunc* rethrow_Type();
duke@435 249 static const TypeFunc* Math_D_D_Type(); // sin,cos & friends
duke@435 250 static const TypeFunc* Math_DD_D_Type(); // mod,pow & friends
duke@435 251 static const TypeFunc* modf_Type();
duke@435 252 static const TypeFunc* l2f_Type();
duke@435 253 static const TypeFunc* current_time_millis_Type();
duke@435 254
duke@435 255 static const TypeFunc* flush_windows_Type();
duke@435 256
duke@435 257 // arraycopy routine types
duke@435 258 static const TypeFunc* fast_arraycopy_Type(); // bit-blasters
duke@435 259 static const TypeFunc* checkcast_arraycopy_Type();
duke@435 260 static const TypeFunc* generic_arraycopy_Type();
duke@435 261 static const TypeFunc* slow_arraycopy_Type(); // the full routine
duke@435 262
duke@435 263 // leaf on stack replacement interpreter accessor types
duke@435 264 static const TypeFunc* osr_end_Type();
duke@435 265
duke@435 266 // leaf methodData routine types
duke@435 267 static const TypeFunc* profile_receiver_type_Type();
duke@435 268
duke@435 269 // leaf on stack replacement interpreter accessor types
duke@435 270 static const TypeFunc* fetch_int_Type();
duke@435 271 static const TypeFunc* fetch_long_Type();
duke@435 272 static const TypeFunc* fetch_float_Type();
duke@435 273 static const TypeFunc* fetch_double_Type();
duke@435 274 static const TypeFunc* fetch_oop_Type();
duke@435 275 static const TypeFunc* fetch_monitor_Type();
duke@435 276
duke@435 277 static const TypeFunc* register_finalizer_Type();
duke@435 278
duke@435 279 // Dtrace support
duke@435 280 static const TypeFunc* dtrace_method_entry_exit_Type();
duke@435 281 static const TypeFunc* dtrace_object_alloc_Type();
duke@435 282
duke@435 283 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@435 284 static const TypeFunc* zap_dead_locals_Type();
duke@435 285 # endif
duke@435 286
duke@435 287 private:
duke@435 288 static NamedCounter * volatile _named_counters;
duke@435 289
duke@435 290 public:
duke@435 291 // helper function which creates a named counter labeled with the
duke@435 292 // if they are available
duke@435 293 static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
duke@435 294
duke@435 295 // dumps all the named counters
duke@435 296 static void print_named_counters();
duke@435 297
duke@435 298 };

mercurial