src/share/vm/c1/c1_Runtime1.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/c1/c1_Runtime1.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,190 @@
     1.4 +/*
     1.5 + * Copyright 1999-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 +class StubAssembler;
    1.29 +
    1.30 +// The Runtime1 holds all assembly stubs and VM
    1.31 +// runtime routines needed by code code generated
    1.32 +// by the Compiler1.
    1.33 +
    1.34 +#define RUNTIME1_STUBS(stub, last_entry) \
    1.35 +  stub(dtrace_object_alloc)          \
    1.36 +  stub(unwind_exception)             \
    1.37 +  stub(forward_exception)            \
    1.38 +  stub(throw_range_check_failed)       /* throws ArrayIndexOutOfBoundsException */ \
    1.39 +  stub(throw_index_exception)          /* throws IndexOutOfBoundsException */ \
    1.40 +  stub(throw_div0_exception)         \
    1.41 +  stub(throw_null_pointer_exception) \
    1.42 +  stub(register_finalizer)           \
    1.43 +  stub(new_instance)                 \
    1.44 +  stub(fast_new_instance)            \
    1.45 +  stub(fast_new_instance_init_check) \
    1.46 +  stub(new_type_array)               \
    1.47 +  stub(new_object_array)             \
    1.48 +  stub(new_multi_array)              \
    1.49 +  stub(handle_exception_nofpu)         /* optimized version that does not preserve fpu registers */ \
    1.50 +  stub(handle_exception)             \
    1.51 +  stub(throw_array_store_exception)  \
    1.52 +  stub(throw_class_cast_exception)   \
    1.53 +  stub(throw_incompatible_class_change_error)   \
    1.54 +  stub(slow_subtype_check)           \
    1.55 +  stub(monitorenter)                 \
    1.56 +  stub(monitorenter_nofpu)             /* optimized version that does not preserve fpu registers */ \
    1.57 +  stub(monitorexit)                  \
    1.58 +  stub(monitorexit_nofpu)              /* optimized version that does not preserve fpu registers */ \
    1.59 +  stub(access_field_patching)        \
    1.60 +  stub(load_klass_patching)          \
    1.61 +  stub(jvmti_exception_throw)        \
    1.62 +  stub(fpu2long_stub)                \
    1.63 +  stub(counter_overflow)             \
    1.64 +  last_entry(number_of_ids)
    1.65 +
    1.66 +#define DECLARE_STUB_ID(x)       x ## _id ,
    1.67 +#define DECLARE_LAST_STUB_ID(x)  x
    1.68 +#define STUB_NAME(x)             #x " Runtime1 stub",
    1.69 +#define LAST_STUB_NAME(x)        #x " Runtime1 stub"
    1.70 +
    1.71 +class Runtime1: public AllStatic {
    1.72 +  friend class VMStructs;
    1.73 +  friend class ArrayCopyStub;
    1.74 + private:
    1.75 +  static int desired_max_code_buffer_size() {
    1.76 +    return (int) NMethodSizeLimit;  // default 256K or 512K
    1.77 +  }
    1.78 +  static int desired_max_constant_size() {
    1.79 +    return (int) NMethodSizeLimit / 10;  // about 25K
    1.80 +  }
    1.81 +
    1.82 +  // Note: This buffers is allocated once at startup since allocation
    1.83 +  // for each compilation seems to be too expensive (at least on Intel
    1.84 +  // win32).
    1.85 +  static BufferBlob* _buffer_blob;
    1.86 +
    1.87 + public:
    1.88 +  enum StubID {
    1.89 +    RUNTIME1_STUBS(DECLARE_STUB_ID, DECLARE_LAST_STUB_ID)
    1.90 +  };
    1.91 +
    1.92 +  // statistics
    1.93 +#ifndef PRODUCT
    1.94 +  static int _resolve_invoke_cnt;
    1.95 +  static int _handle_wrong_method_cnt;
    1.96 +  static int _ic_miss_cnt;
    1.97 +  static int _generic_arraycopy_cnt;
    1.98 +  static int _primitive_arraycopy_cnt;
    1.99 +  static int _oop_arraycopy_cnt;
   1.100 +  static int _arraycopy_slowcase_cnt;
   1.101 +  static int _new_type_array_slowcase_cnt;
   1.102 +  static int _new_object_array_slowcase_cnt;
   1.103 +  static int _new_instance_slowcase_cnt;
   1.104 +  static int _new_multi_array_slowcase_cnt;
   1.105 +  static int _monitorenter_slowcase_cnt;
   1.106 +  static int _monitorexit_slowcase_cnt;
   1.107 +  static int _patch_code_slowcase_cnt;
   1.108 +  static int _throw_range_check_exception_count;
   1.109 +  static int _throw_index_exception_count;
   1.110 +  static int _throw_div0_exception_count;
   1.111 +  static int _throw_null_pointer_exception_count;
   1.112 +  static int _throw_class_cast_exception_count;
   1.113 +  static int _throw_incompatible_class_change_error_count;
   1.114 +  static int _throw_array_store_exception_count;
   1.115 +  static int _throw_count;
   1.116 +#endif
   1.117 +
   1.118 + private:
   1.119 +  static bool      _is_initialized;
   1.120 +  static CodeBlob* _blobs[number_of_ids];
   1.121 +  static const char* _blob_names[];
   1.122 +
   1.123 +  // stub generation
   1.124 +  static void generate_blob_for(StubID id);
   1.125 +  static OopMapSet* generate_code_for(StubID id, StubAssembler* masm);
   1.126 +  static OopMapSet* generate_exception_throw(StubAssembler* sasm, address target, bool has_argument);
   1.127 +  static void generate_handle_exception(StubAssembler *sasm, OopMapSet* oop_maps, OopMap* oop_map, bool ignore_fpu_registers = false);
   1.128 +  static void generate_unwind_exception(StubAssembler *sasm);
   1.129 +  static OopMapSet* generate_patching(StubAssembler* sasm, address target);
   1.130 +
   1.131 +  static OopMapSet* generate_stub_call(StubAssembler* sasm, Register result, address entry,
   1.132 +                                       Register arg1 = noreg, Register arg2 = noreg, Register arg3 = noreg);
   1.133 +
   1.134 +  // runtime entry points
   1.135 +  static void new_instance    (JavaThread* thread, klassOopDesc* klass);
   1.136 +  static void new_type_array  (JavaThread* thread, klassOopDesc* klass, jint length);
   1.137 +  static void new_object_array(JavaThread* thread, klassOopDesc* klass, jint length);
   1.138 +  static void new_multi_array (JavaThread* thread, klassOopDesc* klass, int rank, jint* dims);
   1.139 +
   1.140 +#ifdef TIERED
   1.141 +  static void counter_overflow(JavaThread* thread, int bci);
   1.142 +#endif // TIERED
   1.143 +
   1.144 +  static void unimplemented_entry   (JavaThread* thread, StubID id);
   1.145 +
   1.146 +  static address exception_handler_for_pc(JavaThread* thread);
   1.147 +  static void post_jvmti_exception_throw(JavaThread* thread);
   1.148 +
   1.149 +  static void throw_range_check_exception(JavaThread* thread, int index);
   1.150 +  static void throw_index_exception(JavaThread* thread, int index);
   1.151 +  static void throw_div0_exception(JavaThread* thread);
   1.152 +  static void throw_null_pointer_exception(JavaThread* thread);
   1.153 +  static void throw_class_cast_exception(JavaThread* thread, oopDesc* obect);
   1.154 +  static void throw_incompatible_class_change_error(JavaThread* thread);
   1.155 +  static void throw_array_store_exception(JavaThread* thread);
   1.156 +
   1.157 +  static void monitorenter(JavaThread* thread, oopDesc* obj, BasicObjectLock* lock);
   1.158 +  static void monitorexit (JavaThread* thread, BasicObjectLock* lock);
   1.159 +
   1.160 +  static int access_field_patching(JavaThread* thread);
   1.161 +  static int move_klass_patching(JavaThread* thread);
   1.162 +
   1.163 +  static void patch_code(JavaThread* thread, StubID stub_id);
   1.164 +
   1.165 + public:
   1.166 +  static BufferBlob* get_buffer_blob();
   1.167 +  static void setup_code_buffer(CodeBuffer* cb, int call_stub_estimate);
   1.168 +
   1.169 +  // initialization
   1.170 +  static bool is_initialized()                   { return _is_initialized; }
   1.171 +  static void initialize();
   1.172 +  static void initialize_pd();
   1.173 +
   1.174 +  // stubs
   1.175 +  static CodeBlob* blob_for (StubID id);
   1.176 +  static address   entry_for(StubID id)          { return blob_for(id)->instructions_begin(); }
   1.177 +  static const char* name_for (StubID id);
   1.178 +  static const char* name_for_address(address entry);
   1.179 +
   1.180 +  // method tracing
   1.181 +  static void trace_block_entry(jint block_id);
   1.182 +
   1.183 +#ifndef PRODUCT
   1.184 +  static address throw_count_address()       { return (address)&_throw_count;       }
   1.185 +#endif
   1.186 +
   1.187 +  // directly accessible leaf routine
   1.188 +  static int  arraycopy(oopDesc* src, int src_pos, oopDesc* dst, int dst_pos, int length);
   1.189 +  static void primitive_arraycopy(HeapWord* src, HeapWord* dst, int length);
   1.190 +  static void oop_arraycopy(HeapWord* src, HeapWord* dst, int length);
   1.191 +
   1.192 +  static void print_statistics()                 PRODUCT_RETURN;
   1.193 +};

mercurial