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