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 */
24
25 #include "precompiled.hpp"
26 #include "interpreter/interpreter.hpp"
27 #include "interpreter/interpreterRuntime.hpp"
28 #include "interpreter/interp_masm.hpp"
29 #include "interpreter/templateInterpreter.hpp"
30 #include "interpreter/templateInterpreterGenerator.hpp"
31 #include "interpreter/templateTable.hpp"
32 #include "logging/log.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "runtime/timerTrace.hpp"
35
36 #ifndef CC_INTERP
37
38 # define __ _masm->
39
40 void TemplateInterpreter::initialize() {
41 if (_code != NULL) return;
42 // assertions
43 assert((int)Bytecodes::number_of_codes <= (int)DispatchTable::length,
44 "dispatch table too small");
45
46 AbstractInterpreter::initialize();
47
48 TemplateTable::initialize();
49
50 // generate interpreter
51 { ResourceMark rm;
52 TraceTime timer("Interpreter generation", TRACETIME_LOG(Info, startuptime));
53 int code_size = InterpreterCodeSize;
54 NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space
258
259
260 address TemplateInterpreter::deopt_entry(TosState state, int length) {
261 guarantee(0 <= length && length < Interpreter::number_of_deopt_entries, "illegal length");
262 address entry = _deopt_entry[length].entry(state);
263 vmassert(entry != NULL, "unsupported deopt entry requested, length=%d state=%d", length, TosState_as_index(state));
264 return entry;
265 }
266
267 //------------------------------------------------------------------------------------------------------------------------
268 // Suport for invokes
269
270 int TemplateInterpreter::TosState_as_index(TosState state) {
271 assert( state < number_of_states , "Invalid state in TosState_as_index");
272 assert(0 <= (int)state && (int)state < TemplateInterpreter::number_of_return_addrs, "index out of bounds");
273 return (int)state;
274 }
275
276
277 //------------------------------------------------------------------------------------------------------------------------
278 // Safepoint suppport
279
280 static inline void copy_table(address* from, address* to, int size) {
281 // Copy non-overlapping tables. The copy has to occur word wise for MT safety.
282 while (size-- > 0) *to++ = *from++;
283 }
284
285 void TemplateInterpreter::notice_safepoints() {
286 if (!_notice_safepoints) {
287 log_debug(interpreter, safepoint)("switching active_table to safept_table.");
288 // switch to safepoint dispatch table
289 _notice_safepoints = true;
290 copy_table((address*)&_safept_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address));
291 } else {
292 log_debug(interpreter, safepoint)("active_table is already safept_table; "
293 "notice_safepoints() call is no-op.");
294 }
295 }
296
297 // switch from the dispatch table which notices safepoints back to the
298 // normal dispatch table. So that we can notice single stepping points,
299 // keep the safepoint dispatch table if we are single stepping in JVMTI.
300 // Note that the should_post_single_step test is exactly as fast as the
301 // JvmtiExport::_enabled test and covers both cases.
302 void TemplateInterpreter::ignore_safepoints() {
|
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 */
24
25 #include "precompiled.hpp"
26 #include "interpreter/interpreter.hpp"
27 #include "interpreter/interpreterRuntime.hpp"
28 #include "interpreter/interp_masm.hpp"
29 #include "interpreter/templateInterpreter.hpp"
30 #include "interpreter/templateInterpreterGenerator.hpp"
31 #include "interpreter/templateTable.hpp"
32 #include "logging/log.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "runtime/safepoint.hpp"
35 #include "runtime/timerTrace.hpp"
36 #include "utilities/copy.hpp"
37
38 #ifndef CC_INTERP
39
40 # define __ _masm->
41
42 void TemplateInterpreter::initialize() {
43 if (_code != NULL) return;
44 // assertions
45 assert((int)Bytecodes::number_of_codes <= (int)DispatchTable::length,
46 "dispatch table too small");
47
48 AbstractInterpreter::initialize();
49
50 TemplateTable::initialize();
51
52 // generate interpreter
53 { ResourceMark rm;
54 TraceTime timer("Interpreter generation", TRACETIME_LOG(Info, startuptime));
55 int code_size = InterpreterCodeSize;
56 NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space
260
261
262 address TemplateInterpreter::deopt_entry(TosState state, int length) {
263 guarantee(0 <= length && length < Interpreter::number_of_deopt_entries, "illegal length");
264 address entry = _deopt_entry[length].entry(state);
265 vmassert(entry != NULL, "unsupported deopt entry requested, length=%d state=%d", length, TosState_as_index(state));
266 return entry;
267 }
268
269 //------------------------------------------------------------------------------------------------------------------------
270 // Suport for invokes
271
272 int TemplateInterpreter::TosState_as_index(TosState state) {
273 assert( state < number_of_states , "Invalid state in TosState_as_index");
274 assert(0 <= (int)state && (int)state < TemplateInterpreter::number_of_return_addrs, "index out of bounds");
275 return (int)state;
276 }
277
278
279 //------------------------------------------------------------------------------------------------------------------------
280 // Safepoint support
281
282 static inline void copy_table(address* from, address* to, int size) {
283 // Copy non-overlapping tables.
284 if (SafepointSynchronize::is_at_safepoint()) {
285 // Nothing is using the table at a safepoint so skip atomic word copy.
286 while (size-- > 0) *to++ = *from++;
287 } else {
288 // Use atomic word copy when not at a safepoint for safety.
289 Copy::disjoint_words_atomic((HeapWord*)from, (HeapWord*)to, (size_t)size);
290 }
291 }
292
293 void TemplateInterpreter::notice_safepoints() {
294 if (!_notice_safepoints) {
295 log_debug(interpreter, safepoint)("switching active_table to safept_table.");
296 // switch to safepoint dispatch table
297 _notice_safepoints = true;
298 copy_table((address*)&_safept_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address));
299 } else {
300 log_debug(interpreter, safepoint)("active_table is already safept_table; "
301 "notice_safepoints() call is no-op.");
302 }
303 }
304
305 // switch from the dispatch table which notices safepoints back to the
306 // normal dispatch table. So that we can notice single stepping points,
307 // keep the safepoint dispatch table if we are single stepping in JVMTI.
308 // Note that the should_post_single_step test is exactly as fast as the
309 // JvmtiExport::_enabled test and covers both cases.
310 void TemplateInterpreter::ignore_safepoints() {
|