Path: blob/master/src/hotspot/share/interpreter/interpreterRuntime.hpp
40949 views
/*1* Copyright (c) 1997, 2021, 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_INTERPRETER_INTERPRETERRUNTIME_HPP25#define SHARE_INTERPRETER_INTERPRETERRUNTIME_HPP2627#include "interpreter/bytecode.hpp"28#include "interpreter/linkResolver.hpp"29#include "oops/method.hpp"30#include "runtime/frame.hpp"31#include "runtime/signature.hpp"32#include "runtime/thread.hpp"33#include "utilities/macros.hpp"3435class BufferBlob;36class CodeBuffer;3738// The InterpreterRuntime is called by the interpreter for everything39// that cannot/should not be dealt with in assembly and needs C support.4041class InterpreterRuntime: AllStatic {42friend class BytecodeClosure; // for method and bcp43friend class PrintingClosure; // for method and bcp4445private:4647static void set_bcp_and_mdp(address bcp, JavaThread* current);48static void note_trap_inner(JavaThread* current, int reason,49const methodHandle& trap_method, int trap_bci);50static void note_trap(JavaThread* current, int reason);5152// Inner work method for Interpreter's frequency counter overflow.53static nmethod* frequency_counter_overflow_inner(JavaThread* current, address branch_bcp);5455public:56// Constants57static void ldc (JavaThread* current, bool wide);58static void resolve_ldc (JavaThread* current, Bytecodes::Code bytecode);5960// Allocation61static void _new (JavaThread* current, ConstantPool* pool, int index);62static void newarray (JavaThread* current, BasicType type, jint size);63static void anewarray (JavaThread* current, ConstantPool* pool, int index, jint size);64static void multianewarray(JavaThread* current, jint* first_size_address);65static void register_finalizer(JavaThread* current, oopDesc* obj);6667// Quicken instance-of and check-cast bytecodes68static void quicken_io_cc(JavaThread* current);6970// Exceptions thrown by the interpreter71static void throw_AbstractMethodError(JavaThread* current);72static void throw_AbstractMethodErrorWithMethod(JavaThread* current, Method* oop);73static void throw_AbstractMethodErrorVerbose(JavaThread* current,74Klass* recvKlass,75Method* missingMethod);7677static void throw_IncompatibleClassChangeError(JavaThread* current);78static void throw_IncompatibleClassChangeErrorVerbose(JavaThread* current,79Klass* resc,80Klass* interfaceKlass);81static void throw_StackOverflowError(JavaThread* current);82static void throw_delayed_StackOverflowError(JavaThread* current);83static void throw_ArrayIndexOutOfBoundsException(JavaThread* current, arrayOopDesc* a, jint index);84static void throw_ClassCastException(JavaThread* current, oopDesc* obj);85static void throw_NullPointerException(JavaThread* current);8687static void create_exception(JavaThread* current, char* name, char* message);88static void create_klass_exception(JavaThread* current, char* name, oopDesc* obj);89static address exception_handler_for_exception(JavaThread* current, oopDesc* exception);90#if INCLUDE_JVMTI91static void member_name_arg_or_null(JavaThread* current, address dmh, Method* m, address bcp);92#endif93static void throw_pending_exception(JavaThread* current);9495static void resolve_from_cache(JavaThread* current, Bytecodes::Code bytecode);96private:97// Statics & fields98static void resolve_get_put(JavaThread* current, Bytecodes::Code bytecode);99100// Calls101static void resolve_invoke(JavaThread* current, Bytecodes::Code bytecode);102static void resolve_invokehandle (JavaThread* current);103static void resolve_invokedynamic(JavaThread* current);104105public:106// Synchronization107static void monitorenter(JavaThread* current, BasicObjectLock* elem);108static void monitorexit (BasicObjectLock* elem);109110static void throw_illegal_monitor_state_exception(JavaThread* current);111static void new_illegal_monitor_state_exception(JavaThread* current);112113// Breakpoints114static void _breakpoint(JavaThread* current, Method* method, address bcp);115static Bytecodes::Code get_original_bytecode_at(JavaThread* current, Method* method, address bcp);116static void set_original_bytecode_at(JavaThread* current, Method* method, address bcp, Bytecodes::Code new_code);117118// Safepoints119static void at_safepoint(JavaThread* current);120static void at_unwind(JavaThread* current);121122// Debugger support123static void post_field_access(JavaThread* current, oopDesc* obj,124ConstantPoolCacheEntry *cp_entry);125static void post_field_modification(JavaThread* current, oopDesc* obj,126ConstantPoolCacheEntry *cp_entry, jvalue *value);127static void post_method_entry(JavaThread* current);128static void post_method_exit (JavaThread* current);129static int interpreter_contains(address pc);130131// Native signature handlers132static void prepare_native_call(JavaThread* current, Method* method);133static address slow_signature_handler(JavaThread* current,134Method* method,135intptr_t* from, intptr_t* to);136137#if defined(IA32) || defined(AMD64) || defined(ARM)138// Popframe support (only needed on x86, AMD64 and ARM)139static void popframe_move_outgoing_args(JavaThread* current, void* src_address, void* dest_address);140#endif141142// bytecode tracing is only used by the TraceBytecodes143static intptr_t trace_bytecode(JavaThread* current, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2) PRODUCT_RETURN0;144145// Platform dependent stuff146#include CPU_HEADER(interpreterRT)147148// optional normalization of fingerprints to reduce the number of adapters149static uint64_t normalize_fast_native_fingerprint(uint64_t fingerprint);150151// Interpreter's frequency counter overflow152static nmethod* frequency_counter_overflow(JavaThread* current, address branch_bcp);153154// Interpreter profiling support155static jint bcp_to_di(Method* method, address cur_bcp);156static void update_mdp_for_ret(JavaThread* current, int bci);157#ifdef ASSERT158static void verify_mdp(Method* method, address bcp, address mdp);159#endif // ASSERT160static MethodCounters* build_method_counters(JavaThread* current, Method* m);161};162163164class SignatureHandlerLibrary: public AllStatic {165public:166enum { buffer_size = 1*K }; // the size of the temporary code buffer167enum { blob_size = 32*K }; // the size of a handler code blob.168169private:170static BufferBlob* _handler_blob; // the current buffer blob containing the generated handlers171static address _handler; // next available address within _handler_blob;172static GrowableArray<uint64_t>* _fingerprints; // the fingerprint collection173static GrowableArray<address>* _handlers; // the corresponding handlers174static address _buffer; // the temporary code buffer175176static address set_handler_blob();177static void initialize();178static address set_handler(CodeBuffer* buffer);179static void pd_set_handler(address handler);180181public:182static void add(const methodHandle& method);183static void add(uint64_t fingerprint, address handler);184};185186#endif // SHARE_INTERPRETER_INTERPRETERRUNTIME_HPP187188189