0N/A/*
2273N/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_TEMPLATEINTERPRETER_HPP
1879N/A#define SHARE_VM_INTERPRETER_TEMPLATEINTERPRETER_HPP
1879N/A
1879N/A#include "interpreter/abstractInterpreter.hpp"
1879N/A#include "interpreter/templateTable.hpp"
1879N/A
605N/A// This file contains the platform-independent parts
0N/A// of the template interpreter and the template interpreter generator.
0N/A
0N/A#ifndef CC_INTERP
0N/A
0N/A//------------------------------------------------------------------------------------------------------------------------
0N/A// A little wrapper class to group tosca-specific entry points into a unit.
0N/A// (tosca = Top-Of-Stack CAche)
0N/A
0N/Aclass EntryPoint VALUE_OBJ_CLASS_SPEC {
0N/A private:
0N/A address _entry[number_of_states];
0N/A
0N/A public:
0N/A // Construction
0N/A EntryPoint();
0N/A EntryPoint(address bentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry);
0N/A
0N/A // Attributes
0N/A address entry(TosState state) const; // return target address for a given tosca state
0N/A void set_entry(TosState state, address entry); // set target address for a given tosca state
0N/A void print();
0N/A
0N/A // Comparison
0N/A bool operator == (const EntryPoint& y); // for debugging only
0N/A};
0N/A
0N/A
0N/A//------------------------------------------------------------------------------------------------------------------------
0N/A// A little wrapper class to group tosca-specific dispatch tables into a unit.
0N/A
0N/Aclass DispatchTable VALUE_OBJ_CLASS_SPEC {
0N/A public:
0N/A enum { length = 1 << BitsPerByte }; // an entry point for each byte value (also for undefined bytecodes)
0N/A
0N/A private:
0N/A address _table[number_of_states][length]; // dispatch tables, indexed by tosca and bytecode
0N/A
0N/A public:
0N/A // Attributes
0N/A EntryPoint entry(int i) const; // return entry point for a given bytecode i
0N/A void set_entry(int i, EntryPoint& entry); // set entry point for a given bytecode i
0N/A address* table_for(TosState state) { return _table[state]; }
0N/A address* table_for() { return table_for((TosState)0); }
0N/A int distance_from(address *table) { return table - table_for(); }
0N/A int distance_from(TosState state) { return distance_from(table_for(state)); }
0N/A
0N/A // Comparison
0N/A bool operator == (DispatchTable& y); // for debugging only
0N/A};
0N/A
0N/Aclass TemplateInterpreter: public AbstractInterpreter {
0N/A friend class VMStructs;
0N/A friend class InterpreterMacroAssembler;
0N/A friend class TemplateInterpreterGenerator;
710N/A friend class InterpreterGenerator;
0N/A friend class TemplateTable;
0N/A // friend class Interpreter;
0N/A public:
0N/A
0N/A enum MoreConstants {
726N/A number_of_return_entries = number_of_states, // number of return entry points
726N/A number_of_deopt_entries = number_of_states, // number of deoptimization entry points
726N/A number_of_return_addrs = number_of_states // number of return addresses
0N/A };
0N/A
0N/A protected:
0N/A
0N/A static address _throw_ArrayIndexOutOfBoundsException_entry;
0N/A static address _throw_ArrayStoreException_entry;
0N/A static address _throw_ArithmeticException_entry;
0N/A static address _throw_ClassCastException_entry;
710N/A static address _throw_WrongMethodType_entry;
0N/A static address _throw_NullPointerException_entry;
0N/A static address _throw_exception_entry;
0N/A
0N/A static address _throw_StackOverflowError_entry;
0N/A
0N/A static address _remove_activation_entry; // continuation address if an exception is not handled by current frame
0N/A#ifdef HOTSWAP
0N/A static address _remove_activation_preserving_args_entry; // continuation address when current frame is being popped
0N/A#endif // HOTSWAP
0N/A
0N/A#ifndef PRODUCT
0N/A static EntryPoint _trace_code;
0N/A#endif // !PRODUCT
0N/A static EntryPoint _return_entry[number_of_return_entries]; // entry points to return to from a call
0N/A static EntryPoint _earlyret_entry; // entry point to return early from a call
0N/A static EntryPoint _deopt_entry[number_of_deopt_entries]; // entry points to return to from a deoptimization
0N/A static EntryPoint _continuation_entry;
0N/A static EntryPoint _safept_entry;
0N/A
0N/A static address _return_3_addrs_by_index[number_of_return_addrs]; // for invokevirtual return entries
0N/A static address _return_5_addrs_by_index[number_of_return_addrs]; // for invokeinterface return entries
0N/A
0N/A static DispatchTable _active_table; // the active dispatch table (used by the interpreter for dispatch)
0N/A static DispatchTable _normal_table; // the normal dispatch table (used to set the active table in normal mode)
0N/A static DispatchTable _safept_table; // the safepoint dispatch table (used to set the active table for safepoints)
0N/A static address _wentry_point[DispatchTable::length]; // wide instructions only (vtos tosca always)
0N/A
0N/A
0N/A public:
0N/A // Initialization/debugging
0N/A static void initialize();
0N/A // this only returns whether a pc is within generated code for the interpreter.
0N/A static bool contains(address pc) { return _code != NULL && _code->contains(pc); }
0N/A
0N/A public:
0N/A
0N/A static address remove_activation_early_entry(TosState state) { return _earlyret_entry.entry(state); }
0N/A#ifdef HOTSWAP
0N/A static address remove_activation_preserving_args_entry() { return _remove_activation_preserving_args_entry; }
0N/A#endif // HOTSWAP
0N/A
0N/A static address remove_activation_entry() { return _remove_activation_entry; }
0N/A static address throw_exception_entry() { return _throw_exception_entry; }
0N/A static address throw_ArithmeticException_entry() { return _throw_ArithmeticException_entry; }
710N/A static address throw_WrongMethodType_entry() { return _throw_WrongMethodType_entry; }
0N/A static address throw_NullPointerException_entry() { return _throw_NullPointerException_entry; }
0N/A static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; }
0N/A
0N/A // Code generation
0N/A#ifndef PRODUCT
0N/A static address trace_code (TosState state) { return _trace_code.entry(state); }
0N/A#endif // !PRODUCT
0N/A static address continuation (TosState state) { return _continuation_entry.entry(state); }
0N/A static address* dispatch_table(TosState state) { return _active_table.table_for(state); }
0N/A static address* dispatch_table() { return _active_table.table_for(); }
0N/A static int distance_from_dispatch_table(TosState state){ return _active_table.distance_from(state); }
0N/A static address* normal_table(TosState state) { return _normal_table.table_for(state); }
0N/A static address* normal_table() { return _normal_table.table_for(); }
0N/A
0N/A // Support for invokes
0N/A static address* return_3_addrs_by_index_table() { return _return_3_addrs_by_index; }
0N/A static address* return_5_addrs_by_index_table() { return _return_5_addrs_by_index; }
0N/A static int TosState_as_index(TosState state); // computes index into return_3_entry_by_index table
0N/A
0N/A static address return_entry (TosState state, int length);
0N/A static address deopt_entry (TosState state, int length);
0N/A
0N/A // Safepoint support
0N/A static void notice_safepoints(); // stops the thread when reaching a safepoint
0N/A static void ignore_safepoints(); // ignores safepoints
0N/A
0N/A // Deoptimization support
900N/A // Compute the entry address for continuation after
900N/A static address deopt_continue_after_entry(methodOop method,
900N/A address bcp,
900N/A int callee_parameters,
900N/A bool is_top_frame);
900N/A // Deoptimization should reexecute this bytecode
900N/A static bool bytecode_should_reexecute(Bytecodes::Code code);
900N/A // Compute the address for reexecution
900N/A static address deopt_reexecute_entry(methodOop method, address bcp);
0N/A
1879N/A#ifdef TARGET_ARCH_x86
1879N/A# include "templateInterpreter_x86.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_sparc
1879N/A# include "templateInterpreter_sparc.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_zero
1879N/A# include "templateInterpreter_zero.hpp"
1879N/A#endif
2073N/A#ifdef TARGET_ARCH_arm
2073N/A# include "templateInterpreter_arm.hpp"
2073N/A#endif
2073N/A#ifdef TARGET_ARCH_ppc
2073N/A# include "templateInterpreter_ppc.hpp"
2073N/A#endif
1879N/A
0N/A
0N/A};
0N/A
0N/A#endif // !CC_INTERP
1879N/A
1879N/A#endif // SHARE_VM_INTERPRETER_TEMPLATEINTERPRETER_HPP