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