aoqi@0: /* aoqi@0: * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_C1_C1_RUNTIME1_HPP aoqi@0: #define SHARE_VM_C1_C1_RUNTIME1_HPP aoqi@0: aoqi@0: #include "c1/c1_FrameMap.hpp" aoqi@0: #include "code/stubs.hpp" aoqi@0: #include "interpreter/interpreter.hpp" aoqi@0: #include "memory/allocation.hpp" aoqi@0: #include "runtime/deoptimization.hpp" aoqi@0: aoqi@0: class StubAssembler; aoqi@0: aoqi@0: // The Runtime1 holds all assembly stubs and VM aoqi@0: // runtime routines needed by code code generated aoqi@0: // by the Compiler1. aoqi@0: aoqi@0: #define RUNTIME1_STUBS(stub, last_entry) \ aoqi@0: stub(dtrace_object_alloc) \ aoqi@0: stub(unwind_exception) \ aoqi@0: stub(forward_exception) \ aoqi@0: stub(throw_range_check_failed) /* throws ArrayIndexOutOfBoundsException */ \ aoqi@0: stub(throw_index_exception) /* throws IndexOutOfBoundsException */ \ aoqi@0: stub(throw_div0_exception) \ aoqi@0: stub(throw_null_pointer_exception) \ aoqi@0: stub(register_finalizer) \ aoqi@0: stub(new_instance) \ aoqi@0: stub(fast_new_instance) \ aoqi@0: stub(fast_new_instance_init_check) \ aoqi@0: stub(new_type_array) \ aoqi@0: stub(new_object_array) \ aoqi@0: stub(new_multi_array) \ aoqi@0: stub(handle_exception_nofpu) /* optimized version that does not preserve fpu registers */ \ aoqi@0: stub(handle_exception) \ aoqi@0: stub(handle_exception_from_callee) \ aoqi@0: stub(throw_array_store_exception) \ aoqi@0: stub(throw_class_cast_exception) \ aoqi@0: stub(throw_incompatible_class_change_error) \ aoqi@0: stub(slow_subtype_check) \ aoqi@0: stub(monitorenter) \ aoqi@0: stub(monitorenter_nofpu) /* optimized version that does not preserve fpu registers */ \ aoqi@0: stub(monitorexit) \ aoqi@0: stub(monitorexit_nofpu) /* optimized version that does not preserve fpu registers */ \ aoqi@0: stub(deoptimize) \ aoqi@0: stub(access_field_patching) \ aoqi@0: stub(load_klass_patching) \ aoqi@0: stub(load_mirror_patching) \ aoqi@0: stub(load_appendix_patching) \ aoqi@0: stub(g1_pre_barrier_slow) \ aoqi@0: stub(g1_post_barrier_slow) \ aoqi@0: stub(fpu2long_stub) \ aoqi@0: stub(counter_overflow) \ aoqi@0: stub(predicate_failed_trap) \ aoqi@0: last_entry(number_of_ids) aoqi@0: aoqi@0: #define DECLARE_STUB_ID(x) x ## _id , aoqi@0: #define DECLARE_LAST_STUB_ID(x) x aoqi@0: #define STUB_NAME(x) #x " Runtime1 stub", aoqi@0: #define LAST_STUB_NAME(x) #x " Runtime1 stub" aoqi@0: aoqi@0: class Runtime1: public AllStatic { aoqi@0: friend class VMStructs; aoqi@0: friend class ArrayCopyStub; aoqi@0: aoqi@0: public: aoqi@0: enum StubID { aoqi@0: RUNTIME1_STUBS(DECLARE_STUB_ID, DECLARE_LAST_STUB_ID) aoqi@0: }; aoqi@0: aoqi@0: // statistics aoqi@0: #ifndef PRODUCT aoqi@0: static int _resolve_invoke_cnt; aoqi@0: static int _handle_wrong_method_cnt; aoqi@0: static int _ic_miss_cnt; aoqi@0: static int _generic_arraycopy_cnt; aoqi@0: static int _primitive_arraycopy_cnt; aoqi@0: static int _oop_arraycopy_cnt; aoqi@0: static int _generic_arraycopystub_cnt; aoqi@0: static int _arraycopy_slowcase_cnt; aoqi@0: static int _arraycopy_checkcast_cnt; aoqi@0: static int _arraycopy_checkcast_attempt_cnt; aoqi@0: static int _new_type_array_slowcase_cnt; aoqi@0: static int _new_object_array_slowcase_cnt; aoqi@0: static int _new_instance_slowcase_cnt; aoqi@0: static int _new_multi_array_slowcase_cnt; aoqi@0: static int _monitorenter_slowcase_cnt; aoqi@0: static int _monitorexit_slowcase_cnt; aoqi@0: static int _patch_code_slowcase_cnt; aoqi@0: static int _throw_range_check_exception_count; aoqi@0: static int _throw_index_exception_count; aoqi@0: static int _throw_div0_exception_count; aoqi@0: static int _throw_null_pointer_exception_count; aoqi@0: static int _throw_class_cast_exception_count; aoqi@0: static int _throw_incompatible_class_change_error_count; aoqi@0: static int _throw_array_store_exception_count; aoqi@0: static int _throw_count; aoqi@0: #endif aoqi@0: aoqi@0: private: aoqi@0: static CodeBlob* _blobs[number_of_ids]; aoqi@0: static const char* _blob_names[]; aoqi@0: aoqi@0: // stub generation aoqi@0: static void generate_blob_for(BufferBlob* blob, StubID id); aoqi@0: static OopMapSet* generate_code_for(StubID id, StubAssembler* sasm); aoqi@0: static OopMapSet* generate_exception_throw(StubAssembler* sasm, address target, bool has_argument); aoqi@0: static OopMapSet* generate_handle_exception(StubID id, StubAssembler* sasm); aoqi@0: static void generate_unwind_exception(StubAssembler *sasm); aoqi@0: static OopMapSet* generate_patching(StubAssembler* sasm, address target); aoqi@0: aoqi@0: static OopMapSet* generate_stub_call(StubAssembler* sasm, Register result, address entry, aoqi@0: Register arg1 = noreg, Register arg2 = noreg, Register arg3 = noreg); aoqi@0: aoqi@0: // runtime entry points aoqi@0: static void new_instance (JavaThread* thread, Klass* klass); aoqi@0: static void new_type_array (JavaThread* thread, Klass* klass, jint length); aoqi@0: static void new_object_array(JavaThread* thread, Klass* klass, jint length); aoqi@0: static void new_multi_array (JavaThread* thread, Klass* klass, int rank, jint* dims); aoqi@0: aoqi@0: static address counter_overflow(JavaThread* thread, int bci, Method* method); aoqi@0: aoqi@0: static void unimplemented_entry (JavaThread* thread, StubID id); aoqi@0: aoqi@0: static address exception_handler_for_pc(JavaThread* thread); aoqi@0: aoqi@0: static void throw_range_check_exception(JavaThread* thread, int index); aoqi@0: static void throw_index_exception(JavaThread* thread, int index); aoqi@0: static void throw_div0_exception(JavaThread* thread); aoqi@0: static void throw_null_pointer_exception(JavaThread* thread); aoqi@0: static void throw_class_cast_exception(JavaThread* thread, oopDesc* object); aoqi@0: static void throw_incompatible_class_change_error(JavaThread* thread); aoqi@0: static void throw_array_store_exception(JavaThread* thread, oopDesc* object); aoqi@0: aoqi@0: static void monitorenter(JavaThread* thread, oopDesc* obj, BasicObjectLock* lock); aoqi@0: static void monitorexit (JavaThread* thread, BasicObjectLock* lock); aoqi@0: aoqi@0: static void deoptimize(JavaThread* thread); aoqi@0: aoqi@0: static int access_field_patching(JavaThread* thread); aoqi@0: static int move_klass_patching(JavaThread* thread); aoqi@0: static int move_mirror_patching(JavaThread* thread); aoqi@0: static int move_appendix_patching(JavaThread* thread); aoqi@0: aoqi@0: static void patch_code(JavaThread* thread, StubID stub_id); aoqi@0: aoqi@0: public: aoqi@0: // initialization aoqi@0: static void initialize(BufferBlob* blob); aoqi@0: static void initialize_pd(); aoqi@0: aoqi@0: // stubs aoqi@0: static CodeBlob* blob_for (StubID id); aoqi@0: static address entry_for(StubID id) { return blob_for(id)->code_begin(); } aoqi@0: static const char* name_for (StubID id); aoqi@0: static const char* name_for_address(address entry); aoqi@0: aoqi@0: // platform might add runtime names. aoqi@0: static const char* pd_name_for_address(address entry); aoqi@0: aoqi@0: // method tracing aoqi@0: static void trace_block_entry(jint block_id); aoqi@0: aoqi@0: #ifndef PRODUCT aoqi@0: static address throw_count_address() { return (address)&_throw_count; } aoqi@0: static address arraycopy_count_address(BasicType type); aoqi@0: #endif aoqi@0: aoqi@0: // directly accessible leaf routine aoqi@0: static int arraycopy(oopDesc* src, int src_pos, oopDesc* dst, int dst_pos, int length); aoqi@0: static void primitive_arraycopy(HeapWord* src, HeapWord* dst, int length); aoqi@0: static void oop_arraycopy(HeapWord* src, HeapWord* dst, int length); aoqi@0: static int is_instance_of(oopDesc* mirror, oopDesc* obj); aoqi@0: aoqi@0: static void predicate_failed_trap(JavaThread* thread); aoqi@0: aoqi@0: static void print_statistics() PRODUCT_RETURN; aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_C1_C1_RUNTIME1_HPP