Wed, 03 Jul 2019 20:42:37 +0800
Merge
aoqi@0 | 1 | /* |
kevinw@8368 | 2 | * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@1 | 25 | /* |
aoqi@1 | 26 | * This file has been modified by Loongson Technology in 2015. These |
aoqi@1 | 27 | * modifications are Copyright (c) 2015 Loongson Technology, and are made |
aoqi@1 | 28 | * available on the same license terms set forth above. |
aoqi@1 | 29 | */ |
aoqi@1 | 30 | |
aoqi@0 | 31 | #ifndef SHARE_VM_INTERPRETER_TEMPLATEINTERPRETER_HPP |
aoqi@0 | 32 | #define SHARE_VM_INTERPRETER_TEMPLATEINTERPRETER_HPP |
aoqi@0 | 33 | |
aoqi@0 | 34 | #include "interpreter/abstractInterpreter.hpp" |
aoqi@0 | 35 | #include "interpreter/templateTable.hpp" |
aoqi@0 | 36 | |
aoqi@0 | 37 | // This file contains the platform-independent parts |
aoqi@0 | 38 | // of the template interpreter and the template interpreter generator. |
aoqi@0 | 39 | |
aoqi@0 | 40 | #ifndef CC_INTERP |
aoqi@0 | 41 | |
aoqi@0 | 42 | //------------------------------------------------------------------------------------------------------------------------ |
aoqi@0 | 43 | // A little wrapper class to group tosca-specific entry points into a unit. |
aoqi@0 | 44 | // (tosca = Top-Of-Stack CAche) |
aoqi@0 | 45 | |
aoqi@0 | 46 | class EntryPoint VALUE_OBJ_CLASS_SPEC { |
aoqi@0 | 47 | private: |
aoqi@0 | 48 | address _entry[number_of_states]; |
aoqi@0 | 49 | |
aoqi@0 | 50 | public: |
aoqi@0 | 51 | // Construction |
aoqi@0 | 52 | EntryPoint(); |
kevinw@8368 | 53 | EntryPoint(address bentry, address zentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry); |
aoqi@0 | 54 | |
aoqi@0 | 55 | // Attributes |
aoqi@0 | 56 | address entry(TosState state) const; // return target address for a given tosca state |
aoqi@0 | 57 | void set_entry(TosState state, address entry); // set target address for a given tosca state |
aoqi@0 | 58 | void print(); |
aoqi@0 | 59 | |
aoqi@0 | 60 | // Comparison |
aoqi@0 | 61 | bool operator == (const EntryPoint& y); // for debugging only |
aoqi@0 | 62 | }; |
aoqi@0 | 63 | |
aoqi@0 | 64 | |
aoqi@0 | 65 | //------------------------------------------------------------------------------------------------------------------------ |
aoqi@0 | 66 | // A little wrapper class to group tosca-specific dispatch tables into a unit. |
aoqi@0 | 67 | |
aoqi@0 | 68 | class DispatchTable VALUE_OBJ_CLASS_SPEC { |
aoqi@0 | 69 | public: |
aoqi@0 | 70 | enum { length = 1 << BitsPerByte }; // an entry point for each byte value (also for undefined bytecodes) |
aoqi@0 | 71 | |
aoqi@0 | 72 | private: |
aoqi@0 | 73 | address _table[number_of_states][length]; // dispatch tables, indexed by tosca and bytecode |
aoqi@0 | 74 | |
aoqi@0 | 75 | public: |
aoqi@0 | 76 | // Attributes |
aoqi@0 | 77 | EntryPoint entry(int i) const; // return entry point for a given bytecode i |
aoqi@0 | 78 | void set_entry(int i, EntryPoint& entry); // set entry point for a given bytecode i |
aoqi@0 | 79 | address* table_for(TosState state) { return _table[state]; } |
aoqi@0 | 80 | address* table_for() { return table_for((TosState)0); } |
aoqi@0 | 81 | int distance_from(address *table) { return table - table_for(); } |
aoqi@0 | 82 | int distance_from(TosState state) { return distance_from(table_for(state)); } |
aoqi@0 | 83 | |
aoqi@0 | 84 | // Comparison |
aoqi@0 | 85 | bool operator == (DispatchTable& y); // for debugging only |
aoqi@0 | 86 | }; |
aoqi@0 | 87 | |
aoqi@0 | 88 | class TemplateInterpreter: public AbstractInterpreter { |
aoqi@0 | 89 | friend class VMStructs; |
aoqi@0 | 90 | friend class InterpreterMacroAssembler; |
aoqi@0 | 91 | friend class TemplateInterpreterGenerator; |
aoqi@0 | 92 | friend class InterpreterGenerator; |
aoqi@0 | 93 | friend class TemplateTable; |
aoqi@0 | 94 | // friend class Interpreter; |
aoqi@0 | 95 | public: |
aoqi@0 | 96 | |
aoqi@0 | 97 | enum MoreConstants { |
aoqi@0 | 98 | number_of_return_entries = number_of_states, // number of return entry points |
aoqi@0 | 99 | number_of_deopt_entries = number_of_states, // number of deoptimization entry points |
aoqi@0 | 100 | number_of_return_addrs = number_of_states // number of return addresses |
aoqi@0 | 101 | }; |
aoqi@0 | 102 | |
aoqi@0 | 103 | protected: |
aoqi@0 | 104 | |
aoqi@0 | 105 | static address _throw_ArrayIndexOutOfBoundsException_entry; |
aoqi@0 | 106 | static address _throw_ArrayStoreException_entry; |
aoqi@0 | 107 | static address _throw_ArithmeticException_entry; |
aoqi@0 | 108 | static address _throw_ClassCastException_entry; |
aoqi@0 | 109 | static address _throw_WrongMethodType_entry; |
aoqi@0 | 110 | static address _throw_NullPointerException_entry; |
aoqi@0 | 111 | static address _throw_exception_entry; |
aoqi@0 | 112 | |
aoqi@0 | 113 | static address _throw_StackOverflowError_entry; |
aoqi@0 | 114 | |
aoqi@0 | 115 | static address _remove_activation_entry; // continuation address if an exception is not handled by current frame |
aoqi@0 | 116 | #ifdef HOTSWAP |
aoqi@0 | 117 | static address _remove_activation_preserving_args_entry; // continuation address when current frame is being popped |
aoqi@0 | 118 | #endif // HOTSWAP |
aoqi@0 | 119 | |
aoqi@0 | 120 | #ifndef PRODUCT |
aoqi@0 | 121 | static EntryPoint _trace_code; |
aoqi@0 | 122 | #endif // !PRODUCT |
aoqi@0 | 123 | static EntryPoint _return_entry[number_of_return_entries]; // entry points to return to from a call |
aoqi@0 | 124 | static EntryPoint _earlyret_entry; // entry point to return early from a call |
aoqi@0 | 125 | static EntryPoint _deopt_entry[number_of_deopt_entries]; // entry points to return to from a deoptimization |
aoqi@0 | 126 | static EntryPoint _continuation_entry; |
aoqi@0 | 127 | static EntryPoint _safept_entry; |
aoqi@0 | 128 | |
aoqi@0 | 129 | static address _invoke_return_entry[number_of_return_addrs]; // for invokestatic, invokespecial, invokevirtual return entries |
aoqi@0 | 130 | static address _invokeinterface_return_entry[number_of_return_addrs]; // for invokeinterface return entries |
aoqi@0 | 131 | static address _invokedynamic_return_entry[number_of_return_addrs]; // for invokedynamic return entries |
aoqi@0 | 132 | |
aoqi@0 | 133 | static DispatchTable _active_table; // the active dispatch table (used by the interpreter for dispatch) |
aoqi@0 | 134 | static DispatchTable _normal_table; // the normal dispatch table (used to set the active table in normal mode) |
aoqi@0 | 135 | static DispatchTable _safept_table; // the safepoint dispatch table (used to set the active table for safepoints) |
aoqi@0 | 136 | static address _wentry_point[DispatchTable::length]; // wide instructions only (vtos tosca always) |
aoqi@0 | 137 | |
aoqi@0 | 138 | |
aoqi@0 | 139 | public: |
aoqi@0 | 140 | // Initialization/debugging |
aoqi@0 | 141 | static void initialize(); |
aoqi@0 | 142 | // this only returns whether a pc is within generated code for the interpreter. |
aoqi@0 | 143 | static bool contains(address pc) { return _code != NULL && _code->contains(pc); } |
aoqi@0 | 144 | |
aoqi@0 | 145 | public: |
aoqi@0 | 146 | |
aoqi@0 | 147 | static address remove_activation_early_entry(TosState state) { return _earlyret_entry.entry(state); } |
aoqi@0 | 148 | #ifdef HOTSWAP |
aoqi@0 | 149 | static address remove_activation_preserving_args_entry() { return _remove_activation_preserving_args_entry; } |
aoqi@0 | 150 | #endif // HOTSWAP |
aoqi@0 | 151 | |
aoqi@0 | 152 | static address remove_activation_entry() { return _remove_activation_entry; } |
aoqi@0 | 153 | static address throw_exception_entry() { return _throw_exception_entry; } |
aoqi@0 | 154 | static address throw_ArithmeticException_entry() { return _throw_ArithmeticException_entry; } |
aoqi@0 | 155 | static address throw_WrongMethodType_entry() { return _throw_WrongMethodType_entry; } |
aoqi@0 | 156 | static address throw_NullPointerException_entry() { return _throw_NullPointerException_entry; } |
aoqi@0 | 157 | static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; } |
aoqi@0 | 158 | |
aoqi@0 | 159 | // Code generation |
aoqi@0 | 160 | #ifndef PRODUCT |
aoqi@0 | 161 | static address trace_code (TosState state) { return _trace_code.entry(state); } |
aoqi@0 | 162 | #endif // !PRODUCT |
aoqi@0 | 163 | static address continuation (TosState state) { return _continuation_entry.entry(state); } |
aoqi@0 | 164 | static address* dispatch_table(TosState state) { return _active_table.table_for(state); } |
aoqi@0 | 165 | static address* dispatch_table() { return _active_table.table_for(); } |
aoqi@0 | 166 | static int distance_from_dispatch_table(TosState state){ return _active_table.distance_from(state); } |
aoqi@0 | 167 | static address* normal_table(TosState state) { return _normal_table.table_for(state); } |
aoqi@0 | 168 | static address* normal_table() { return _normal_table.table_for(); } |
aoqi@0 | 169 | |
aoqi@0 | 170 | // Support for invokes |
aoqi@0 | 171 | static address* invoke_return_entry_table() { return _invoke_return_entry; } |
aoqi@0 | 172 | static address* invokeinterface_return_entry_table() { return _invokeinterface_return_entry; } |
aoqi@0 | 173 | static address* invokedynamic_return_entry_table() { return _invokedynamic_return_entry; } |
aoqi@0 | 174 | static int TosState_as_index(TosState state); |
aoqi@0 | 175 | |
aoqi@0 | 176 | static address* invoke_return_entry_table_for(Bytecodes::Code code); |
aoqi@0 | 177 | |
aoqi@0 | 178 | static address deopt_entry(TosState state, int length); |
aoqi@0 | 179 | static address return_entry(TosState state, int length, Bytecodes::Code code); |
aoqi@0 | 180 | |
aoqi@0 | 181 | // Safepoint support |
aoqi@0 | 182 | static void notice_safepoints(); // stops the thread when reaching a safepoint |
aoqi@0 | 183 | static void ignore_safepoints(); // ignores safepoints |
aoqi@0 | 184 | |
aoqi@0 | 185 | // Deoptimization support |
aoqi@0 | 186 | // Compute the entry address for continuation after |
aoqi@0 | 187 | static address deopt_continue_after_entry(Method* method, |
aoqi@0 | 188 | address bcp, |
aoqi@0 | 189 | int callee_parameters, |
aoqi@0 | 190 | bool is_top_frame); |
aoqi@0 | 191 | // Deoptimization should reexecute this bytecode |
aoqi@0 | 192 | static bool bytecode_should_reexecute(Bytecodes::Code code); |
aoqi@0 | 193 | // Compute the address for reexecution |
aoqi@0 | 194 | static address deopt_reexecute_entry(Method* method, address bcp); |
aoqi@0 | 195 | |
aoqi@0 | 196 | #ifdef TARGET_ARCH_x86 |
aoqi@0 | 197 | # include "templateInterpreter_x86.hpp" |
aoqi@0 | 198 | #endif |
aoqi@1 | 199 | #ifdef TARGET_ARCH_mips |
aoqi@1 | 200 | # include "templateInterpreter_mips.hpp" |
aoqi@1 | 201 | #endif |
aoqi@0 | 202 | #ifdef TARGET_ARCH_sparc |
aoqi@0 | 203 | # include "templateInterpreter_sparc.hpp" |
aoqi@0 | 204 | #endif |
aoqi@0 | 205 | #ifdef TARGET_ARCH_zero |
aoqi@0 | 206 | # include "templateInterpreter_zero.hpp" |
aoqi@0 | 207 | #endif |
aoqi@0 | 208 | #ifdef TARGET_ARCH_arm |
aoqi@0 | 209 | # include "templateInterpreter_arm.hpp" |
aoqi@0 | 210 | #endif |
aoqi@0 | 211 | #ifdef TARGET_ARCH_ppc |
aoqi@0 | 212 | # include "templateInterpreter_ppc.hpp" |
aoqi@0 | 213 | #endif |
aoqi@0 | 214 | |
aoqi@0 | 215 | |
aoqi@0 | 216 | }; |
aoqi@0 | 217 | |
aoqi@0 | 218 | #endif // !CC_INTERP |
aoqi@0 | 219 | |
aoqi@0 | 220 | #endif // SHARE_VM_INTERPRETER_TEMPLATEINTERPRETER_HPP |