interpreterRuntime.hpp revision 2073
0N/A/*
2027N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_INTERPRETER_INTERPRETERRUNTIME_HPP
1879N/A#define SHARE_VM_INTERPRETER_INTERPRETERRUNTIME_HPP
1879N/A
1879N/A#include "interpreter/bytecode.hpp"
1879N/A#include "interpreter/linkResolver.hpp"
1879N/A#include "memory/universe.hpp"
1879N/A#include "oops/methodOop.hpp"
1879N/A#include "runtime/frame.inline.hpp"
1879N/A#include "runtime/signature.hpp"
1879N/A#include "utilities/top.hpp"
1879N/A#ifdef TARGET_OS_FAMILY_linux
1879N/A# include "thread_linux.inline.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_OS_FAMILY_solaris
1879N/A# include "thread_solaris.inline.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_OS_FAMILY_windows
1879N/A# include "thread_windows.inline.hpp"
1879N/A#endif
1879N/A
0N/A// The InterpreterRuntime is called by the interpreter for everything
0N/A// that cannot/should not be dealt with in assembly and needs C support.
0N/A
0N/Aclass InterpreterRuntime: AllStatic {
0N/A friend class BytecodeClosure; // for method and bcp
0N/A friend class PrintingClosure; // for method and bcp
0N/A
0N/A private:
0N/A // Helper functions to access current interpreter state
0N/A static frame last_frame(JavaThread *thread) { return thread->last_frame(); }
0N/A static methodOop method(JavaThread *thread) { return last_frame(thread).interpreter_frame_method(); }
0N/A static address bcp(JavaThread *thread) { return last_frame(thread).interpreter_frame_bcp(); }
1522N/A static int bci(JavaThread *thread) { return last_frame(thread).interpreter_frame_bci(); }
0N/A static void set_bcp_and_mdp(address bcp, JavaThread*thread);
113N/A static Bytecodes::Code code(JavaThread *thread) {
113N/A // pass method to avoid calling unsafe bcp_to_method (partial fix 4926272)
2027N/A return Bytecodes::code_at(method(thread), bcp(thread));
113N/A }
0N/A static bool already_resolved(JavaThread *thread) { return cache_entry(thread)->is_resolved(code(thread)); }
2027N/A static Bytecode bytecode(JavaThread *thread) { return Bytecode(method(thread), bcp(thread)); }
1485N/A static int get_index_u1(JavaThread *thread, Bytecodes::Code bc)
2027N/A { return bytecode(thread).get_index_u1(bc); }
1485N/A static int get_index_u2(JavaThread *thread, Bytecodes::Code bc)
2027N/A { return bytecode(thread).get_index_u2(bc); }
1485N/A static int get_index_u2_cpcache(JavaThread *thread, Bytecodes::Code bc)
2027N/A { return bytecode(thread).get_index_u2_cpcache(bc); }
0N/A static int number_of_dimensions(JavaThread *thread) { return bcp(thread)[3]; }
726N/A
726N/A static ConstantPoolCacheEntry* cache_entry_at(JavaThread *thread, int i) { return method(thread)->constants()->cache()->entry_at(i); }
726N/A static ConstantPoolCacheEntry* cache_entry(JavaThread *thread) { return cache_entry_at(thread, Bytes::get_native_u2(bcp(thread) + 1)); }
0N/A static void note_trap(JavaThread *thread, int reason, TRAPS);
0N/A
941N/A // Inner work method for Interpreter's frequency counter overflow
941N/A static nmethod* frequency_counter_overflow_inner(JavaThread* thread, address branch_bcp);
941N/A
0N/A public:
0N/A // Constants
0N/A static void ldc (JavaThread* thread, bool wide);
1522N/A static void resolve_ldc (JavaThread* thread, Bytecodes::Code bytecode);
0N/A
0N/A // Allocation
0N/A static void _new (JavaThread* thread, constantPoolOopDesc* pool, int index);
0N/A static void newarray (JavaThread* thread, BasicType type, jint size);
0N/A static void anewarray (JavaThread* thread, constantPoolOopDesc* pool, int index, jint size);
0N/A static void multianewarray(JavaThread* thread, jint* first_size_address);
0N/A static void register_finalizer(JavaThread* thread, oopDesc* obj);
0N/A
0N/A // Quicken instance-of and check-cast bytecodes
0N/A static void quicken_io_cc(JavaThread* thread);
0N/A
0N/A // Exceptions thrown by the interpreter
0N/A static void throw_AbstractMethodError(JavaThread* thread);
0N/A static void throw_IncompatibleClassChangeError(JavaThread* thread);
0N/A static void throw_StackOverflowError(JavaThread* thread);
0N/A static void throw_ArrayIndexOutOfBoundsException(JavaThread* thread, char* name, jint index);
0N/A static void throw_ClassCastException(JavaThread* thread, oopDesc* obj);
710N/A static void throw_WrongMethodTypeException(JavaThread* thread, oopDesc* mtype = NULL, oopDesc* mhandle = NULL);
0N/A static void create_exception(JavaThread* thread, char* name, char* message);
0N/A static void create_klass_exception(JavaThread* thread, char* name, oopDesc* obj);
0N/A static address exception_handler_for_exception(JavaThread* thread, oopDesc* exception);
0N/A static void throw_pending_exception(JavaThread* thread);
0N/A
0N/A // Statics & fields
0N/A static void resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode);
0N/A
0N/A // Synchronization
0N/A static void monitorenter(JavaThread* thread, BasicObjectLock* elem);
0N/A static void monitorexit (JavaThread* thread, BasicObjectLock* elem);
0N/A
0N/A static void throw_illegal_monitor_state_exception(JavaThread* thread);
0N/A static void new_illegal_monitor_state_exception(JavaThread* thread);
0N/A
0N/A // Calls
726N/A static void resolve_invoke (JavaThread* thread, Bytecodes::Code bytecode);
726N/A static void resolve_invokedynamic(JavaThread* thread);
0N/A
0N/A // Breakpoints
0N/A static void _breakpoint(JavaThread* thread, methodOopDesc* method, address bcp);
0N/A static Bytecodes::Code get_original_bytecode_at(JavaThread* thread, methodOopDesc* method, address bcp);
0N/A static void set_original_bytecode_at(JavaThread* thread, methodOopDesc* method, address bcp, Bytecodes::Code new_code);
0N/A static bool is_breakpoint(JavaThread *thread) { return Bytecodes::code_or_bp_at(bcp(thread)) == Bytecodes::_breakpoint; }
0N/A
0N/A // Safepoints
0N/A static void at_safepoint(JavaThread* thread);
0N/A
0N/A // Debugger support
0N/A static void post_field_access(JavaThread *thread, oopDesc* obj,
0N/A ConstantPoolCacheEntry *cp_entry);
0N/A static void post_field_modification(JavaThread *thread, oopDesc* obj,
0N/A ConstantPoolCacheEntry *cp_entry, jvalue *value);
0N/A static void post_method_entry(JavaThread *thread);
0N/A static void post_method_exit (JavaThread *thread);
0N/A static int interpreter_contains(address pc);
0N/A
0N/A // Native signature handlers
0N/A static void prepare_native_call(JavaThread* thread, methodOopDesc* method);
0N/A static address slow_signature_handler(JavaThread* thread,
0N/A methodOopDesc* method,
0N/A intptr_t* from, intptr_t* to);
0N/A
0N/A#if defined(IA32) || defined(AMD64)
0N/A // Popframe support (only needed on x86 and AMD64)
0N/A static void popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address);
0N/A#endif
0N/A
0N/A // Platform dependent stuff
1879N/A#ifdef TARGET_ARCH_x86
1879N/A# include "interpreterRT_x86.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_sparc
1879N/A# include "interpreterRT_sparc.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_zero
1879N/A# include "interpreterRT_zero.hpp"
1879N/A#endif
2073N/A#ifdef TARGET_ARCH_arm
2073N/A# include "interpreterRT_arm.hpp"
2073N/A#endif
2073N/A#ifdef TARGET_ARCH_ppc
2073N/A# include "interpreterRT_ppc.hpp"
2073N/A#endif
1879N/A
0N/A
0N/A // Interpreter's frequency counter overflow
0N/A static nmethod* frequency_counter_overflow(JavaThread* thread, address branch_bcp);
0N/A
0N/A // Interpreter profiling support
0N/A static jint bcp_to_di(methodOopDesc* method, address cur_bcp);
2003N/A static void profile_method(JavaThread* thread);
0N/A static void update_mdp_for_ret(JavaThread* thread, int bci);
0N/A#ifdef ASSERT
0N/A static void verify_mdp(methodOopDesc* method, address bcp, address mdp);
0N/A#endif // ASSERT
0N/A};
0N/A
0N/A
0N/Aclass SignatureHandlerLibrary: public AllStatic {
0N/A public:
0N/A enum { buffer_size = 1*K }; // the size of the temporary code buffer
0N/A enum { blob_size = 32*K }; // the size of a handler code blob.
0N/A
0N/A private:
0N/A static BufferBlob* _handler_blob; // the current buffer blob containing the generated handlers
0N/A static address _handler; // next available address within _handler_blob;
0N/A static GrowableArray<uint64_t>* _fingerprints; // the fingerprint collection
0N/A static GrowableArray<address>* _handlers; // the corresponding handlers
0N/A static address _buffer; // the temporary code buffer
0N/A
0N/A static address set_handler_blob();
0N/A static void initialize();
0N/A static address set_handler(CodeBuffer* buffer);
0N/A static void pd_set_handler(address handler);
0N/A
0N/A public:
0N/A static void add(methodHandle method);
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_INTERPRETER_INTERPRETERRUNTIME_HPP