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