Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/interpreter/templateInterpreter.hpp
32285 views
/*1* Copyright (c) 1997, 2016, 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_TEMPLATEINTERPRETER_HPP25#define SHARE_VM_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 CC_INTERP3435//------------------------------------------------------------------------------------------------------------------------36// A little wrapper class to group tosca-specific entry points into a unit.37// (tosca = Top-Of-Stack CAche)3839class EntryPoint VALUE_OBJ_CLASS_SPEC {40private:41address _entry[number_of_states];4243public:44// Construction45EntryPoint();46EntryPoint(address bentry, address zentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry);4748// Attributes49address entry(TosState state) const; // return target address for a given tosca state50void set_entry(TosState state, address entry); // set target address for a given tosca state51void print();5253// Comparison54bool operator == (const EntryPoint& y); // for debugging only55};565758//------------------------------------------------------------------------------------------------------------------------59// A little wrapper class to group tosca-specific dispatch tables into a unit.6061class DispatchTable VALUE_OBJ_CLASS_SPEC {62public:63enum { length = 1 << BitsPerByte }; // an entry point for each byte value (also for undefined bytecodes)6465private:66address _table[number_of_states][length]; // dispatch tables, indexed by tosca and bytecode6768public:69// Attributes70EntryPoint entry(int i) const; // return entry point for a given bytecode i71void set_entry(int i, EntryPoint& entry); // set entry point for a given bytecode i72address* table_for(TosState state) { return _table[state]; }73address* table_for() { return table_for((TosState)0); }74int distance_from(address *table) { return table - table_for(); }75int distance_from(TosState state) { return distance_from(table_for(state)); }7677// Comparison78bool operator == (DispatchTable& y); // for debugging only79};8081class TemplateInterpreter: public AbstractInterpreter {82friend class VMStructs;83friend class InterpreterMacroAssembler;84friend class TemplateInterpreterGenerator;85friend class InterpreterGenerator;86friend class TemplateTable;87// friend class Interpreter;88public:8990enum MoreConstants {91number_of_return_entries = number_of_states, // number of return entry points92number_of_deopt_entries = number_of_states, // number of deoptimization entry points93number_of_return_addrs = number_of_states // number of return addresses94};9596protected:9798static address _throw_ArrayIndexOutOfBoundsException_entry;99static address _throw_ArrayStoreException_entry;100static address _throw_ArithmeticException_entry;101static address _throw_ClassCastException_entry;102static address _throw_WrongMethodType_entry;103static address _throw_NullPointerException_entry;104static address _throw_exception_entry;105106static address _throw_StackOverflowError_entry;107108static address _remove_activation_entry; // continuation address if an exception is not handled by current frame109#ifdef HOTSWAP110static address _remove_activation_preserving_args_entry; // continuation address when current frame is being popped111#endif // HOTSWAP112113#ifndef PRODUCT114static EntryPoint _trace_code;115#endif // !PRODUCT116static EntryPoint _return_entry[number_of_return_entries]; // entry points to return to from a call117static EntryPoint _earlyret_entry; // entry point to return early from a call118static EntryPoint _deopt_entry[number_of_deopt_entries]; // entry points to return to from a deoptimization119static EntryPoint _continuation_entry;120static EntryPoint _safept_entry;121122static address _invoke_return_entry[number_of_return_addrs]; // for invokestatic, invokespecial, invokevirtual return entries123static address _invokeinterface_return_entry[number_of_return_addrs]; // for invokeinterface return entries124static address _invokedynamic_return_entry[number_of_return_addrs]; // for invokedynamic return entries125126static DispatchTable _active_table; // the active dispatch table (used by the interpreter for dispatch)127static DispatchTable _normal_table; // the normal dispatch table (used to set the active table in normal mode)128static DispatchTable _safept_table; // the safepoint dispatch table (used to set the active table for safepoints)129static address _wentry_point[DispatchTable::length]; // wide instructions only (vtos tosca always)130131132public:133// Initialization/debugging134static void initialize();135// this only returns whether a pc is within generated code for the interpreter.136static bool contains(address pc) { return _code != NULL && _code->contains(pc); }137138public:139140static address remove_activation_early_entry(TosState state) { return _earlyret_entry.entry(state); }141#ifdef HOTSWAP142static address remove_activation_preserving_args_entry() { return _remove_activation_preserving_args_entry; }143#endif // HOTSWAP144145static address remove_activation_entry() { return _remove_activation_entry; }146static address throw_exception_entry() { return _throw_exception_entry; }147static address throw_ArithmeticException_entry() { return _throw_ArithmeticException_entry; }148static address throw_WrongMethodType_entry() { return _throw_WrongMethodType_entry; }149static address throw_NullPointerException_entry() { return _throw_NullPointerException_entry; }150static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; }151152// Code generation153#ifndef PRODUCT154static address trace_code (TosState state) { return _trace_code.entry(state); }155#endif // !PRODUCT156static address continuation (TosState state) { return _continuation_entry.entry(state); }157static address* dispatch_table(TosState state) { return _active_table.table_for(state); }158static address* dispatch_table() { return _active_table.table_for(); }159static int distance_from_dispatch_table(TosState state){ return _active_table.distance_from(state); }160static address* normal_table(TosState state) { return _normal_table.table_for(state); }161static address* normal_table() { return _normal_table.table_for(); }162163// Support for invokes164static address* invoke_return_entry_table() { return _invoke_return_entry; }165static address* invokeinterface_return_entry_table() { return _invokeinterface_return_entry; }166static address* invokedynamic_return_entry_table() { return _invokedynamic_return_entry; }167static int TosState_as_index(TosState state);168169static address* invoke_return_entry_table_for(Bytecodes::Code code);170171static address deopt_entry(TosState state, int length);172static address return_entry(TosState state, int length, Bytecodes::Code code);173174// Safepoint support175static void notice_safepoints(); // stops the thread when reaching a safepoint176static void ignore_safepoints(); // ignores safepoints177178// Deoptimization support179// Compute the entry address for continuation after180static address deopt_continue_after_entry(Method* method,181address bcp,182int callee_parameters,183bool is_top_frame);184// Deoptimization should reexecute this bytecode185static bool bytecode_should_reexecute(Bytecodes::Code code);186// Compute the address for reexecution187static address deopt_reexecute_entry(Method* method, address bcp);188189#ifdef TARGET_ARCH_x86190# include "templateInterpreter_x86.hpp"191#endif192#ifdef TARGET_ARCH_aarch32193# include "templateInterpreter_aarch32.hpp"194#endif195#ifdef TARGET_ARCH_aarch64196# include "templateInterpreter_aarch64.hpp"197#endif198#ifdef TARGET_ARCH_sparc199# include "templateInterpreter_sparc.hpp"200#endif201#ifdef TARGET_ARCH_zero202# include "templateInterpreter_zero.hpp"203#endif204#ifdef TARGET_ARCH_arm205# include "templateInterpreter_arm.hpp"206#endif207#ifdef TARGET_ARCH_ppc208# include "templateInterpreter_ppc.hpp"209#endif210211212};213214#endif // !CC_INTERP215216#endif // SHARE_VM_INTERPRETER_TEMPLATEINTERPRETER_HPP217218219