1 /*
2 * Copyright (c) 1997, 2016, 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 *
75 void set_entry(int i, EntryPoint& entry); // set entry point for a given bytecode i
76 address* table_for(TosState state) { return _table[state]; }
77 address* table_for() { return table_for((TosState)0); }
78 int distance_from(address *table) { return table - table_for(); }
79 int distance_from(TosState state) { return distance_from(table_for(state)); }
80
81 // Comparison
82 bool operator == (DispatchTable& y); // for debugging only
83 };
84
85 class TemplateInterpreter: public AbstractInterpreter {
86 friend class VMStructs;
87 friend class InterpreterMacroAssembler;
88 friend class TemplateInterpreterGenerator;
89 friend class TemplateTable;
90 friend class CodeCacheExtensions;
91 // friend class Interpreter;
92 public:
93
94 enum MoreConstants {
95 number_of_return_entries = number_of_states, // number of return entry points
96 number_of_deopt_entries = number_of_states, // number of deoptimization entry points
97 number_of_return_addrs = number_of_states // number of return addresses
98 };
99
100 protected:
101
102 static address _throw_ArrayIndexOutOfBoundsException_entry;
103 static address _throw_ArrayStoreException_entry;
104 static address _throw_ArithmeticException_entry;
105 static address _throw_ClassCastException_entry;
106 static address _throw_NullPointerException_entry;
107 static address _throw_exception_entry;
108
109 static address _throw_StackOverflowError_entry;
110
111 static address _remove_activation_entry; // continuation address if an exception is not handled by current frame
112 #ifdef HOTSWAP
113 static address _remove_activation_preserving_args_entry; // continuation address when current frame is being popped
114 #endif // HOTSWAP
115
116 #ifndef PRODUCT
117 static EntryPoint _trace_code;
118 #endif // !PRODUCT
119 static EntryPoint _return_entry[number_of_return_entries]; // entry points to return to from a call
120 static EntryPoint _earlyret_entry; // entry point to return early from a call
121 static EntryPoint _deopt_entry[number_of_deopt_entries]; // entry points to return to from a deoptimization
122 static EntryPoint _safept_entry;
123
124 static address _invoke_return_entry[number_of_return_addrs]; // for invokestatic, invokespecial, invokevirtual return entries
125 static address _invokeinterface_return_entry[number_of_return_addrs]; // for invokeinterface return entries
126 static address _invokedynamic_return_entry[number_of_return_addrs]; // for invokedynamic return entries
127
128 static DispatchTable _active_table; // the active dispatch table (used by the interpreter for dispatch)
129 static DispatchTable _normal_table; // the normal dispatch table (used to set the active table in normal mode)
130 static DispatchTable _safept_table; // the safepoint dispatch table (used to set the active table for safepoints)
131 static address _wentry_point[DispatchTable::length]; // wide instructions only (vtos tosca always)
132
133
134 public:
135 // Initialization/debugging
136 static void initialize();
137 // this only returns whether a pc is within generated code for the interpreter.
138 static bool contains(address pc) { return _code != NULL && _code->contains(pc); }
139 // Debugging/printing
140 static InterpreterCodelet* codelet_containing(address pc);
141
155
156 // Code generation
157 #ifndef PRODUCT
158 static address trace_code (TosState state) { return _trace_code.entry(state); }
159 #endif // !PRODUCT
160 static address* dispatch_table(TosState state) { return _active_table.table_for(state); }
161 static address* dispatch_table() { return _active_table.table_for(); }
162 static int distance_from_dispatch_table(TosState state){ return _active_table.distance_from(state); }
163 static address* normal_table(TosState state) { return _normal_table.table_for(state); }
164 static address* normal_table() { return _normal_table.table_for(); }
165
166 // Support for invokes
167 static address* invoke_return_entry_table() { return _invoke_return_entry; }
168 static address* invokeinterface_return_entry_table() { return _invokeinterface_return_entry; }
169 static address* invokedynamic_return_entry_table() { return _invokedynamic_return_entry; }
170 static int TosState_as_index(TosState state);
171
172 static address* invoke_return_entry_table_for(Bytecodes::Code code);
173
174 static address deopt_entry(TosState state, int length);
175 static address return_entry(TosState state, int length, Bytecodes::Code code);
176
177 // Safepoint support
178 static void notice_safepoints(); // stops the thread when reaching a safepoint
179 static void ignore_safepoints(); // ignores safepoints
180
181 // Deoptimization support
182 // Compute the entry address for continuation after
183 static address deopt_continue_after_entry(Method* method,
184 address bcp,
185 int callee_parameters,
186 bool is_top_frame);
187 // Deoptimization should reexecute this bytecode
188 static bool bytecode_should_reexecute(Bytecodes::Code code);
189 // Compute the address for reexecution
190 static address deopt_reexecute_entry(Method* method, address bcp);
191
192 // Size of interpreter code. Max size with JVMTI
193 static int InterpreterCodeSize;
194 };
|
1 /*
2 * Copyright (c) 1997, 2017, 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 *
75 void set_entry(int i, EntryPoint& entry); // set entry point for a given bytecode i
76 address* table_for(TosState state) { return _table[state]; }
77 address* table_for() { return table_for((TosState)0); }
78 int distance_from(address *table) { return table - table_for(); }
79 int distance_from(TosState state) { return distance_from(table_for(state)); }
80
81 // Comparison
82 bool operator == (DispatchTable& y); // for debugging only
83 };
84
85 class TemplateInterpreter: public AbstractInterpreter {
86 friend class VMStructs;
87 friend class InterpreterMacroAssembler;
88 friend class TemplateInterpreterGenerator;
89 friend class TemplateTable;
90 friend class CodeCacheExtensions;
91 // friend class Interpreter;
92 public:
93
94 enum MoreConstants {
95 max_invoke_length = 5, // invokedynamic is the longest
96 max_bytecode_length = 6, // worse case is wide iinc, "reexecute" bytecodes are excluded because "skip" will be 0
97 number_of_return_entries = max_invoke_length + 1, // number of return entry points
98 number_of_deopt_entries = max_bytecode_length + 1, // number of deoptimization entry points
99 number_of_return_addrs = number_of_states // number of return addresses
100 };
101
102 protected:
103
104 static address _throw_ArrayIndexOutOfBoundsException_entry;
105 static address _throw_ArrayStoreException_entry;
106 static address _throw_ArithmeticException_entry;
107 static address _throw_ClassCastException_entry;
108 static address _throw_NullPointerException_entry;
109 static address _throw_exception_entry;
110
111 static address _throw_StackOverflowError_entry;
112
113 static address _remove_activation_entry; // continuation address if an exception is not handled by current frame
114 #ifdef HOTSWAP
115 static address _remove_activation_preserving_args_entry; // continuation address when current frame is being popped
116 #endif // HOTSWAP
117
118 #ifndef PRODUCT
119 static EntryPoint _trace_code;
120 #endif // !PRODUCT
121 static EntryPoint _return_entry[number_of_return_entries]; // entry points to return to from a call
122 static EntryPoint _earlyret_entry; // entry point to return early from a call
123 static EntryPoint _deopt_entry[number_of_deopt_entries]; // entry points to return to from a deoptimization
124 static address _deopt_reexecute_return_entry;
125 static EntryPoint _safept_entry;
126
127 static address _invoke_return_entry[number_of_return_addrs]; // for invokestatic, invokespecial, invokevirtual return entries
128 static address _invokeinterface_return_entry[number_of_return_addrs]; // for invokeinterface return entries
129 static address _invokedynamic_return_entry[number_of_return_addrs]; // for invokedynamic return entries
130
131 static DispatchTable _active_table; // the active dispatch table (used by the interpreter for dispatch)
132 static DispatchTable _normal_table; // the normal dispatch table (used to set the active table in normal mode)
133 static DispatchTable _safept_table; // the safepoint dispatch table (used to set the active table for safepoints)
134 static address _wentry_point[DispatchTable::length]; // wide instructions only (vtos tosca always)
135
136
137 public:
138 // Initialization/debugging
139 static void initialize();
140 // this only returns whether a pc is within generated code for the interpreter.
141 static bool contains(address pc) { return _code != NULL && _code->contains(pc); }
142 // Debugging/printing
143 static InterpreterCodelet* codelet_containing(address pc);
144
158
159 // Code generation
160 #ifndef PRODUCT
161 static address trace_code (TosState state) { return _trace_code.entry(state); }
162 #endif // !PRODUCT
163 static address* dispatch_table(TosState state) { return _active_table.table_for(state); }
164 static address* dispatch_table() { return _active_table.table_for(); }
165 static int distance_from_dispatch_table(TosState state){ return _active_table.distance_from(state); }
166 static address* normal_table(TosState state) { return _normal_table.table_for(state); }
167 static address* normal_table() { return _normal_table.table_for(); }
168
169 // Support for invokes
170 static address* invoke_return_entry_table() { return _invoke_return_entry; }
171 static address* invokeinterface_return_entry_table() { return _invokeinterface_return_entry; }
172 static address* invokedynamic_return_entry_table() { return _invokedynamic_return_entry; }
173 static int TosState_as_index(TosState state);
174
175 static address* invoke_return_entry_table_for(Bytecodes::Code code);
176
177 static address deopt_entry(TosState state, int length);
178 static address deopt_reexecute_return_entry() { return _deopt_reexecute_return_entry; }
179 static address return_entry(TosState state, int length, Bytecodes::Code code);
180
181 // Safepoint support
182 static void notice_safepoints(); // stops the thread when reaching a safepoint
183 static void ignore_safepoints(); // ignores safepoints
184
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);
195
196 // Size of interpreter code. Max size with JVMTI
197 static int InterpreterCodeSize;
198 };
|