Thu, 21 Nov 2013 12:30:35 -0800
Merge
duke@435 | 1 | /* |
coleenp@4037 | 2 | * Copyright (c) 1999, 2012, Oracle and/or its affiliates. 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 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_C1_C1_RUNTIME1_HPP |
stefank@2314 | 26 | #define SHARE_VM_C1_C1_RUNTIME1_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "c1/c1_FrameMap.hpp" |
stefank@2314 | 29 | #include "code/stubs.hpp" |
stefank@2314 | 30 | #include "interpreter/interpreter.hpp" |
stefank@2314 | 31 | #include "memory/allocation.hpp" |
stefank@2314 | 32 | #include "runtime/deoptimization.hpp" |
stefank@2314 | 33 | |
duke@435 | 34 | class StubAssembler; |
duke@435 | 35 | |
duke@435 | 36 | // The Runtime1 holds all assembly stubs and VM |
duke@435 | 37 | // runtime routines needed by code code generated |
duke@435 | 38 | // by the Compiler1. |
duke@435 | 39 | |
duke@435 | 40 | #define RUNTIME1_STUBS(stub, last_entry) \ |
duke@435 | 41 | stub(dtrace_object_alloc) \ |
duke@435 | 42 | stub(unwind_exception) \ |
duke@435 | 43 | stub(forward_exception) \ |
duke@435 | 44 | stub(throw_range_check_failed) /* throws ArrayIndexOutOfBoundsException */ \ |
duke@435 | 45 | stub(throw_index_exception) /* throws IndexOutOfBoundsException */ \ |
duke@435 | 46 | stub(throw_div0_exception) \ |
duke@435 | 47 | stub(throw_null_pointer_exception) \ |
duke@435 | 48 | stub(register_finalizer) \ |
duke@435 | 49 | stub(new_instance) \ |
duke@435 | 50 | stub(fast_new_instance) \ |
duke@435 | 51 | stub(fast_new_instance_init_check) \ |
duke@435 | 52 | stub(new_type_array) \ |
duke@435 | 53 | stub(new_object_array) \ |
duke@435 | 54 | stub(new_multi_array) \ |
duke@435 | 55 | stub(handle_exception_nofpu) /* optimized version that does not preserve fpu registers */ \ |
duke@435 | 56 | stub(handle_exception) \ |
twisti@2603 | 57 | stub(handle_exception_from_callee) \ |
duke@435 | 58 | stub(throw_array_store_exception) \ |
duke@435 | 59 | stub(throw_class_cast_exception) \ |
duke@435 | 60 | stub(throw_incompatible_class_change_error) \ |
duke@435 | 61 | stub(slow_subtype_check) \ |
duke@435 | 62 | stub(monitorenter) \ |
duke@435 | 63 | stub(monitorenter_nofpu) /* optimized version that does not preserve fpu registers */ \ |
duke@435 | 64 | stub(monitorexit) \ |
duke@435 | 65 | stub(monitorexit_nofpu) /* optimized version that does not preserve fpu registers */ \ |
twisti@3244 | 66 | stub(deoptimize) \ |
duke@435 | 67 | stub(access_field_patching) \ |
duke@435 | 68 | stub(load_klass_patching) \ |
coleenp@4037 | 69 | stub(load_mirror_patching) \ |
roland@5628 | 70 | stub(load_appendix_patching) \ |
ysr@777 | 71 | stub(g1_pre_barrier_slow) \ |
ysr@777 | 72 | stub(g1_post_barrier_slow) \ |
duke@435 | 73 | stub(fpu2long_stub) \ |
duke@435 | 74 | stub(counter_overflow) \ |
roland@4860 | 75 | stub(predicate_failed_trap) \ |
duke@435 | 76 | last_entry(number_of_ids) |
duke@435 | 77 | |
duke@435 | 78 | #define DECLARE_STUB_ID(x) x ## _id , |
duke@435 | 79 | #define DECLARE_LAST_STUB_ID(x) x |
duke@435 | 80 | #define STUB_NAME(x) #x " Runtime1 stub", |
duke@435 | 81 | #define LAST_STUB_NAME(x) #x " Runtime1 stub" |
duke@435 | 82 | |
duke@435 | 83 | class Runtime1: public AllStatic { |
duke@435 | 84 | friend class VMStructs; |
duke@435 | 85 | friend class ArrayCopyStub; |
duke@435 | 86 | |
duke@435 | 87 | public: |
duke@435 | 88 | enum StubID { |
duke@435 | 89 | RUNTIME1_STUBS(DECLARE_STUB_ID, DECLARE_LAST_STUB_ID) |
duke@435 | 90 | }; |
duke@435 | 91 | |
duke@435 | 92 | // statistics |
duke@435 | 93 | #ifndef PRODUCT |
duke@435 | 94 | static int _resolve_invoke_cnt; |
duke@435 | 95 | static int _handle_wrong_method_cnt; |
duke@435 | 96 | static int _ic_miss_cnt; |
duke@435 | 97 | static int _generic_arraycopy_cnt; |
duke@435 | 98 | static int _primitive_arraycopy_cnt; |
duke@435 | 99 | static int _oop_arraycopy_cnt; |
roland@2728 | 100 | static int _generic_arraycopystub_cnt; |
duke@435 | 101 | static int _arraycopy_slowcase_cnt; |
roland@2728 | 102 | static int _arraycopy_checkcast_cnt; |
roland@2728 | 103 | static int _arraycopy_checkcast_attempt_cnt; |
duke@435 | 104 | static int _new_type_array_slowcase_cnt; |
duke@435 | 105 | static int _new_object_array_slowcase_cnt; |
duke@435 | 106 | static int _new_instance_slowcase_cnt; |
duke@435 | 107 | static int _new_multi_array_slowcase_cnt; |
duke@435 | 108 | static int _monitorenter_slowcase_cnt; |
duke@435 | 109 | static int _monitorexit_slowcase_cnt; |
duke@435 | 110 | static int _patch_code_slowcase_cnt; |
duke@435 | 111 | static int _throw_range_check_exception_count; |
duke@435 | 112 | static int _throw_index_exception_count; |
duke@435 | 113 | static int _throw_div0_exception_count; |
duke@435 | 114 | static int _throw_null_pointer_exception_count; |
duke@435 | 115 | static int _throw_class_cast_exception_count; |
duke@435 | 116 | static int _throw_incompatible_class_change_error_count; |
duke@435 | 117 | static int _throw_array_store_exception_count; |
duke@435 | 118 | static int _throw_count; |
duke@435 | 119 | #endif |
duke@435 | 120 | |
duke@435 | 121 | private: |
duke@435 | 122 | static CodeBlob* _blobs[number_of_ids]; |
duke@435 | 123 | static const char* _blob_names[]; |
duke@435 | 124 | |
duke@435 | 125 | // stub generation |
twisti@2603 | 126 | static void generate_blob_for(BufferBlob* blob, StubID id); |
twisti@2603 | 127 | static OopMapSet* generate_code_for(StubID id, StubAssembler* sasm); |
duke@435 | 128 | static OopMapSet* generate_exception_throw(StubAssembler* sasm, address target, bool has_argument); |
twisti@2603 | 129 | static OopMapSet* generate_handle_exception(StubID id, StubAssembler* sasm); |
twisti@2603 | 130 | static void generate_unwind_exception(StubAssembler *sasm); |
duke@435 | 131 | static OopMapSet* generate_patching(StubAssembler* sasm, address target); |
duke@435 | 132 | |
duke@435 | 133 | static OopMapSet* generate_stub_call(StubAssembler* sasm, Register result, address entry, |
duke@435 | 134 | Register arg1 = noreg, Register arg2 = noreg, Register arg3 = noreg); |
duke@435 | 135 | |
duke@435 | 136 | // runtime entry points |
coleenp@4037 | 137 | static void new_instance (JavaThread* thread, Klass* klass); |
coleenp@4037 | 138 | static void new_type_array (JavaThread* thread, Klass* klass, jint length); |
coleenp@4037 | 139 | static void new_object_array(JavaThread* thread, Klass* klass, jint length); |
coleenp@4037 | 140 | static void new_multi_array (JavaThread* thread, Klass* klass, int rank, jint* dims); |
duke@435 | 141 | |
coleenp@4037 | 142 | static address counter_overflow(JavaThread* thread, int bci, Method* method); |
duke@435 | 143 | |
duke@435 | 144 | static void unimplemented_entry (JavaThread* thread, StubID id); |
duke@435 | 145 | |
duke@435 | 146 | static address exception_handler_for_pc(JavaThread* thread); |
duke@435 | 147 | |
duke@435 | 148 | static void throw_range_check_exception(JavaThread* thread, int index); |
duke@435 | 149 | static void throw_index_exception(JavaThread* thread, int index); |
duke@435 | 150 | static void throw_div0_exception(JavaThread* thread); |
duke@435 | 151 | static void throw_null_pointer_exception(JavaThread* thread); |
never@2488 | 152 | static void throw_class_cast_exception(JavaThread* thread, oopDesc* object); |
duke@435 | 153 | static void throw_incompatible_class_change_error(JavaThread* thread); |
never@2488 | 154 | static void throw_array_store_exception(JavaThread* thread, oopDesc* object); |
duke@435 | 155 | |
duke@435 | 156 | static void monitorenter(JavaThread* thread, oopDesc* obj, BasicObjectLock* lock); |
duke@435 | 157 | static void monitorexit (JavaThread* thread, BasicObjectLock* lock); |
duke@435 | 158 | |
twisti@3244 | 159 | static void deoptimize(JavaThread* thread); |
twisti@3244 | 160 | |
duke@435 | 161 | static int access_field_patching(JavaThread* thread); |
duke@435 | 162 | static int move_klass_patching(JavaThread* thread); |
coleenp@4037 | 163 | static int move_mirror_patching(JavaThread* thread); |
roland@5628 | 164 | static int move_appendix_patching(JavaThread* thread); |
duke@435 | 165 | |
duke@435 | 166 | static void patch_code(JavaThread* thread, StubID stub_id); |
duke@435 | 167 | |
duke@435 | 168 | public: |
duke@435 | 169 | // initialization |
iveresov@1939 | 170 | static void initialize(BufferBlob* blob); |
duke@435 | 171 | static void initialize_pd(); |
duke@435 | 172 | |
duke@435 | 173 | // stubs |
duke@435 | 174 | static CodeBlob* blob_for (StubID id); |
twisti@2103 | 175 | static address entry_for(StubID id) { return blob_for(id)->code_begin(); } |
duke@435 | 176 | static const char* name_for (StubID id); |
duke@435 | 177 | static const char* name_for_address(address entry); |
duke@435 | 178 | |
bobv@2036 | 179 | // platform might add runtime names. |
bobv@2036 | 180 | static const char* pd_name_for_address(address entry); |
bobv@2036 | 181 | |
duke@435 | 182 | // method tracing |
duke@435 | 183 | static void trace_block_entry(jint block_id); |
duke@435 | 184 | |
duke@435 | 185 | #ifndef PRODUCT |
roland@2728 | 186 | static address throw_count_address() { return (address)&_throw_count; } |
roland@2728 | 187 | static address arraycopy_count_address(BasicType type); |
duke@435 | 188 | #endif |
duke@435 | 189 | |
duke@435 | 190 | // directly accessible leaf routine |
duke@435 | 191 | static int arraycopy(oopDesc* src, int src_pos, oopDesc* dst, int dst_pos, int length); |
duke@435 | 192 | static void primitive_arraycopy(HeapWord* src, HeapWord* dst, int length); |
duke@435 | 193 | static void oop_arraycopy(HeapWord* src, HeapWord* dst, int length); |
roland@3838 | 194 | static int is_instance_of(oopDesc* mirror, oopDesc* obj); |
duke@435 | 195 | |
roland@4860 | 196 | static void predicate_failed_trap(JavaThread* thread); |
roland@4860 | 197 | |
duke@435 | 198 | static void print_statistics() PRODUCT_RETURN; |
duke@435 | 199 | }; |
stefank@2314 | 200 | |
stefank@2314 | 201 | #endif // SHARE_VM_C1_C1_RUNTIME1_HPP |