Path: blob/master/src/hotspot/share/interpreter/templateInterpreter.hpp
40949 views
/*1* Copyright (c) 1997, 2020, 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_TEMPLATEINTERPRETER_HPP25#define SHARE_INTERPRETER_TEMPLATEINTERPRETER_HPP2627#include "interpreter/abstractInterpreter.hpp"28#include "interpreter/templateTable.hpp"2930// This file contains the platform-independent parts31// of the template interpreter and the template interpreter generator.3233#ifndef ZERO3435class InterpreterMacroAssembler;36class InterpreterCodelet;3738//------------------------------------------------------------------------------------------------------------------------39// A little wrapper class to group tosca-specific entry points into a unit.40// (tosca = Top-Of-Stack CAche)4142class EntryPoint {43private:44address _entry[number_of_states];4546public:47// Construction48EntryPoint();49EntryPoint(address bentry, address zentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry);50// Will use the ientry for each of [bzcs]entry51EntryPoint(address aentry, address ientry, address lentry, address fentry, address dentry, address ventry);52// Attributes53address entry(TosState state) const; // return target address for a given tosca state54void set_entry(TosState state, address entry); // set target address for a given tosca state55void print();5657// Comparison58bool operator == (const EntryPoint& y); // for debugging only59};606162//------------------------------------------------------------------------------------------------------------------------63// A little wrapper class to group tosca-specific dispatch tables into a unit.6465class DispatchTable {66public:67enum { length = 1 << BitsPerByte }; // an entry point for each byte value (also for undefined bytecodes)6869private:70address _table[number_of_states][length]; // dispatch tables, indexed by tosca and bytecode7172public:73// Attributes74EntryPoint entry(int i) const; // return entry point for a given bytecode i75void set_entry(int i, EntryPoint& entry); // set entry point for a given bytecode i76address* table_for(TosState state) { return _table[state]; }77address* table_for() { return table_for((TosState)0); }78int distance_from(address *table) { return table - table_for(); }79int distance_from(TosState state) { return distance_from(table_for(state)); }8081// Comparison82bool operator == (DispatchTable& y); // for debugging only83};8485class TemplateInterpreter: public AbstractInterpreter {86friend class VMStructs;87friend class InterpreterMacroAssembler;88friend class TemplateInterpreterGenerator;89friend class TemplateTable;90friend class CodeCacheExtensions;91// friend class Interpreter;92public:9394enum MoreConstants {95max_invoke_length = 5, // invokedynamic is the longest96max_bytecode_length = 6, // worse case is wide iinc, "reexecute" bytecodes are excluded because "skip" will be 097number_of_return_entries = max_invoke_length + 1, // number of return entry points98number_of_deopt_entries = max_bytecode_length + 1, // number of deoptimization entry points99number_of_return_addrs = number_of_states // number of return addresses100};101102protected:103104static address _throw_ArrayIndexOutOfBoundsException_entry;105static address _throw_ArrayStoreException_entry;106static address _throw_ArithmeticException_entry;107static address _throw_ClassCastException_entry;108static address _throw_NullPointerException_entry;109static address _throw_exception_entry;110111static address _throw_StackOverflowError_entry;112113static address _remove_activation_entry; // continuation address if an exception is not handled by current frame114static address _remove_activation_preserving_args_entry; // continuation address when current frame is being popped115116#ifndef PRODUCT117static EntryPoint _trace_code;118#endif // !PRODUCT119static EntryPoint _return_entry[number_of_return_entries]; // entry points to return to from a call120static EntryPoint _earlyret_entry; // entry point to return early from a call121static EntryPoint _deopt_entry[number_of_deopt_entries]; // entry points to return to from a deoptimization122static address _deopt_reexecute_return_entry;123static EntryPoint _safept_entry;124125static address _invoke_return_entry[number_of_return_addrs]; // for invokestatic, invokespecial, invokevirtual return entries126static address _invokeinterface_return_entry[number_of_return_addrs]; // for invokeinterface return entries127static address _invokedynamic_return_entry[number_of_return_addrs]; // for invokedynamic return entries128129static DispatchTable _active_table; // the active dispatch table (used by the interpreter for dispatch)130static DispatchTable _normal_table; // the normal dispatch table (used to set the active table in normal mode)131static DispatchTable _safept_table; // the safepoint dispatch table (used to set the active table for safepoints)132static address _wentry_point[DispatchTable::length]; // wide instructions only (vtos tosca always)133134135public:136// Initialization/debugging137static void initialize_stub();138static void initialize_code();139// this only returns whether a pc is within generated code for the interpreter.140static bool contains(address pc) { return _code != NULL && _code->contains(pc); }141// Debugging/printing142static InterpreterCodelet* codelet_containing(address pc);143144145public:146147static address remove_activation_early_entry(TosState state) { return _earlyret_entry.entry(state); }148static address remove_activation_preserving_args_entry() { return _remove_activation_preserving_args_entry; }149150static address remove_activation_entry() { return _remove_activation_entry; }151static address throw_exception_entry() { return _throw_exception_entry; }152static address throw_ArithmeticException_entry() { return _throw_ArithmeticException_entry; }153static address throw_NullPointerException_entry() { return _throw_NullPointerException_entry; }154static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; }155156// Code generation157#ifndef PRODUCT158static address trace_code (TosState state) { return _trace_code.entry(state); }159#endif // !PRODUCT160static address* dispatch_table(TosState state) { return _active_table.table_for(state); }161static address* dispatch_table() { return _active_table.table_for(); }162static int distance_from_dispatch_table(TosState state){ return _active_table.distance_from(state); }163static address* normal_table(TosState state) { return _normal_table.table_for(state); }164static address* normal_table() { return _normal_table.table_for(); }165static address* safept_table(TosState state) { return _safept_table.table_for(state); }166167// Support for invokes168static address* invoke_return_entry_table() { return _invoke_return_entry; }169static address* invokeinterface_return_entry_table() { return _invokeinterface_return_entry; }170static address* invokedynamic_return_entry_table() { return _invokedynamic_return_entry; }171static int TosState_as_index(TosState state);172173static address* invoke_return_entry_table_for(Bytecodes::Code code);174175static address deopt_entry(TosState state, int length);176static address deopt_reexecute_return_entry() { return _deopt_reexecute_return_entry; }177static address return_entry(TosState state, int length, Bytecodes::Code code);178179// Safepoint support180static void notice_safepoints(); // stops the thread when reaching a safepoint181static void ignore_safepoints(); // ignores safepoints182183// Deoptimization support184// Compute the entry address for continuation after185static address deopt_continue_after_entry(Method* method,186address bcp,187int callee_parameters,188bool is_top_frame);189// Deoptimization should reexecute this bytecode190static bool bytecode_should_reexecute(Bytecodes::Code code);191// Compute the address for reexecution192static address deopt_reexecute_entry(Method* method, address bcp);193194// Size of interpreter code. Max size with JVMTI195static int InterpreterCodeSize;196};197198#endif // !ZERO199200#endif // SHARE_INTERPRETER_TEMPLATEINTERPRETER_HPP201202203