Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/interpreter/interpreterRuntime.hpp
32285 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_INTERPRETER_INTERPRETERRUNTIME_HPP25#define SHARE_VM_INTERPRETER_INTERPRETERRUNTIME_HPP2627#include "interpreter/bytecode.hpp"28#include "interpreter/linkResolver.hpp"29#include "memory/universe.hpp"30#include "oops/method.hpp"31#include "runtime/frame.inline.hpp"32#include "runtime/signature.hpp"33#include "runtime/thread.inline.hpp"34#include "utilities/top.hpp"3536// The InterpreterRuntime is called by the interpreter for everything37// that cannot/should not be dealt with in assembly and needs C support.3839class InterpreterRuntime: AllStatic {40friend class BytecodeClosure; // for method and bcp41friend class PrintingClosure; // for method and bcp4243private:44// Helper functions to access current interpreter state45static frame last_frame(JavaThread *thread) { return thread->last_frame(); }46static Method* method(JavaThread *thread) { return last_frame(thread).interpreter_frame_method(); }47static address bcp(JavaThread *thread) { return last_frame(thread).interpreter_frame_bcp(); }48static int bci(JavaThread *thread) { return last_frame(thread).interpreter_frame_bci(); }49static void set_bcp_and_mdp(address bcp, JavaThread*thread);50static Bytecodes::Code code(JavaThread *thread) {51// pass method to avoid calling unsafe bcp_to_method (partial fix 4926272)52return Bytecodes::code_at(method(thread), bcp(thread));53}54static bool already_resolved(JavaThread *thread) { return cache_entry(thread)->is_resolved(code(thread)); }55static Bytecode bytecode(JavaThread *thread) { return Bytecode(method(thread), bcp(thread)); }56static int get_index_u1(JavaThread *thread, Bytecodes::Code bc)57{ return bytecode(thread).get_index_u1(bc); }58static int get_index_u2(JavaThread *thread, Bytecodes::Code bc)59{ return bytecode(thread).get_index_u2(bc); }60static int get_index_u2_cpcache(JavaThread *thread, Bytecodes::Code bc)61{ return bytecode(thread).get_index_u2_cpcache(bc); }62static int get_index_u4(JavaThread *thread, Bytecodes::Code bc)63{ return bytecode(thread).get_index_u4(bc); }64static int number_of_dimensions(JavaThread *thread) { return bcp(thread)[3]; }6566static ConstantPoolCacheEntry* cache_entry_at(JavaThread *thread, int i) { return method(thread)->constants()->cache()->entry_at(i); }67static ConstantPoolCacheEntry* cache_entry(JavaThread *thread) { return cache_entry_at(thread, Bytes::get_native_u2(bcp(thread) + 1)); }68static void note_trap_inner(JavaThread* thread, int reason,69methodHandle trap_method, int trap_bci, TRAPS);70static void note_trap(JavaThread *thread, int reason, TRAPS);71#ifdef CC_INTERP72// Profile traps in C++ interpreter.73static void note_trap(JavaThread* thread, int reason, Method *method, int trap_bci);74#endif // CC_INTERP7576// Inner work method for Interpreter's frequency counter overflow.77static nmethod* frequency_counter_overflow_inner(JavaThread* thread, address branch_bcp);7879public:80// Constants81static void ldc (JavaThread* thread, bool wide);82static void resolve_ldc (JavaThread* thread, Bytecodes::Code bytecode);8384// Allocation85static void _new (JavaThread* thread, ConstantPool* pool, int index);86static void newarray (JavaThread* thread, BasicType type, jint size);87static void anewarray (JavaThread* thread, ConstantPool* pool, int index, jint size);88static void multianewarray(JavaThread* thread, jint* first_size_address);89static void register_finalizer(JavaThread* thread, oopDesc* obj);9091// Quicken instance-of and check-cast bytecodes92static void quicken_io_cc(JavaThread* thread);9394// Exceptions thrown by the interpreter95static void throw_AbstractMethodError(JavaThread* thread);96static void throw_IncompatibleClassChangeError(JavaThread* thread);97static void throw_StackOverflowError(JavaThread* thread);98static void throw_ArrayIndexOutOfBoundsException(JavaThread* thread, char* name, jint index);99static void throw_ClassCastException(JavaThread* thread, oopDesc* obj);100static void create_exception(JavaThread* thread, char* name, char* message);101static void create_klass_exception(JavaThread* thread, char* name, oopDesc* obj);102static address exception_handler_for_exception(JavaThread* thread, oopDesc* exception);103#if INCLUDE_JVMTI104static void member_name_arg_or_null(JavaThread* thread, address dmh, Method* m, address bcp);105#endif106static void throw_pending_exception(JavaThread* thread);107108#ifdef CC_INTERP109// Profile traps in C++ interpreter.110static void note_nullCheck_trap (JavaThread* thread, Method *method, int trap_bci);111static void note_div0Check_trap (JavaThread* thread, Method *method, int trap_bci);112static void note_rangeCheck_trap(JavaThread* thread, Method *method, int trap_bci);113static void note_classCheck_trap(JavaThread* thread, Method *method, int trap_bci);114static void note_arrayCheck_trap(JavaThread* thread, Method *method, int trap_bci);115// A dummy for makros that shall not profile traps.116static void note_no_trap(JavaThread* thread, Method *method, int trap_bci) {}117#endif // CC_INTERP118119// Statics & fields120static void resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode);121122// Synchronization123static void monitorenter(JavaThread* thread, BasicObjectLock* elem);124static void monitorexit (JavaThread* thread, BasicObjectLock* elem);125126static void throw_illegal_monitor_state_exception(JavaThread* thread);127static void new_illegal_monitor_state_exception(JavaThread* thread);128129// Calls130static void resolve_invoke (JavaThread* thread, Bytecodes::Code bytecode);131static void resolve_invokehandle (JavaThread* thread);132static void resolve_invokedynamic(JavaThread* thread);133134// Breakpoints135static void _breakpoint(JavaThread* thread, Method* method, address bcp);136static Bytecodes::Code get_original_bytecode_at(JavaThread* thread, Method* method, address bcp);137static void set_original_bytecode_at(JavaThread* thread, Method* method, address bcp, Bytecodes::Code new_code);138static bool is_breakpoint(JavaThread *thread) { return Bytecodes::code_or_bp_at(bcp(thread)) == Bytecodes::_breakpoint; }139140// Safepoints141static void at_safepoint(JavaThread* thread);142143// Debugger support144static void post_field_access(JavaThread *thread, oopDesc* obj,145ConstantPoolCacheEntry *cp_entry);146static void post_field_modification(JavaThread *thread, oopDesc* obj,147ConstantPoolCacheEntry *cp_entry, jvalue *value);148static void post_method_entry(JavaThread *thread);149static void post_method_exit (JavaThread *thread);150static int interpreter_contains(address pc);151152// Native signature handlers153static void prepare_native_call(JavaThread* thread, Method* method);154static address slow_signature_handler(JavaThread* thread,155Method* method,156intptr_t* from, intptr_t* to);157158#if defined(IA32) || defined(AMD64) || defined(ARM) || defined(AARCH64)159// Popframe support (only needed on x86, AMD64 and ARM)160static void popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address);161#endif162163// Platform dependent stuff164#ifdef TARGET_ARCH_x86165# include "interpreterRT_x86.hpp"166#endif167#ifdef TARGET_ARCH_aarch32168# include "interpreterRT_aarch32.hpp"169#endif170#ifdef TARGET_ARCH_aarch64171# include "interpreterRT_aarch64.hpp"172#endif173#ifdef TARGET_ARCH_sparc174# include "interpreterRT_sparc.hpp"175#endif176#ifdef TARGET_ARCH_zero177# include "interpreterRT_zero.hpp"178#endif179#ifdef TARGET_ARCH_arm180# include "interpreterRT_arm.hpp"181#endif182#ifdef TARGET_ARCH_ppc183# include "interpreterRT_ppc.hpp"184#endif185186187// Interpreter's frequency counter overflow188static nmethod* frequency_counter_overflow(JavaThread* thread, address branch_bcp);189190// Interpreter profiling support191static jint bcp_to_di(Method* method, address cur_bcp);192static void profile_method(JavaThread* thread);193static void update_mdp_for_ret(JavaThread* thread, int bci);194#ifdef ASSERT195static void verify_mdp(Method* method, address bcp, address mdp);196#endif // ASSERT197static MethodCounters* build_method_counters(JavaThread* thread, Method* m);198};199200201class SignatureHandlerLibrary: public AllStatic {202public:203enum { buffer_size = 1*K }; // the size of the temporary code buffer204enum { blob_size = 32*K }; // the size of a handler code blob.205206private:207static BufferBlob* _handler_blob; // the current buffer blob containing the generated handlers208static address _handler; // next available address within _handler_blob;209static GrowableArray<uint64_t>* _fingerprints; // the fingerprint collection210static GrowableArray<address>* _handlers; // the corresponding handlers211static address _buffer; // the temporary code buffer212213static address set_handler_blob();214static void initialize();215static address set_handler(CodeBuffer* buffer);216static void pd_set_handler(address handler);217218public:219static void add(methodHandle method);220};221222#endif // SHARE_VM_INTERPRETER_INTERPRETERRUNTIME_HPP223224225