src/share/vm/opto/runtime.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/opto/runtime.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,342 @@
     1.4 +/*
     1.5 + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_OPTO_RUNTIME_HPP
    1.29 +#define SHARE_VM_OPTO_RUNTIME_HPP
    1.30 +
    1.31 +#include "code/codeBlob.hpp"
    1.32 +#include "opto/machnode.hpp"
    1.33 +#include "opto/type.hpp"
    1.34 +#include "runtime/biasedLocking.hpp"
    1.35 +#include "runtime/rtmLocking.hpp"
    1.36 +#include "runtime/deoptimization.hpp"
    1.37 +#include "runtime/vframe.hpp"
    1.38 +
    1.39 +//------------------------------OptoRuntime------------------------------------
    1.40 +// Opto compiler runtime routines
    1.41 +//
    1.42 +// These are all generated from Ideal graphs.  They are called with the
    1.43 +// Java calling convention.  Internally they call C++.  They are made once at
    1.44 +// startup time and Opto compiles calls to them later.
    1.45 +// Things are broken up into quads: the signature they will be called with,
    1.46 +// the address of the generated code, the corresponding C++ code and an
    1.47 +// nmethod.
    1.48 +
    1.49 +// The signature (returned by "xxx_Type()") is used at startup time by the
    1.50 +// Generator to make the generated code "xxx_Java".  Opto compiles calls
    1.51 +// to the generated code "xxx_Java".  When the compiled code gets executed,
    1.52 +// it calls the C++ code "xxx_C".  The generated nmethod is saved in the
    1.53 +// CodeCache.  Exception handlers use the nmethod to get the callee-save
    1.54 +// register OopMaps.
    1.55 +class CallInfo;
    1.56 +
    1.57 +//
    1.58 +// NamedCounters are tagged counters which can be used for profiling
    1.59 +// code in various ways.  Currently they are used by the lock coarsening code
    1.60 +//
    1.61 +
    1.62 +class NamedCounter : public CHeapObj<mtCompiler> {
    1.63 +public:
    1.64 +    enum CounterTag {
    1.65 +    NoTag,
    1.66 +    LockCounter,
    1.67 +    EliminatedLockCounter,
    1.68 +    BiasedLockingCounter,
    1.69 +    RTMLockingCounter
    1.70 +  };
    1.71 +
    1.72 +private:
    1.73 +  const char *  _name;
    1.74 +  int           _count;
    1.75 +  CounterTag    _tag;
    1.76 +  NamedCounter* _next;
    1.77 +
    1.78 + public:
    1.79 +  NamedCounter(const char *n, CounterTag tag = NoTag):
    1.80 +    _name(n),
    1.81 +    _count(0),
    1.82 +    _next(NULL),
    1.83 +    _tag(tag) {}
    1.84 +
    1.85 +  const char * name() const     { return _name; }
    1.86 +  int count() const             { return _count; }
    1.87 +  address addr()                { return (address)&_count; }
    1.88 +  CounterTag tag() const        { return _tag; }
    1.89 +  void set_tag(CounterTag tag)  { _tag = tag; }
    1.90 +
    1.91 +  NamedCounter* next() const    { return _next; }
    1.92 +  void set_next(NamedCounter* next) {
    1.93 +    assert(_next == NULL || next == NULL, "already set");
    1.94 +    _next = next;
    1.95 +  }
    1.96 +
    1.97 +};
    1.98 +
    1.99 +class BiasedLockingNamedCounter : public NamedCounter {
   1.100 + private:
   1.101 +  BiasedLockingCounters _counters;
   1.102 +
   1.103 + public:
   1.104 +  BiasedLockingNamedCounter(const char *n) :
   1.105 +    NamedCounter(n, BiasedLockingCounter), _counters() {}
   1.106 +
   1.107 +  BiasedLockingCounters* counters() { return &_counters; }
   1.108 +};
   1.109 +
   1.110 +
   1.111 +class RTMLockingNamedCounter : public NamedCounter {
   1.112 + private:
   1.113 + RTMLockingCounters _counters;
   1.114 +
   1.115 + public:
   1.116 +  RTMLockingNamedCounter(const char *n) :
   1.117 +    NamedCounter(n, RTMLockingCounter), _counters() {}
   1.118 +
   1.119 +  RTMLockingCounters* counters() { return &_counters; }
   1.120 +};
   1.121 +
   1.122 +typedef const TypeFunc*(*TypeFunc_generator)();
   1.123 +
   1.124 +class OptoRuntime : public AllStatic {
   1.125 +  friend class Matcher;  // allow access to stub names
   1.126 +
   1.127 + private:
   1.128 +  // define stubs
   1.129 +  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.130 +
   1.131 +  // References to generated stubs
   1.132 +  static address _new_instance_Java;
   1.133 +  static address _new_array_Java;
   1.134 +  static address _new_array_nozero_Java;
   1.135 +  static address _multianewarray2_Java;
   1.136 +  static address _multianewarray3_Java;
   1.137 +  static address _multianewarray4_Java;
   1.138 +  static address _multianewarray5_Java;
   1.139 +  static address _multianewarrayN_Java;
   1.140 +  static address _g1_wb_pre_Java;
   1.141 +  static address _g1_wb_post_Java;
   1.142 +  static address _vtable_must_compile_Java;
   1.143 +  static address _complete_monitor_locking_Java;
   1.144 +  static address _rethrow_Java;
   1.145 +
   1.146 +  static address _slow_arraycopy_Java;
   1.147 +  static address _register_finalizer_Java;
   1.148 +
   1.149 +# ifdef ENABLE_ZAP_DEAD_LOCALS
   1.150 +  static address _zap_dead_Java_locals_Java;
   1.151 +  static address _zap_dead_native_locals_Java;
   1.152 +# endif
   1.153 +
   1.154 +
   1.155 +  //
   1.156 +  // Implementation of runtime methods
   1.157 +  // =================================
   1.158 +
   1.159 +  // Allocate storage for a Java instance.
   1.160 +  static void new_instance_C(Klass* instance_klass, JavaThread *thread);
   1.161 +
   1.162 +  // Allocate storage for a objArray or typeArray
   1.163 +  static void new_array_C(Klass* array_klass, int len, JavaThread *thread);
   1.164 +  static void new_array_nozero_C(Klass* array_klass, int len, JavaThread *thread);
   1.165 +
   1.166 +  // Post-slow-path-allocation, pre-initializing-stores step for
   1.167 +  // implementing ReduceInitialCardMarks
   1.168 +  static void new_store_pre_barrier(JavaThread* thread);
   1.169 +
   1.170 +  // Allocate storage for a multi-dimensional arrays
   1.171 +  // Note: needs to be fixed for arbitrary number of dimensions
   1.172 +  static void multianewarray2_C(Klass* klass, int len1, int len2, JavaThread *thread);
   1.173 +  static void multianewarray3_C(Klass* klass, int len1, int len2, int len3, JavaThread *thread);
   1.174 +  static void multianewarray4_C(Klass* klass, int len1, int len2, int len3, int len4, JavaThread *thread);
   1.175 +  static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread *thread);
   1.176 +  static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread *thread);
   1.177 +  static void g1_wb_pre_C(oopDesc* orig, JavaThread* thread);
   1.178 +  static void g1_wb_post_C(void* card_addr, JavaThread* thread);
   1.179 +
   1.180 +public:
   1.181 +  // Slow-path Locking and Unlocking
   1.182 +  static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
   1.183 +  static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock);
   1.184 +
   1.185 +private:
   1.186 +
   1.187 +  // Implicit exception support
   1.188 +  static void throw_null_exception_C(JavaThread* thread);
   1.189 +
   1.190 +  // Exception handling
   1.191 +  static address handle_exception_C       (JavaThread* thread);
   1.192 +  static address handle_exception_C_helper(JavaThread* thread, nmethod*& nm);
   1.193 +  static address rethrow_C                (oopDesc* exception, JavaThread *thread, address return_pc );
   1.194 +  static void deoptimize_caller_frame     (JavaThread *thread);
   1.195 +  static void deoptimize_caller_frame     (JavaThread *thread, bool doit);
   1.196 +  static bool is_deoptimized_caller_frame (JavaThread *thread);
   1.197 +
   1.198 +  // CodeBlob support
   1.199 +  // ===================================================================
   1.200 +
   1.201 +  static ExceptionBlob*       _exception_blob;
   1.202 +  static void generate_exception_blob();
   1.203 +
   1.204 +  static void register_finalizer(oopDesc* obj, JavaThread* thread);
   1.205 +
   1.206 +  // zaping dead locals, either from Java frames or from native frames
   1.207 +# ifdef ENABLE_ZAP_DEAD_LOCALS
   1.208 +  static void zap_dead_Java_locals_C(   JavaThread* thread);
   1.209 +  static void zap_dead_native_locals_C( JavaThread* thread);
   1.210 +
   1.211 +  static void zap_dead_java_or_native_locals( JavaThread*, bool (*)(frame*));
   1.212 +
   1.213 + public:
   1.214 +   static int ZapDeadCompiledLocals_count;
   1.215 +
   1.216 +# endif
   1.217 +
   1.218 +
   1.219 + public:
   1.220 +
   1.221 +  static bool is_callee_saved_register(MachRegisterNumbers reg);
   1.222 +
   1.223 +  // One time only generate runtime code stubs. Returns true
   1.224 +  // when runtime stubs have been generated successfully and
   1.225 +  // false otherwise.
   1.226 +  static bool generate(ciEnv* env);
   1.227 +
   1.228 +  // Returns the name of a stub
   1.229 +  static const char* stub_name(address entry);
   1.230 +
   1.231 +  // access to runtime stubs entry points for java code
   1.232 +  static address new_instance_Java()                     { return _new_instance_Java; }
   1.233 +  static address new_array_Java()                        { return _new_array_Java; }
   1.234 +  static address new_array_nozero_Java()                 { return _new_array_nozero_Java; }
   1.235 +  static address multianewarray2_Java()                  { return _multianewarray2_Java; }
   1.236 +  static address multianewarray3_Java()                  { return _multianewarray3_Java; }
   1.237 +  static address multianewarray4_Java()                  { return _multianewarray4_Java; }
   1.238 +  static address multianewarray5_Java()                  { return _multianewarray5_Java; }
   1.239 +  static address multianewarrayN_Java()                  { return _multianewarrayN_Java; }
   1.240 +  static address g1_wb_pre_Java()                        { return _g1_wb_pre_Java; }
   1.241 +  static address g1_wb_post_Java()                       { return _g1_wb_post_Java; }
   1.242 +  static address vtable_must_compile_stub()              { return _vtable_must_compile_Java; }
   1.243 +  static address complete_monitor_locking_Java()         { return _complete_monitor_locking_Java;   }
   1.244 +
   1.245 +  static address slow_arraycopy_Java()                   { return _slow_arraycopy_Java; }
   1.246 +  static address register_finalizer_Java()               { return _register_finalizer_Java; }
   1.247 +
   1.248 +
   1.249 +# ifdef ENABLE_ZAP_DEAD_LOCALS
   1.250 +  static address zap_dead_locals_stub(bool is_native)    { return is_native
   1.251 +                                                                  ? _zap_dead_native_locals_Java
   1.252 +                                                                  : _zap_dead_Java_locals_Java; }
   1.253 +  static MachNode* node_to_call_zap_dead_locals(Node* n, int block_num, bool is_native);
   1.254 +# endif
   1.255 +
   1.256 +  static ExceptionBlob*    exception_blob()                      { return _exception_blob; }
   1.257 +
   1.258 +  // Leaf routines helping with method data update
   1.259 +  static void profile_receiver_type_C(DataLayout* data, oopDesc* receiver);
   1.260 +
   1.261 +  // Implicit exception support
   1.262 +  static void throw_div0_exception_C      (JavaThread* thread);
   1.263 +  static void throw_stack_overflow_error_C(JavaThread* thread);
   1.264 +
   1.265 +  // Exception handling
   1.266 +  static address rethrow_stub()             { return _rethrow_Java; }
   1.267 +
   1.268 +
   1.269 +  // Type functions
   1.270 +  // ======================================================
   1.271 +
   1.272 +  static const TypeFunc* new_instance_Type(); // object allocation (slow case)
   1.273 +  static const TypeFunc* new_array_Type ();   // [a]newarray (slow case)
   1.274 +  static const TypeFunc* multianewarray_Type(int ndim); // multianewarray
   1.275 +  static const TypeFunc* multianewarray2_Type(); // multianewarray
   1.276 +  static const TypeFunc* multianewarray3_Type(); // multianewarray
   1.277 +  static const TypeFunc* multianewarray4_Type(); // multianewarray
   1.278 +  static const TypeFunc* multianewarray5_Type(); // multianewarray
   1.279 +  static const TypeFunc* multianewarrayN_Type(); // multianewarray
   1.280 +  static const TypeFunc* g1_wb_pre_Type();
   1.281 +  static const TypeFunc* g1_wb_post_Type();
   1.282 +  static const TypeFunc* complete_monitor_enter_Type();
   1.283 +  static const TypeFunc* complete_monitor_exit_Type();
   1.284 +  static const TypeFunc* uncommon_trap_Type();
   1.285 +  static const TypeFunc* athrow_Type();
   1.286 +  static const TypeFunc* rethrow_Type();
   1.287 +  static const TypeFunc* Math_D_D_Type();  // sin,cos & friends
   1.288 +  static const TypeFunc* Math_DD_D_Type(); // mod,pow & friends
   1.289 +  static const TypeFunc* modf_Type();
   1.290 +  static const TypeFunc* l2f_Type();
   1.291 +  static const TypeFunc* void_long_Type();
   1.292 +
   1.293 +  static const TypeFunc* flush_windows_Type();
   1.294 +
   1.295 +  // arraycopy routine types
   1.296 +  static const TypeFunc* fast_arraycopy_Type(); // bit-blasters
   1.297 +  static const TypeFunc* checkcast_arraycopy_Type();
   1.298 +  static const TypeFunc* generic_arraycopy_Type();
   1.299 +  static const TypeFunc* slow_arraycopy_Type();   // the full routine
   1.300 +
   1.301 +  static const TypeFunc* array_fill_Type();
   1.302 +
   1.303 +  static const TypeFunc* aescrypt_block_Type();
   1.304 +  static const TypeFunc* cipherBlockChaining_aescrypt_Type();
   1.305 +
   1.306 +  static const TypeFunc* updateBytesCRC32_Type();
   1.307 +
   1.308 +  // leaf on stack replacement interpreter accessor types
   1.309 +  static const TypeFunc* osr_end_Type();
   1.310 +
   1.311 +  // leaf methodData routine types
   1.312 +  static const TypeFunc* profile_receiver_type_Type();
   1.313 +
   1.314 +  // leaf on stack replacement interpreter accessor types
   1.315 +  static const TypeFunc* fetch_int_Type();
   1.316 +  static const TypeFunc* fetch_long_Type();
   1.317 +  static const TypeFunc* fetch_float_Type();
   1.318 +  static const TypeFunc* fetch_double_Type();
   1.319 +  static const TypeFunc* fetch_oop_Type();
   1.320 +  static const TypeFunc* fetch_monitor_Type();
   1.321 +
   1.322 +  static const TypeFunc* register_finalizer_Type();
   1.323 +
   1.324 +  // Dtrace support
   1.325 +  static const TypeFunc* dtrace_method_entry_exit_Type();
   1.326 +  static const TypeFunc* dtrace_object_alloc_Type();
   1.327 +
   1.328 +# ifdef ENABLE_ZAP_DEAD_LOCALS
   1.329 +  static const TypeFunc* zap_dead_locals_Type();
   1.330 +# endif
   1.331 +
   1.332 + private:
   1.333 + static NamedCounter * volatile _named_counters;
   1.334 +
   1.335 + public:
   1.336 + // helper function which creates a named counter labeled with the
   1.337 + // if they are available
   1.338 + static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
   1.339 +
   1.340 + // dumps all the named counters
   1.341 + static void          print_named_counters();
   1.342 +
   1.343 +};
   1.344 +
   1.345 +#endif // SHARE_VM_OPTO_RUNTIME_HPP

mercurial