src/share/vm/interpreter/interpreter.cpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6680
78bbf4d43a14
parent 1
2d8a650513c2
child 9138
b56ab8e56604
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2014, 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 #include "precompiled.hpp"
aoqi@0 32 #include "asm/macroAssembler.hpp"
aoqi@0 33 #include "asm/macroAssembler.inline.hpp"
aoqi@0 34 #include "compiler/disassembler.hpp"
aoqi@0 35 #include "interpreter/bytecodeHistogram.hpp"
aoqi@0 36 #include "interpreter/bytecodeInterpreter.hpp"
aoqi@0 37 #include "interpreter/interpreter.hpp"
aoqi@0 38 #include "interpreter/interpreterRuntime.hpp"
aoqi@0 39 #include "interpreter/templateTable.hpp"
aoqi@0 40 #include "memory/allocation.inline.hpp"
aoqi@0 41 #include "memory/resourceArea.hpp"
aoqi@0 42 #include "oops/arrayOop.hpp"
aoqi@0 43 #include "oops/methodData.hpp"
aoqi@0 44 #include "oops/method.hpp"
aoqi@0 45 #include "oops/oop.inline.hpp"
aoqi@0 46 #include "prims/forte.hpp"
aoqi@0 47 #include "prims/jvmtiExport.hpp"
aoqi@0 48 #include "prims/methodHandles.hpp"
aoqi@0 49 #include "runtime/handles.inline.hpp"
aoqi@0 50 #include "runtime/sharedRuntime.hpp"
aoqi@0 51 #include "runtime/stubRoutines.hpp"
aoqi@0 52 #include "runtime/timer.hpp"
aoqi@0 53
aoqi@0 54 # define __ _masm->
aoqi@0 55
aoqi@0 56
aoqi@0 57 //------------------------------------------------------------------------------------------------------------------------
aoqi@0 58 // Implementation of InterpreterCodelet
aoqi@0 59
aoqi@0 60 void InterpreterCodelet::initialize(const char* description, Bytecodes::Code bytecode) {
aoqi@0 61 _description = description;
aoqi@0 62 _bytecode = bytecode;
aoqi@0 63 }
aoqi@0 64
aoqi@0 65
aoqi@0 66 void InterpreterCodelet::verify() {
aoqi@0 67 }
aoqi@0 68
aoqi@0 69
aoqi@0 70 void InterpreterCodelet::print_on(outputStream* st) const {
aoqi@0 71 ttyLocker ttyl;
aoqi@0 72
aoqi@0 73 if (PrintInterpreter) {
aoqi@0 74 st->cr();
aoqi@0 75 st->print_cr("----------------------------------------------------------------------");
aoqi@0 76 }
aoqi@0 77
aoqi@0 78 if (description() != NULL) st->print("%s ", description());
aoqi@0 79 if (bytecode() >= 0 ) st->print("%d %s ", bytecode(), Bytecodes::name(bytecode()));
aoqi@0 80 st->print_cr("[" INTPTR_FORMAT ", " INTPTR_FORMAT "] %d bytes",
aoqi@0 81 p2i(code_begin()), p2i(code_end()), code_size());
aoqi@0 82
aoqi@0 83 if (PrintInterpreter) {
aoqi@0 84 st->cr();
aoqi@1 85 #ifndef MIPS64
aoqi@0 86 Disassembler::decode(code_begin(), code_end(), st, DEBUG_ONLY(_strings) NOT_DEBUG(CodeStrings()));
aoqi@1 87 #else
aoqi@1 88 Disassembler::decode(code_begin(), code_end(), st);
aoqi@1 89 #endif //disassembler_mips.cpp not implement "decode(address start, address end, outputStream* st, CodeComments c". 2013/02/25.
aoqi@0 90 }
aoqi@0 91 }
aoqi@0 92
aoqi@0 93
aoqi@0 94 //------------------------------------------------------------------------------------------------------------------------
aoqi@0 95 // Implementation of platform independent aspects of Interpreter
aoqi@0 96
aoqi@0 97 void AbstractInterpreter::initialize() {
aoqi@0 98 if (_code != NULL) return;
aoqi@0 99
aoqi@0 100 // make sure 'imported' classes are initialized
aoqi@0 101 if (CountBytecodes || TraceBytecodes || StopInterpreterAt) BytecodeCounter::reset();
aoqi@0 102 if (PrintBytecodeHistogram) BytecodeHistogram::reset();
aoqi@0 103 if (PrintBytecodePairHistogram) BytecodePairHistogram::reset();
aoqi@0 104
aoqi@0 105 InvocationCounter::reinitialize(DelayCompilationDuringStartup);
aoqi@0 106
aoqi@0 107 }
aoqi@0 108
aoqi@0 109 void AbstractInterpreter::print() {
aoqi@0 110 tty->cr();
aoqi@0 111 tty->print_cr("----------------------------------------------------------------------");
aoqi@0 112 tty->print_cr("Interpreter");
aoqi@0 113 tty->cr();
aoqi@0 114 tty->print_cr("code size = %6dK bytes", (int)_code->used_space()/1024);
aoqi@0 115 tty->print_cr("total space = %6dK bytes", (int)_code->total_space()/1024);
aoqi@0 116 tty->print_cr("wasted space = %6dK bytes", (int)_code->available_space()/1024);
aoqi@0 117 tty->cr();
aoqi@0 118 tty->print_cr("# of codelets = %6d" , _code->number_of_stubs());
aoqi@0 119 tty->print_cr("avg codelet size = %6d bytes", _code->used_space() / _code->number_of_stubs());
aoqi@0 120 tty->cr();
aoqi@0 121 _code->print();
aoqi@0 122 tty->print_cr("----------------------------------------------------------------------");
aoqi@0 123 tty->cr();
aoqi@0 124 }
aoqi@0 125
aoqi@0 126
aoqi@0 127 void interpreter_init() {
aoqi@0 128 Interpreter::initialize();
aoqi@0 129 #ifndef PRODUCT
aoqi@0 130 if (TraceBytecodes) BytecodeTracer::set_closure(BytecodeTracer::std_closure());
aoqi@0 131 #endif // PRODUCT
aoqi@0 132 // need to hit every safepoint in order to call zapping routine
aoqi@0 133 // register the interpreter
aoqi@0 134 Forte::register_stub(
aoqi@0 135 "Interpreter",
aoqi@0 136 AbstractInterpreter::code()->code_start(),
aoqi@0 137 AbstractInterpreter::code()->code_end()
aoqi@0 138 );
aoqi@0 139
aoqi@0 140 // notify JVMTI profiler
aoqi@0 141 if (JvmtiExport::should_post_dynamic_code_generated()) {
aoqi@0 142 JvmtiExport::post_dynamic_code_generated("Interpreter",
aoqi@0 143 AbstractInterpreter::code()->code_start(),
aoqi@0 144 AbstractInterpreter::code()->code_end());
aoqi@0 145 }
aoqi@0 146 }
aoqi@0 147
aoqi@0 148 //------------------------------------------------------------------------------------------------------------------------
aoqi@0 149 // Implementation of interpreter
aoqi@0 150
aoqi@0 151 StubQueue* AbstractInterpreter::_code = NULL;
aoqi@0 152 bool AbstractInterpreter::_notice_safepoints = false;
aoqi@0 153 address AbstractInterpreter::_rethrow_exception_entry = NULL;
aoqi@0 154
aoqi@0 155 address AbstractInterpreter::_native_entry_begin = NULL;
aoqi@0 156 address AbstractInterpreter::_native_entry_end = NULL;
aoqi@0 157 address AbstractInterpreter::_slow_signature_handler;
aoqi@0 158 address AbstractInterpreter::_entry_table [AbstractInterpreter::number_of_method_entries];
aoqi@0 159 address AbstractInterpreter::_native_abi_to_tosca [AbstractInterpreter::number_of_result_handlers];
aoqi@0 160
aoqi@0 161 //------------------------------------------------------------------------------------------------------------------------
aoqi@0 162 // Generation of complete interpreter
aoqi@0 163
aoqi@0 164 AbstractInterpreterGenerator::AbstractInterpreterGenerator(StubQueue* _code) {
aoqi@0 165 _masm = NULL;
aoqi@0 166 }
aoqi@0 167
aoqi@0 168
aoqi@0 169 static const BasicType types[Interpreter::number_of_result_handlers] = {
aoqi@0 170 T_BOOLEAN,
aoqi@0 171 T_CHAR ,
aoqi@0 172 T_BYTE ,
aoqi@0 173 T_SHORT ,
aoqi@0 174 T_INT ,
aoqi@0 175 T_LONG ,
aoqi@0 176 T_VOID ,
aoqi@0 177 T_FLOAT ,
aoqi@0 178 T_DOUBLE ,
aoqi@0 179 T_OBJECT
aoqi@0 180 };
aoqi@0 181
aoqi@0 182 void AbstractInterpreterGenerator::generate_all() {
aoqi@0 183
aoqi@0 184
aoqi@0 185 { CodeletMark cm(_masm, "slow signature handler");
aoqi@0 186 Interpreter::_slow_signature_handler = generate_slow_signature_handler();
aoqi@0 187 }
aoqi@0 188
aoqi@0 189 }
aoqi@0 190
aoqi@0 191 //------------------------------------------------------------------------------------------------------------------------
aoqi@0 192 // Entry points
aoqi@0 193
aoqi@0 194 AbstractInterpreter::MethodKind AbstractInterpreter::method_kind(methodHandle m) {
aoqi@0 195 // Abstract method?
aoqi@0 196 if (m->is_abstract()) return abstract;
aoqi@0 197
aoqi@0 198 // Method handle primitive?
aoqi@0 199 if (m->is_method_handle_intrinsic()) {
aoqi@0 200 vmIntrinsics::ID id = m->intrinsic_id();
aoqi@0 201 assert(MethodHandles::is_signature_polymorphic(id), "must match an intrinsic");
aoqi@0 202 MethodKind kind = (MethodKind)( method_handle_invoke_FIRST +
aoqi@0 203 ((int)id - vmIntrinsics::FIRST_MH_SIG_POLY) );
aoqi@0 204 assert(kind <= method_handle_invoke_LAST, "parallel enum ranges");
aoqi@0 205 return kind;
aoqi@0 206 }
aoqi@0 207
aoqi@0 208 #ifndef CC_INTERP
aoqi@0 209 if (UseCRC32Intrinsics && m->is_native()) {
aoqi@0 210 // Use optimized stub code for CRC32 native methods.
aoqi@0 211 switch (m->intrinsic_id()) {
aoqi@0 212 case vmIntrinsics::_updateCRC32 : return java_util_zip_CRC32_update;
aoqi@0 213 case vmIntrinsics::_updateBytesCRC32 : return java_util_zip_CRC32_updateBytes;
aoqi@0 214 case vmIntrinsics::_updateByteBufferCRC32 : return java_util_zip_CRC32_updateByteBuffer;
aoqi@0 215 }
aoqi@0 216 }
aoqi@0 217 #endif
aoqi@0 218
aoqi@0 219 // Native method?
aoqi@0 220 // Note: This test must come _before_ the test for intrinsic
aoqi@0 221 // methods. See also comments below.
aoqi@0 222 if (m->is_native()) {
aoqi@0 223 assert(!m->is_method_handle_intrinsic(), "overlapping bits here, watch out");
aoqi@0 224 return m->is_synchronized() ? native_synchronized : native;
aoqi@0 225 }
aoqi@0 226
aoqi@0 227 // Synchronized?
aoqi@0 228 if (m->is_synchronized()) {
aoqi@0 229 return zerolocals_synchronized;
aoqi@0 230 }
aoqi@0 231
aoqi@0 232 if (RegisterFinalizersAtInit && m->code_size() == 1 &&
aoqi@0 233 m->intrinsic_id() == vmIntrinsics::_Object_init) {
aoqi@0 234 // We need to execute the special return bytecode to check for
aoqi@0 235 // finalizer registration so create a normal frame.
aoqi@0 236 return zerolocals;
aoqi@0 237 }
aoqi@0 238
aoqi@0 239 // Empty method?
aoqi@0 240 if (m->is_empty_method()) {
aoqi@0 241 return empty;
aoqi@0 242 }
aoqi@0 243
aoqi@0 244 // Special intrinsic method?
aoqi@0 245 // Note: This test must come _after_ the test for native methods,
aoqi@0 246 // otherwise we will run into problems with JDK 1.2, see also
aoqi@0 247 // AbstractInterpreterGenerator::generate_method_entry() for
aoqi@0 248 // for details.
aoqi@0 249 switch (m->intrinsic_id()) {
aoqi@0 250 case vmIntrinsics::_dsin : return java_lang_math_sin ;
aoqi@0 251 case vmIntrinsics::_dcos : return java_lang_math_cos ;
aoqi@0 252 case vmIntrinsics::_dtan : return java_lang_math_tan ;
aoqi@0 253 case vmIntrinsics::_dabs : return java_lang_math_abs ;
aoqi@0 254 case vmIntrinsics::_dsqrt : return java_lang_math_sqrt ;
aoqi@0 255 case vmIntrinsics::_dlog : return java_lang_math_log ;
aoqi@0 256 case vmIntrinsics::_dlog10: return java_lang_math_log10;
aoqi@0 257 case vmIntrinsics::_dpow : return java_lang_math_pow ;
aoqi@0 258 case vmIntrinsics::_dexp : return java_lang_math_exp ;
aoqi@0 259
aoqi@0 260 case vmIntrinsics::_Reference_get:
aoqi@0 261 return java_lang_ref_reference_get;
aoqi@0 262 }
aoqi@0 263
aoqi@0 264 // Accessor method?
aoqi@0 265 if (m->is_accessor()) {
aoqi@0 266 assert(m->size_of_parameters() == 1, "fast code for accessors assumes parameter size = 1");
aoqi@0 267 return accessor;
aoqi@0 268 }
aoqi@0 269
aoqi@0 270 // Note: for now: zero locals for all non-empty methods
aoqi@0 271 return zerolocals;
aoqi@0 272 }
aoqi@0 273
aoqi@0 274
aoqi@0 275 void AbstractInterpreter::set_entry_for_kind(AbstractInterpreter::MethodKind kind, address entry) {
aoqi@0 276 assert(kind >= method_handle_invoke_FIRST &&
aoqi@0 277 kind <= method_handle_invoke_LAST, "late initialization only for MH entry points");
aoqi@0 278 assert(_entry_table[kind] == _entry_table[abstract], "previous value must be AME entry");
aoqi@0 279 _entry_table[kind] = entry;
aoqi@0 280 }
aoqi@0 281
aoqi@0 282
aoqi@0 283 // Return true if the interpreter can prove that the given bytecode has
aoqi@0 284 // not yet been executed (in Java semantics, not in actual operation).
aoqi@0 285 bool AbstractInterpreter::is_not_reached(methodHandle method, int bci) {
aoqi@0 286 Bytecodes::Code code = method()->code_at(bci);
aoqi@0 287
aoqi@0 288 if (!Bytecodes::must_rewrite(code)) {
aoqi@0 289 // might have been reached
aoqi@0 290 return false;
aoqi@0 291 }
aoqi@0 292
aoqi@0 293 // the bytecode might not be rewritten if the method is an accessor, etc.
aoqi@0 294 address ientry = method->interpreter_entry();
aoqi@0 295 if (ientry != entry_for_kind(AbstractInterpreter::zerolocals) &&
aoqi@0 296 ientry != entry_for_kind(AbstractInterpreter::zerolocals_synchronized))
aoqi@0 297 return false; // interpreter does not run this method!
aoqi@0 298
aoqi@0 299 // otherwise, we can be sure this bytecode has never been executed
aoqi@0 300 return true;
aoqi@0 301 }
aoqi@0 302
aoqi@0 303
aoqi@0 304 #ifndef PRODUCT
aoqi@0 305 void AbstractInterpreter::print_method_kind(MethodKind kind) {
aoqi@0 306 switch (kind) {
aoqi@0 307 case zerolocals : tty->print("zerolocals" ); break;
aoqi@0 308 case zerolocals_synchronized: tty->print("zerolocals_synchronized"); break;
aoqi@0 309 case native : tty->print("native" ); break;
aoqi@0 310 case native_synchronized : tty->print("native_synchronized" ); break;
aoqi@0 311 case empty : tty->print("empty" ); break;
aoqi@0 312 case accessor : tty->print("accessor" ); break;
aoqi@0 313 case abstract : tty->print("abstract" ); break;
aoqi@0 314 case java_lang_math_sin : tty->print("java_lang_math_sin" ); break;
aoqi@0 315 case java_lang_math_cos : tty->print("java_lang_math_cos" ); break;
aoqi@0 316 case java_lang_math_tan : tty->print("java_lang_math_tan" ); break;
aoqi@0 317 case java_lang_math_abs : tty->print("java_lang_math_abs" ); break;
aoqi@0 318 case java_lang_math_sqrt : tty->print("java_lang_math_sqrt" ); break;
aoqi@0 319 case java_lang_math_log : tty->print("java_lang_math_log" ); break;
aoqi@0 320 case java_lang_math_log10 : tty->print("java_lang_math_log10" ); break;
aoqi@0 321 case java_util_zip_CRC32_update : tty->print("java_util_zip_CRC32_update"); break;
aoqi@0 322 case java_util_zip_CRC32_updateBytes : tty->print("java_util_zip_CRC32_updateBytes"); break;
aoqi@0 323 case java_util_zip_CRC32_updateByteBuffer : tty->print("java_util_zip_CRC32_updateByteBuffer"); break;
aoqi@0 324 default:
aoqi@0 325 if (kind >= method_handle_invoke_FIRST &&
aoqi@0 326 kind <= method_handle_invoke_LAST) {
aoqi@0 327 const char* kind_name = vmIntrinsics::name_at(method_handle_intrinsic(kind));
aoqi@0 328 if (kind_name[0] == '_') kind_name = &kind_name[1]; // '_invokeExact' => 'invokeExact'
aoqi@0 329 tty->print("method_handle_%s", kind_name);
aoqi@0 330 break;
aoqi@0 331 }
aoqi@0 332 ShouldNotReachHere();
aoqi@0 333 break;
aoqi@0 334 }
aoqi@0 335 }
aoqi@0 336 #endif // PRODUCT
aoqi@0 337
aoqi@0 338
aoqi@0 339 //------------------------------------------------------------------------------------------------------------------------
aoqi@0 340 // Deoptimization support
aoqi@0 341
aoqi@0 342 /**
aoqi@0 343 * If a deoptimization happens, this function returns the point of next bytecode to continue execution.
aoqi@0 344 */
aoqi@0 345 address AbstractInterpreter::deopt_continue_after_entry(Method* method, address bcp, int callee_parameters, bool is_top_frame) {
aoqi@0 346 assert(method->contains(bcp), "just checkin'");
aoqi@0 347
aoqi@0 348 // Get the original and rewritten bytecode.
aoqi@0 349 Bytecodes::Code code = Bytecodes::java_code_at(method, bcp);
aoqi@0 350 assert(!Interpreter::bytecode_should_reexecute(code), "should not reexecute");
aoqi@0 351
aoqi@0 352 const int bci = method->bci_from(bcp);
aoqi@0 353
aoqi@0 354 // compute continuation length
aoqi@0 355 const int length = Bytecodes::length_at(method, bcp);
aoqi@0 356
aoqi@0 357 // compute result type
aoqi@0 358 BasicType type = T_ILLEGAL;
aoqi@0 359
aoqi@0 360 switch (code) {
aoqi@0 361 case Bytecodes::_invokevirtual :
aoqi@0 362 case Bytecodes::_invokespecial :
aoqi@0 363 case Bytecodes::_invokestatic :
aoqi@0 364 case Bytecodes::_invokeinterface: {
aoqi@0 365 Thread *thread = Thread::current();
aoqi@0 366 ResourceMark rm(thread);
aoqi@0 367 methodHandle mh(thread, method);
aoqi@0 368 type = Bytecode_invoke(mh, bci).result_type();
aoqi@0 369 // since the cache entry might not be initialized:
aoqi@0 370 // (NOT needed for the old calling convension)
aoqi@0 371 if (!is_top_frame) {
aoqi@0 372 int index = Bytes::get_native_u2(bcp+1);
aoqi@0 373 method->constants()->cache()->entry_at(index)->set_parameter_size(callee_parameters);
aoqi@0 374 }
aoqi@0 375 break;
aoqi@0 376 }
aoqi@0 377
aoqi@0 378 case Bytecodes::_invokedynamic: {
aoqi@0 379 Thread *thread = Thread::current();
aoqi@0 380 ResourceMark rm(thread);
aoqi@0 381 methodHandle mh(thread, method);
aoqi@0 382 type = Bytecode_invoke(mh, bci).result_type();
aoqi@0 383 // since the cache entry might not be initialized:
aoqi@0 384 // (NOT needed for the old calling convension)
aoqi@0 385 if (!is_top_frame) {
aoqi@0 386 int index = Bytes::get_native_u4(bcp+1);
aoqi@0 387 method->constants()->invokedynamic_cp_cache_entry_at(index)->set_parameter_size(callee_parameters);
aoqi@0 388 }
aoqi@0 389 break;
aoqi@0 390 }
aoqi@0 391
aoqi@0 392 case Bytecodes::_ldc :
aoqi@0 393 case Bytecodes::_ldc_w : // fall through
aoqi@0 394 case Bytecodes::_ldc2_w:
aoqi@0 395 {
aoqi@0 396 Thread *thread = Thread::current();
aoqi@0 397 ResourceMark rm(thread);
aoqi@0 398 methodHandle mh(thread, method);
aoqi@0 399 type = Bytecode_loadconstant(mh, bci).result_type();
aoqi@0 400 break;
aoqi@0 401 }
aoqi@0 402
aoqi@0 403 default:
aoqi@0 404 type = Bytecodes::result_type(code);
aoqi@0 405 break;
aoqi@0 406 }
aoqi@0 407
aoqi@0 408 // return entry point for computed continuation state & bytecode length
aoqi@0 409 return
aoqi@0 410 is_top_frame
aoqi@0 411 ? Interpreter::deopt_entry (as_TosState(type), length)
aoqi@0 412 : Interpreter::return_entry(as_TosState(type), length, code);
aoqi@0 413 }
aoqi@0 414
aoqi@0 415 // If deoptimization happens, this function returns the point where the interpreter reexecutes
aoqi@0 416 // the bytecode.
aoqi@0 417 // Note: Bytecodes::_athrow is a special case in that it does not return
aoqi@0 418 // Interpreter::deopt_entry(vtos, 0) like others
aoqi@0 419 address AbstractInterpreter::deopt_reexecute_entry(Method* method, address bcp) {
aoqi@0 420 assert(method->contains(bcp), "just checkin'");
aoqi@0 421 Bytecodes::Code code = Bytecodes::java_code_at(method, bcp);
aoqi@0 422 #ifdef COMPILER1
aoqi@0 423 if(code == Bytecodes::_athrow ) {
aoqi@0 424 return Interpreter::rethrow_exception_entry();
aoqi@0 425 }
aoqi@0 426 #endif /* COMPILER1 */
aoqi@0 427 return Interpreter::deopt_entry(vtos, 0);
aoqi@0 428 }
aoqi@0 429
aoqi@0 430 // If deoptimization happens, the interpreter should reexecute these bytecodes.
aoqi@0 431 // This function mainly helps the compilers to set up the reexecute bit.
aoqi@0 432 bool AbstractInterpreter::bytecode_should_reexecute(Bytecodes::Code code) {
aoqi@0 433 switch (code) {
aoqi@0 434 case Bytecodes::_lookupswitch:
aoqi@0 435 case Bytecodes::_tableswitch:
aoqi@0 436 case Bytecodes::_fast_binaryswitch:
aoqi@0 437 case Bytecodes::_fast_linearswitch:
aoqi@0 438 // recompute condtional expression folded into _if<cond>
aoqi@0 439 case Bytecodes::_lcmp :
aoqi@0 440 case Bytecodes::_fcmpl :
aoqi@0 441 case Bytecodes::_fcmpg :
aoqi@0 442 case Bytecodes::_dcmpl :
aoqi@0 443 case Bytecodes::_dcmpg :
aoqi@0 444 case Bytecodes::_ifnull :
aoqi@0 445 case Bytecodes::_ifnonnull :
aoqi@0 446 case Bytecodes::_goto :
aoqi@0 447 case Bytecodes::_goto_w :
aoqi@0 448 case Bytecodes::_ifeq :
aoqi@0 449 case Bytecodes::_ifne :
aoqi@0 450 case Bytecodes::_iflt :
aoqi@0 451 case Bytecodes::_ifge :
aoqi@0 452 case Bytecodes::_ifgt :
aoqi@0 453 case Bytecodes::_ifle :
aoqi@0 454 case Bytecodes::_if_icmpeq :
aoqi@0 455 case Bytecodes::_if_icmpne :
aoqi@0 456 case Bytecodes::_if_icmplt :
aoqi@0 457 case Bytecodes::_if_icmpge :
aoqi@0 458 case Bytecodes::_if_icmpgt :
aoqi@0 459 case Bytecodes::_if_icmple :
aoqi@0 460 case Bytecodes::_if_acmpeq :
aoqi@0 461 case Bytecodes::_if_acmpne :
aoqi@0 462 // special cases
aoqi@0 463 case Bytecodes::_getfield :
aoqi@0 464 case Bytecodes::_putfield :
aoqi@0 465 case Bytecodes::_getstatic :
aoqi@0 466 case Bytecodes::_putstatic :
aoqi@0 467 case Bytecodes::_aastore :
aoqi@0 468 #ifdef COMPILER1
aoqi@0 469 //special case of reexecution
aoqi@0 470 case Bytecodes::_athrow :
aoqi@0 471 #endif
aoqi@0 472 return true;
aoqi@0 473
aoqi@0 474 default:
aoqi@0 475 return false;
aoqi@0 476 }
aoqi@0 477 }
aoqi@0 478
aoqi@0 479 void AbstractInterpreterGenerator::bang_stack_shadow_pages(bool native_call) {
aoqi@0 480 // Quick & dirty stack overflow checking: bang the stack & handle trap.
aoqi@0 481 // Note that we do the banging after the frame is setup, since the exception
aoqi@0 482 // handling code expects to find a valid interpreter frame on the stack.
aoqi@0 483 // Doing the banging earlier fails if the caller frame is not an interpreter
aoqi@0 484 // frame.
aoqi@0 485 // (Also, the exception throwing code expects to unlock any synchronized
aoqi@0 486 // method receiever, so do the banging after locking the receiver.)
aoqi@0 487
aoqi@0 488 // Bang each page in the shadow zone. We can't assume it's been done for
aoqi@0 489 // an interpreter frame with greater than a page of locals, so each page
aoqi@0 490 // needs to be checked. Only true for non-native.
aoqi@0 491 if (UseStackBanging) {
aoqi@0 492 const int start_page = native_call ? StackShadowPages : 1;
aoqi@0 493 const int page_size = os::vm_page_size();
aoqi@0 494 for (int pages = start_page; pages <= StackShadowPages ; pages++) {
aoqi@0 495 __ bang_stack_with_offset(pages*page_size);
aoqi@0 496 }
aoqi@0 497 }
aoqi@0 498 }
aoqi@0 499
aoqi@0 500 void AbstractInterpreterGenerator::initialize_method_handle_entries() {
aoqi@0 501 // method handle entry kinds are generated later in MethodHandlesAdapterGenerator::generate:
aoqi@0 502 for (int i = Interpreter::method_handle_invoke_FIRST; i <= Interpreter::method_handle_invoke_LAST; i++) {
aoqi@0 503 Interpreter::MethodKind kind = (Interpreter::MethodKind) i;
aoqi@0 504 Interpreter::_entry_table[kind] = Interpreter::_entry_table[Interpreter::abstract];
aoqi@0 505 }
aoqi@0 506 }

mercurial