src/share/vm/opto/runtime.hpp

changeset 435
a61af66fc99e
child 777
37f87013dfd8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/opto/runtime.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,289 @@
     1.4 +/*
     1.5 + * Copyright 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +//------------------------------OptoRuntime------------------------------------
    1.29 +// Opto compiler runtime routines
    1.30 +//
    1.31 +// These are all generated from Ideal graphs.  They are called with the
    1.32 +// Java calling convention.  Internally they call C++.  They are made once at
    1.33 +// startup time and Opto compiles calls to them later.
    1.34 +// Things are broken up into quads: the signature they will be called with,
    1.35 +// the address of the generated code, the corresponding C++ code and an
    1.36 +// nmethod.
    1.37 +
    1.38 +// The signature (returned by "xxx_Type()") is used at startup time by the
    1.39 +// Generator to make the generated code "xxx_Java".  Opto compiles calls
    1.40 +// to the generated code "xxx_Java".  When the compiled code gets executed,
    1.41 +// it calls the C++ code "xxx_C".  The generated nmethod is saved in the
    1.42 +// CodeCache.  Exception handlers use the nmethod to get the callee-save
    1.43 +// register OopMaps.
    1.44 +class CallInfo;
    1.45 +
    1.46 +//
    1.47 +// NamedCounters are tagged counters which can be used for profiling
    1.48 +// code in various ways.  Currently they are used by the lock coarsening code
    1.49 +//
    1.50 +
    1.51 +class NamedCounter : public CHeapObj {
    1.52 +public:
    1.53 +    enum CounterTag {
    1.54 +    NoTag,
    1.55 +    LockCounter,
    1.56 +    EliminatedLockCounter,
    1.57 +    BiasedLockingCounter
    1.58 +  };
    1.59 +
    1.60 +private:
    1.61 +  const char *  _name;
    1.62 +  int           _count;
    1.63 +  CounterTag    _tag;
    1.64 +  NamedCounter* _next;
    1.65 +
    1.66 + public:
    1.67 +  NamedCounter(const char *n, CounterTag tag = NoTag):
    1.68 +    _name(n),
    1.69 +    _count(0),
    1.70 +    _next(NULL),
    1.71 +    _tag(tag) {}
    1.72 +
    1.73 +  const char * name() const     { return _name; }
    1.74 +  int count() const             { return _count; }
    1.75 +  address addr()                { return (address)&_count; }
    1.76 +  CounterTag tag() const        { return _tag; }
    1.77 +  void set_tag(CounterTag tag)  { _tag = tag; }
    1.78 +
    1.79 +  NamedCounter* next() const    { return _next; }
    1.80 +  void set_next(NamedCounter* next) {
    1.81 +    assert(_next == NULL, "already set");
    1.82 +    _next = next;
    1.83 +  }
    1.84 +
    1.85 +};
    1.86 +
    1.87 +class BiasedLockingNamedCounter : public NamedCounter {
    1.88 + private:
    1.89 +  BiasedLockingCounters _counters;
    1.90 +
    1.91 + public:
    1.92 +  BiasedLockingNamedCounter(const char *n) :
    1.93 +    NamedCounter(n, BiasedLockingCounter), _counters() {}
    1.94 +
    1.95 +  BiasedLockingCounters* counters() { return &_counters; }
    1.96 +};
    1.97 +
    1.98 +typedef const TypeFunc*(*TypeFunc_generator)();
    1.99 +
   1.100 +class OptoRuntime : public AllStatic {
   1.101 +  friend class Matcher;  // allow access to stub names
   1.102 +
   1.103 + private:
   1.104 +  // define stubs
   1.105 +  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);
   1.106 +
   1.107 +  // References to generated stubs
   1.108 +  static address _new_instance_Java;
   1.109 +  static address _new_array_Java;
   1.110 +  static address _multianewarray2_Java;
   1.111 +  static address _multianewarray3_Java;
   1.112 +  static address _multianewarray4_Java;
   1.113 +  static address _multianewarray5_Java;
   1.114 +  static address _vtable_must_compile_Java;
   1.115 +  static address _complete_monitor_locking_Java;
   1.116 +  static address _rethrow_Java;
   1.117 +
   1.118 +  static address _slow_arraycopy_Java;
   1.119 +  static address _register_finalizer_Java;
   1.120 +
   1.121 +# ifdef ENABLE_ZAP_DEAD_LOCALS
   1.122 +  static address _zap_dead_Java_locals_Java;
   1.123 +  static address _zap_dead_native_locals_Java;
   1.124 +# endif
   1.125 +
   1.126 +
   1.127 +  //
   1.128 +  // Implementation of runtime methods
   1.129 +  // =================================
   1.130 +
   1.131 +  // Allocate storage for a Java instance.
   1.132 +  static void new_instance_C(klassOopDesc* instance_klass, JavaThread *thread);
   1.133 +
   1.134 +  // Allocate storage for a objArray or typeArray
   1.135 +  static void new_array_C(klassOopDesc* array_klass, int len, JavaThread *thread);
   1.136 +
   1.137 +  // Post-allocation step for implementing ReduceInitialCardMarks:
   1.138 +  static void do_eager_card_mark(JavaThread* thread);
   1.139 +
   1.140 +  // Allocate storage for a multi-dimensional arrays
   1.141 +  // Note: needs to be fixed for arbitrary number of dimensions
   1.142 +  static void multianewarray2_C(klassOopDesc* klass, int len1, int len2, JavaThread *thread);
   1.143 +  static void multianewarray3_C(klassOopDesc* klass, int len1, int len2, int len3, JavaThread *thread);
   1.144 +  static void multianewarray4_C(klassOopDesc* klass, int len1, int len2, int len3, int len4, JavaThread *thread);
   1.145 +  static void multianewarray5_C(klassOopDesc* klass, int len1, int len2, int len3, int len4, int len5, JavaThread *thread);
   1.146 +
   1.147 +public:
   1.148 +  // Slow-path Locking and Unlocking
   1.149 +  static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
   1.150 +  static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock);
   1.151 +
   1.152 +private:
   1.153 +
   1.154 +  // Implicit exception support
   1.155 +  static void throw_null_exception_C(JavaThread* thread);
   1.156 +
   1.157 +  // Exception handling
   1.158 +  static address handle_exception_C       (JavaThread* thread);
   1.159 +  static address handle_exception_C_helper(JavaThread* thread, nmethod*& nm);
   1.160 +  static address rethrow_C                (oopDesc* exception, JavaThread *thread, address return_pc );
   1.161 +  static void deoptimize_caller_frame     (JavaThread *thread, bool doit);
   1.162 +
   1.163 +  // CodeBlob support
   1.164 +  // ===================================================================
   1.165 +
   1.166 +  static ExceptionBlob*       _exception_blob;
   1.167 +  static void generate_exception_blob();
   1.168 +
   1.169 +  static void register_finalizer(oopDesc* obj, JavaThread* thread);
   1.170 +
   1.171 +  // zaping dead locals, either from Java frames or from native frames
   1.172 +# ifdef ENABLE_ZAP_DEAD_LOCALS
   1.173 +  static void zap_dead_Java_locals_C(   JavaThread* thread);
   1.174 +  static void zap_dead_native_locals_C( JavaThread* thread);
   1.175 +
   1.176 +  static void zap_dead_java_or_native_locals( JavaThread*, bool (*)(frame*));
   1.177 +
   1.178 + public:
   1.179 +   static int ZapDeadCompiledLocals_count;
   1.180 +
   1.181 +# endif
   1.182 +
   1.183 +
   1.184 + public:
   1.185 +
   1.186 +  static bool is_callee_saved_register(MachRegisterNumbers reg);
   1.187 +
   1.188 +  // One time only generate runtime code stubs
   1.189 +  static void generate(ciEnv* env);
   1.190 +
   1.191 +  // Returns the name of a stub
   1.192 +  static const char* stub_name(address entry);
   1.193 +
   1.194 +  // access to runtime stubs entry points for java code
   1.195 +  static address new_instance_Java()                     { return _new_instance_Java; }
   1.196 +  static address new_array_Java()                        { return _new_array_Java; }
   1.197 +  static address multianewarray2_Java()                  { return _multianewarray2_Java; }
   1.198 +  static address multianewarray3_Java()                  { return _multianewarray3_Java; }
   1.199 +  static address multianewarray4_Java()                  { return _multianewarray4_Java; }
   1.200 +  static address multianewarray5_Java()                  { return _multianewarray5_Java; }
   1.201 +  static address vtable_must_compile_stub()              { return _vtable_must_compile_Java; }
   1.202 +  static address complete_monitor_locking_Java()         { return _complete_monitor_locking_Java;   }
   1.203 +
   1.204 +  static address slow_arraycopy_Java()                   { return _slow_arraycopy_Java; }
   1.205 +  static address register_finalizer_Java()               { return _register_finalizer_Java; }
   1.206 +
   1.207 +
   1.208 +# ifdef ENABLE_ZAP_DEAD_LOCALS
   1.209 +  static address zap_dead_locals_stub(bool is_native)    { return is_native
   1.210 +                                                                  ? _zap_dead_native_locals_Java
   1.211 +                                                                  : _zap_dead_Java_locals_Java; }
   1.212 +  static MachNode* node_to_call_zap_dead_locals(Node* n, int block_num, bool is_native);
   1.213 +# endif
   1.214 +
   1.215 +  static ExceptionBlob*    exception_blob()                      { return _exception_blob; }
   1.216 +
   1.217 +  // Leaf routines helping with method data update
   1.218 +  static void profile_receiver_type_C(DataLayout* data, oopDesc* receiver);
   1.219 +
   1.220 +  // Implicit exception support
   1.221 +  static void throw_div0_exception_C      (JavaThread* thread);
   1.222 +  static void throw_stack_overflow_error_C(JavaThread* thread);
   1.223 +
   1.224 +  // Exception handling
   1.225 +  static address rethrow_stub()             { return _rethrow_Java; }
   1.226 +
   1.227 +
   1.228 +  // Type functions
   1.229 +  // ======================================================
   1.230 +
   1.231 +  static const TypeFunc* new_instance_Type(); // object allocation (slow case)
   1.232 +  static const TypeFunc* new_array_Type ();   // [a]newarray (slow case)
   1.233 +  static const TypeFunc* multianewarray_Type(int ndim); // multianewarray
   1.234 +  static const TypeFunc* multianewarray2_Type(); // multianewarray
   1.235 +  static const TypeFunc* multianewarray3_Type(); // multianewarray
   1.236 +  static const TypeFunc* multianewarray4_Type(); // multianewarray
   1.237 +  static const TypeFunc* multianewarray5_Type(); // multianewarray
   1.238 +  static const TypeFunc* complete_monitor_enter_Type();
   1.239 +  static const TypeFunc* complete_monitor_exit_Type();
   1.240 +  static const TypeFunc* uncommon_trap_Type();
   1.241 +  static const TypeFunc* athrow_Type();
   1.242 +  static const TypeFunc* rethrow_Type();
   1.243 +  static const TypeFunc* Math_D_D_Type();  // sin,cos & friends
   1.244 +  static const TypeFunc* Math_DD_D_Type(); // mod,pow & friends
   1.245 +  static const TypeFunc* modf_Type();
   1.246 +  static const TypeFunc* l2f_Type();
   1.247 +  static const TypeFunc* current_time_millis_Type();
   1.248 +
   1.249 +  static const TypeFunc* flush_windows_Type();
   1.250 +
   1.251 +  // arraycopy routine types
   1.252 +  static const TypeFunc* fast_arraycopy_Type(); // bit-blasters
   1.253 +  static const TypeFunc* checkcast_arraycopy_Type();
   1.254 +  static const TypeFunc* generic_arraycopy_Type();
   1.255 +  static const TypeFunc* slow_arraycopy_Type();   // the full routine
   1.256 +
   1.257 +  // leaf on stack replacement interpreter accessor types
   1.258 +  static const TypeFunc* osr_end_Type();
   1.259 +
   1.260 +  // leaf methodData routine types
   1.261 +  static const TypeFunc* profile_receiver_type_Type();
   1.262 +
   1.263 +  // leaf on stack replacement interpreter accessor types
   1.264 +  static const TypeFunc* fetch_int_Type();
   1.265 +  static const TypeFunc* fetch_long_Type();
   1.266 +  static const TypeFunc* fetch_float_Type();
   1.267 +  static const TypeFunc* fetch_double_Type();
   1.268 +  static const TypeFunc* fetch_oop_Type();
   1.269 +  static const TypeFunc* fetch_monitor_Type();
   1.270 +
   1.271 +  static const TypeFunc* register_finalizer_Type();
   1.272 +
   1.273 +  // Dtrace support
   1.274 +  static const TypeFunc* dtrace_method_entry_exit_Type();
   1.275 +  static const TypeFunc* dtrace_object_alloc_Type();
   1.276 +
   1.277 +# ifdef ENABLE_ZAP_DEAD_LOCALS
   1.278 +  static const TypeFunc* zap_dead_locals_Type();
   1.279 +# endif
   1.280 +
   1.281 + private:
   1.282 + static NamedCounter * volatile _named_counters;
   1.283 +
   1.284 + public:
   1.285 + // helper function which creates a named counter labeled with the
   1.286 + // if they are available
   1.287 + static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
   1.288 +
   1.289 + // dumps all the named counters
   1.290 + static void          print_named_counters();
   1.291 +
   1.292 +};

mercurial