src/hotspot/share/interpreter/bytecodeInterpreter.cpp
author mikael
Thu, 12 Jul 2018 17:29:48 -0700
changeset 51050 96ea37459ca7
parent 50736 f703d45c5687
child 54786 ebf733a324d4
permissions -rw-r--r--
8207011: Remove uses of the register storage class specifier Reviewed-by: kbarrett, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
     2
 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5426
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5426
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5426
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    25
// no precompiled headers
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    26
#include "classfile/vmSymbols.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30132
diff changeset
    27
#include "gc/shared/collectedHeap.hpp"
49597
cbfc09ce5f24 8200197: Zero fails to build after 8200105
enevill
parents: 49449
diff changeset
    28
#include "gc/shared/threadLocalAllocBuffer.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    29
#include "interpreter/bytecodeHistogram.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    30
#include "interpreter/bytecodeInterpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    31
#include "interpreter/bytecodeInterpreter.inline.hpp"
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
    32
#include "interpreter/bytecodeInterpreterProfiling.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    33
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    34
#include "interpreter/interpreterRuntime.hpp"
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 33749
diff changeset
    35
#include "logging/log.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    36
#include "memory/resourceArea.hpp"
49390
95f0b54a3024 8199220: Zero build broken after 8195103, 8191102 and 8189871
enevill
parents: 49368
diff changeset
    37
#include "oops/constantPool.inline.hpp"
95f0b54a3024 8199220: Zero build broken after 8195103, 8191102 and 8189871
enevill
parents: 49368
diff changeset
    38
#include "oops/cpCache.inline.hpp"
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48887
diff changeset
    39
#include "oops/method.inline.hpp"
17314
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
    40
#include "oops/methodCounters.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    41
#include "oops/objArrayKlass.hpp"
29468
fb61ea6af339 8074543: Missing symbol "objArrayOopDesc::obj_at" when buiding with CPP Interpreter
stefank
parents: 28650
diff changeset
    42
#include "oops/objArrayOop.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    43
#include "oops/oop.inline.hpp"
49390
95f0b54a3024 8199220: Zero build broken after 8195103, 8191102 and 8189871
enevill
parents: 49368
diff changeset
    44
#include "oops/typeArrayOop.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    45
#include "prims/jvmtiExport.hpp"
22816
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
    46
#include "prims/jvmtiThreadState.hpp"
40655
9f644073d3a0 8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents: 38063
diff changeset
    47
#include "runtime/atomic.hpp"
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
    48
#include "runtime/biasedLocking.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    49
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    50
#include "runtime/handles.inline.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49390
diff changeset
    51
#include "runtime/interfaceSupport.inline.hpp"
50429
83aec1d357d4 8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents: 49722
diff changeset
    52
#include "runtime/orderAccess.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    53
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    54
#include "runtime/threadCritical.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6271
diff changeset
    55
#include "utilities/exceptions.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
// no precompiled headers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
#ifdef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
 * USELABELS - If using GCC, then use labels for the opcode dispatching
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
 * rather -then a switch statement. This improves performance because it
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 26705
diff changeset
    63
 * gives us the opportunity to have the instructions that calculate the
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
 * next opcode to jump to be intermixed with the rest of the instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
 * that implement the opcode (see UPDATE_PC_AND_TOS_AND_CONTINUE macro).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
#undef USELABELS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
#ifdef __GNUC__
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
   ASSERT signifies debugging. It is much easier to step thru bytecodes if we
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
   don't use the computed goto approach.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
*/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
#ifndef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
#define USELABELS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
#undef CASE
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
#ifdef USELABELS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
#define CASE(opcode) opc ## opcode
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
#define DEFAULT opc_default
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
#define CASE(opcode) case Bytecodes:: opcode
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
#define DEFAULT default
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
 * PREFETCH_OPCCODE - Some compilers do better if you prefetch the next
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
 * opcode before going back to the top of the while loop, rather then having
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
 * the top of the while loop handle it. This provides a better opportunity
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
 * for instruction scheduling. Some compilers just do this prefetch
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
 * automatically. Some actually end up with worse performance if you
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
 * force the prefetch. Solaris gcc seems to do better, but cc does worse.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
#undef PREFETCH_OPCCODE
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
#define PREFETCH_OPCCODE
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  Interpreter safepoint: it is expected that the interpreter will have no live
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  handles of its own creation live at an interpreter safepoint. Therefore we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  run a HandleMarkCleaner and trash all handles allocated in the call chain
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  since the JavaCalls::call_helper invocation that initiated the chain.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  There really shouldn't be any handles remaining to trash but this is cheap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  in relation to a safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
*/
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
#define SAFEPOINT                                                                 \
47906
0ad8a90268a7 8191333: Zero variant broken after 8189941
glaubitz
parents: 47687
diff changeset
   107
    {                                                                             \
0ad8a90268a7 8191333: Zero variant broken after 8189941
glaubitz
parents: 47687
diff changeset
   108
       /* zap freed handles rather than GC'ing them */                            \
0ad8a90268a7 8191333: Zero variant broken after 8189941
glaubitz
parents: 47687
diff changeset
   109
       HandleMarkCleaner __hmc(THREAD);                                           \
0ad8a90268a7 8191333: Zero variant broken after 8189941
glaubitz
parents: 47687
diff changeset
   110
       CALL_VM(SafepointMechanism::block_if_requested(THREAD), handle_exception); \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
 * VM_JAVA_ERROR - Macro for throwing a java exception from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
 * the interpreter loop. Should really be a CALL_VM but there
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
 * is no entry point to do the transition to vm so we just
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
 * do it by hand here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
 */
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   119
#define VM_JAVA_ERROR_NO_JUMP(name, msg, note_a_trap)                             \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    DECACHE_STATE();                                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    SET_LAST_JAVA_FRAME();                                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    {                                                                             \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   123
       InterpreterRuntime::note_a_trap(THREAD, istate->method(), BCI());          \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
       ThreadInVMfromJava trans(THREAD);                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
       Exceptions::_throw_msg(THREAD, __FILE__, __LINE__, name, msg);             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    }                                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    RESET_LAST_JAVA_FRAME();                                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    CACHE_STATE();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   130
// Normal throw of a java error.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   131
#define VM_JAVA_ERROR(name, msg, note_a_trap)                                     \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   132
    VM_JAVA_ERROR_NO_JUMP(name, msg, note_a_trap)                                 \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    goto handle_exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
#ifdef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
#define DO_UPDATE_INSTRUCTION_COUNT(opcode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
#define DO_UPDATE_INSTRUCTION_COUNT(opcode)                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
{                                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    BytecodeCounter::_counter_value++;                                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    BytecodeHistogram::_counters[(Bytecodes::Code)opcode]++;                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    if (StopInterpreterAt && StopInterpreterAt == BytecodeCounter::_counter_value) os::breakpoint(); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    if (TraceBytecodes) {                                                                            \
37152
29e68f1d35bb 8152065: TraceBytecodes breaks the interpreter expression stack
coleenp
parents: 35928
diff changeset
   144
      CALL_VM((void)InterpreterRuntime::trace_bytecode(THREAD, 0,                    \
29e68f1d35bb 8152065: TraceBytecodes breaks the interpreter expression stack
coleenp
parents: 35928
diff changeset
   145
                                        topOfStack[Interpreter::expr_index_at(1)],   \
29e68f1d35bb 8152065: TraceBytecodes breaks the interpreter expression stack
coleenp
parents: 35928
diff changeset
   146
                                        topOfStack[Interpreter::expr_index_at(2)]),  \
29e68f1d35bb 8152065: TraceBytecodes breaks the interpreter expression stack
coleenp
parents: 35928
diff changeset
   147
                                        handle_exception);                           \
29e68f1d35bb 8152065: TraceBytecodes breaks the interpreter expression stack
coleenp
parents: 35928
diff changeset
   148
    }                                                                                \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
#undef DEBUGGER_SINGLE_STEP_NOTIFY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
#ifdef VM_JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
/* NOTE: (kbr) This macro must be called AFTER the PC has been
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
   incremented. JvmtiExport::at_single_stepping_point() may cause a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
   breakpoint opcode to get inserted at the current PC to allow the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
   debugger to coalesce single-step events.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
   As a result if we call at_single_stepping_point() we refetch opcode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
   to get the current opcode. This will override any other prefetching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
   that might have occurred.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
*/
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
#define DEBUGGER_SINGLE_STEP_NOTIFY()                                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
{                                                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
      if (_jvmti_interp_events) {                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
        if (JvmtiExport::should_post_single_step()) {                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
          DECACHE_STATE();                                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
          SET_LAST_JAVA_FRAME();                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
          ThreadInVMfromJava trans(THREAD);                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
          JvmtiExport::at_single_stepping_point(THREAD,                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
                                          istate->method(),                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
                                          pc);                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
          RESET_LAST_JAVA_FRAME();                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
          CACHE_STATE();                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
          if (THREAD->pop_frame_pending() &&                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
              !THREAD->pop_frame_in_process()) {                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
            goto handle_Pop_Frame;                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
          }                                                                      \
22816
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   179
          if (THREAD->jvmti_thread_state() &&                                    \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   180
              THREAD->jvmti_thread_state()->is_earlyret_pending()) {             \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   181
            goto handle_Early_Return;                                            \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   182
          }                                                                      \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
          opcode = *pc;                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
        }                                                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
      }                                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
#define DEBUGGER_SINGLE_STEP_NOTIFY()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
 * CONTINUE - Macro for executing the next opcode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
#undef CONTINUE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
#ifdef USELABELS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
// Have to do this dispatch this way in C++ because otherwise gcc complains about crossing an
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
// initialization (which is is the initialization of the table pointer...)
1896
cce23a9ff495 6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents: 670
diff changeset
   198
#define DISPATCH(opcode) goto *(void*)dispatch_table[opcode]
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
#define CONTINUE {                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
        opcode = *pc;                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
        DO_UPDATE_INSTRUCTION_COUNT(opcode);    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
        DEBUGGER_SINGLE_STEP_NOTIFY();          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
        DISPATCH(opcode);                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
#ifdef PREFETCH_OPCCODE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
#define CONTINUE {                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
        opcode = *pc;                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
        DO_UPDATE_INSTRUCTION_COUNT(opcode);    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
        DEBUGGER_SINGLE_STEP_NOTIFY();          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
        continue;                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
#define CONTINUE {                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
        DO_UPDATE_INSTRUCTION_COUNT(opcode);    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
        DEBUGGER_SINGLE_STEP_NOTIFY();          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
        continue;                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
#define UPDATE_PC(opsize) {pc += opsize; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
 * UPDATE_PC_AND_TOS - Macro for updating the pc and topOfStack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
#undef UPDATE_PC_AND_TOS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
#define UPDATE_PC_AND_TOS(opsize, stack) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    {pc += opsize; MORE_STACK(stack); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
 * UPDATE_PC_AND_TOS_AND_CONTINUE - Macro for updating the pc and topOfStack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
 * and executing the next opcode. It's somewhat similar to the combination
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
 * of UPDATE_PC_AND_TOS and CONTINUE, but with some minor optimizations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
#undef UPDATE_PC_AND_TOS_AND_CONTINUE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
#ifdef USELABELS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
#define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) {         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
        pc += opsize; opcode = *pc; MORE_STACK(stack);          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
        DO_UPDATE_INSTRUCTION_COUNT(opcode);                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
        DEBUGGER_SINGLE_STEP_NOTIFY();                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
        DISPATCH(opcode);                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
#define UPDATE_PC_AND_CONTINUE(opsize) {                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
        pc += opsize; opcode = *pc;                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
        DO_UPDATE_INSTRUCTION_COUNT(opcode);                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
        DEBUGGER_SINGLE_STEP_NOTIFY();                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
        DISPATCH(opcode);                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
#ifdef PREFETCH_OPCCODE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
#define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) {         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
        pc += opsize; opcode = *pc; MORE_STACK(stack);          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
        DO_UPDATE_INSTRUCTION_COUNT(opcode);                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
        DEBUGGER_SINGLE_STEP_NOTIFY();                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
        goto do_continue;                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
#define UPDATE_PC_AND_CONTINUE(opsize) {                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
        pc += opsize; opcode = *pc;                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
        DO_UPDATE_INSTRUCTION_COUNT(opcode);                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
        DEBUGGER_SINGLE_STEP_NOTIFY();                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
        goto do_continue;                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
#define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
        pc += opsize; MORE_STACK(stack);                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
        DO_UPDATE_INSTRUCTION_COUNT(opcode);            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
        DEBUGGER_SINGLE_STEP_NOTIFY();                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
        goto do_continue;                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
#define UPDATE_PC_AND_CONTINUE(opsize) {                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
        pc += opsize;                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
        DO_UPDATE_INSTRUCTION_COUNT(opcode);            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
        DEBUGGER_SINGLE_STEP_NOTIFY();                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
        goto do_continue;                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
#endif /* PREFETCH_OPCCODE */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
#endif /* USELABELS */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
// About to call a new method, update the save the adjusted pc and return to frame manager
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
#define UPDATE_PC_AND_RETURN(opsize)  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
   DECACHE_TOS();                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
   istate->set_bcp(pc+opsize);        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
   return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
#define METHOD istate->method()
17314
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   291
#define GET_METHOD_COUNTERS(res)    \
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   292
  res = METHOD->method_counters();  \
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   293
  if (res == NULL) {                \
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   294
    CALL_VM(res = InterpreterRuntime::build_method_counters(THREAD, METHOD), handle_exception); \
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   295
  }
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   296
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
#define OSR_REQUEST(res, branch_pc) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
            CALL_VM(res=InterpreterRuntime::frequency_counter_overflow(THREAD, branch_pc), handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
 * For those opcodes that need to have a GC point on a backwards branch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
// Backedge counting is kind of strange. The asm interpreter will increment
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
// the backedge counter as a separate counter but it does it's comparisons
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
// to the sum (scaled) of invocation counter and backedge count to make
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
// a decision. Seems kind of odd to sum them together like that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
// skip is delta from current bcp/bci for target, branch_pc is pre-branch bcp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
#define DO_BACKEDGE_CHECKS(skip, branch_pc)                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    if ((skip) <= 0) {                                                                              \
17314
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   313
      MethodCounters* mcs;                                                                          \
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   314
      GET_METHOD_COUNTERS(mcs);                                                                     \
4448
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   315
      if (UseLoopCounter) {                                                                         \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
        bool do_OSR = UseOnStackReplacement;                                                        \
17314
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   317
        mcs->backedge_counter()->increment();                                                       \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   318
        if (ProfileInterpreter) {                                                                   \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   319
          BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception);                                   \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   320
          /* Check for overflow against MDO count. */                                               \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   321
          do_OSR = do_OSR                                                                           \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   322
            && (mdo_last_branch_taken_count >= (uint)InvocationCounter::InterpreterBackwardBranchLimit)\
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   323
            /* When ProfileInterpreter is on, the backedge_count comes     */                       \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   324
            /* from the methodDataOop, which value does not get reset on   */                       \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   325
            /* the call to frequency_counter_overflow(). To avoid          */                       \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   326
            /* excessive calls to the overflow routine while the method is */                       \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   327
            /* being compiled, add a second test to make sure the overflow */                       \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   328
            /* function is called only once every overflow_frequency.      */                       \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   329
            && (!(mdo_last_branch_taken_count & 1023));                                             \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   330
        } else {                                                                                    \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   331
          /* check for overflow of backedge counter */                                              \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   332
          do_OSR = do_OSR                                                                           \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   333
            && mcs->invocation_counter()->reached_InvocationLimit(mcs->backedge_counter());         \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   334
        }                                                                                           \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
        if (do_OSR) {                                                                               \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   336
          nmethod* osr_nmethod;                                                                     \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
          OSR_REQUEST(osr_nmethod, branch_pc);                                                      \
26705
fca1785e7084 8048721: -XX:+PrintCompilation prints negative bci for non entrant OSR methods
thartmann
parents: 26142
diff changeset
   338
          if (osr_nmethod != NULL && osr_nmethod->is_in_use()) {                                    \
22833
92d74f188f73 8024469: PPC64 (part 202): cppInterpreter: support for OSR.
goetz
parents: 22827
diff changeset
   339
            intptr_t* buf;                                                                          \
92d74f188f73 8024469: PPC64 (part 202): cppInterpreter: support for OSR.
goetz
parents: 22827
diff changeset
   340
            /* Call OSR migration with last java frame only, no checks. */                          \
92d74f188f73 8024469: PPC64 (part 202): cppInterpreter: support for OSR.
goetz
parents: 22827
diff changeset
   341
            CALL_VM_NAKED_LJF(buf=SharedRuntime::OSR_migration_begin(THREAD));                      \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
            istate->set_msg(do_osr);                                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
            istate->set_osr_buf((address)buf);                                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
            istate->set_osr_entry(osr_nmethod->osr_entry());                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
            return;                                                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
          }                                                                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
        }                                                                                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
      }  /* UseCompiler ... */                                                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
      SAFEPOINT;                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
 * For those opcodes that need to have a GC point on a backwards branch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
 * Macros for caching and flushing the interpreter state. Some local
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
 * variables need to be flushed out to the frame before we do certain
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
 * things (like pushing frames or becomming gc safe) and some need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
 * be recached later (like after popping a frame). We could use one
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
 * macro to cache or decache everything, but this would be less then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
 * optimal because we don't always need to cache or decache everything
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
 * because some things we know are already cached or decached.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
#undef DECACHE_TOS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
#undef CACHE_TOS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
#undef CACHE_PREV_TOS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
#define DECACHE_TOS()    istate->set_stack(topOfStack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
#define CACHE_TOS()      topOfStack = (intptr_t *)istate->stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
#undef DECACHE_PC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
#undef CACHE_PC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
#define DECACHE_PC()    istate->set_bcp(pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
#define CACHE_PC()      pc = istate->bcp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
#define CACHE_CP()      cp = istate->constants();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
#define CACHE_LOCALS()  locals = istate->locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
#undef CACHE_FRAME
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
#define CACHE_FRAME()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   381
// BCI() returns the current bytecode-index.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   382
#undef  BCI
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   383
#define BCI()           ((int)(intptr_t)(pc - (intptr_t)istate->method()->code_base()))
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   384
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
 * CHECK_NULL - Macro for throwing a NullPointerException if the object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
 * passed is a null ref.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
 * On some architectures/platforms it should be possible to do this implicitly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
#undef CHECK_NULL
22878
206db4a4adcc 8035392: cppInterpreter: fix message of NPE
goetz
parents: 22872
diff changeset
   391
#define CHECK_NULL(obj_)                                                                         \
206db4a4adcc 8035392: cppInterpreter: fix message of NPE
goetz
parents: 22872
diff changeset
   392
        if ((obj_) == NULL) {                                                                    \
206db4a4adcc 8035392: cppInterpreter: fix message of NPE
goetz
parents: 22872
diff changeset
   393
          VM_JAVA_ERROR(vmSymbols::java_lang_NullPointerException(), NULL, note_nullCheck_trap); \
206db4a4adcc 8035392: cppInterpreter: fix message of NPE
goetz
parents: 22872
diff changeset
   394
        }                                                                                        \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   395
        VERIFY_OOP(obj_)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
#define VMdoubleConstZero() 0.0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
#define VMdoubleConstOne() 1.0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
#define VMlongConstZero() (max_jlong-max_jlong)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
#define VMlongConstOne() ((max_jlong-max_jlong)+1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
 * Alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
#define VMalignWordUp(val)          (((uintptr_t)(val) + 3) & ~3)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
// Decache the interpreter state that interpreter modifies directly (i.e. GC is indirect mod)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
#define DECACHE_STATE() DECACHE_PC(); DECACHE_TOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
// Reload interpreter state after calling the VM or a possible GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
#define CACHE_STATE()   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
        CACHE_TOS();    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
        CACHE_PC();     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
        CACHE_CP();     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
        CACHE_LOCALS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
22833
92d74f188f73 8024469: PPC64 (part 202): cppInterpreter: support for OSR.
goetz
parents: 22827
diff changeset
   417
// Call the VM with last java frame only.
92d74f188f73 8024469: PPC64 (part 202): cppInterpreter: support for OSR.
goetz
parents: 22827
diff changeset
   418
#define CALL_VM_NAKED_LJF(func)                                    \
22816
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   419
        DECACHE_STATE();                                           \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   420
        SET_LAST_JAVA_FRAME();                                     \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   421
        func;                                                      \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   422
        RESET_LAST_JAVA_FRAME();                                   \
22833
92d74f188f73 8024469: PPC64 (part 202): cppInterpreter: support for OSR.
goetz
parents: 22827
diff changeset
   423
        CACHE_STATE();
92d74f188f73 8024469: PPC64 (part 202): cppInterpreter: support for OSR.
goetz
parents: 22827
diff changeset
   424
92d74f188f73 8024469: PPC64 (part 202): cppInterpreter: support for OSR.
goetz
parents: 22827
diff changeset
   425
// Call the VM. Don't check for pending exceptions.
92d74f188f73 8024469: PPC64 (part 202): cppInterpreter: support for OSR.
goetz
parents: 22827
diff changeset
   426
#define CALL_VM_NOCHECK(func)                                      \
92d74f188f73 8024469: PPC64 (part 202): cppInterpreter: support for OSR.
goetz
parents: 22827
diff changeset
   427
        CALL_VM_NAKED_LJF(func)                                    \
22816
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   428
        if (THREAD->pop_frame_pending() &&                         \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   429
            !THREAD->pop_frame_in_process()) {                     \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   430
          goto handle_Pop_Frame;                                   \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   431
        }                                                          \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   432
        if (THREAD->jvmti_thread_state() &&                        \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   433
            THREAD->jvmti_thread_state()->is_earlyret_pending()) { \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   434
          goto handle_Early_Return;                                \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   435
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
// Call the VM and check for pending exceptions
22816
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   438
#define CALL_VM(func, label) {                                     \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   439
          CALL_VM_NOCHECK(func);                                   \
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   440
          if (THREAD->has_pending_exception()) goto label;         \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
 * BytecodeInterpreter::run(interpreterState istate)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
 * BytecodeInterpreter::runWithChecks(interpreterState istate)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
 * The real deal. This is where byte codes actually get interpreted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
 * Basically it's a big while loop that iterates until we return from
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
 * the method passed in.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
 * The runWithChecks is used if JVMTI is enabled.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
#if defined(VM_JVMTI)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
void
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
BytecodeInterpreter::runWithChecks(interpreterState istate) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
void
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
BytecodeInterpreter::run(interpreterState istate) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  // In order to simplify some tests based on switches set at runtime
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  // we invoke the interpreter a single time after switches are enabled
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  // and set simpler to to test variables rather than method calls or complex
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  // boolean expressions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  static int initialized = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  static int checkit = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  static intptr_t* c_addr = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  static intptr_t  c_value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  if (checkit && *c_addr != c_value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
    os::breakpoint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
#ifdef VM_JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  static bool _jvmti_interp_events = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  static int _compiling;  // (UseCompiler || CountCompiledCalls)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  if (istate->_msg != initialize) {
24322
c2978d1578e3 8036956: remove EnableInvokeDynamic flag
anoll
parents: 23203
diff changeset
   483
    assert(labs(istate->_stack_base - istate->_stack_limit) == (istate->_method->max_stack() + 1), "bad stack limit");
6271
271ac8e393e4 6977640: Zero and Shark fixes
twisti
parents: 6176
diff changeset
   484
    IA32_ONLY(assert(istate->_stack_limit == istate->_thread->last_Java_sp() + 1, "wrong"));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  // Verify linkages.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  interpreterState l = istate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
    assert(l == l->_self_link, "bad link");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
    l = l->_prev_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  } while (l != NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  // Screwups with stack management usually cause us to overwrite istate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  // save a copy so we can verify it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  interpreterState orig = istate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
51050
96ea37459ca7 8207011: Remove uses of the register storage class specifier
mikael
parents: 50736
diff changeset
   497
  intptr_t*        topOfStack = (intptr_t *)istate->stack(); /* access with STACK macros */
96ea37459ca7 8207011: Remove uses of the register storage class specifier
mikael
parents: 50736
diff changeset
   498
  address          pc = istate->bcp();
96ea37459ca7 8207011: Remove uses of the register storage class specifier
mikael
parents: 50736
diff changeset
   499
  jubyte opcode;
96ea37459ca7 8207011: Remove uses of the register storage class specifier
mikael
parents: 50736
diff changeset
   500
  intptr_t*        locals = istate->locals();
96ea37459ca7 8207011: Remove uses of the register storage class specifier
mikael
parents: 50736
diff changeset
   501
  ConstantPoolCache*    cp = istate->constants(); // method()->constants()->cache()
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
#ifdef LOTS_OF_REGS
51050
96ea37459ca7 8207011: Remove uses of the register storage class specifier
mikael
parents: 50736
diff changeset
   503
  JavaThread*      THREAD = istate->thread();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
#undef THREAD
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
#define THREAD istate->thread()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
#ifdef USELABELS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  const static void* const opclabels_data[256] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
/* 0x00 */ &&opc_nop,     &&opc_aconst_null,&&opc_iconst_m1,&&opc_iconst_0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
/* 0x04 */ &&opc_iconst_1,&&opc_iconst_2,   &&opc_iconst_3, &&opc_iconst_4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
/* 0x08 */ &&opc_iconst_5,&&opc_lconst_0,   &&opc_lconst_1, &&opc_fconst_0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
/* 0x0C */ &&opc_fconst_1,&&opc_fconst_2,   &&opc_dconst_0, &&opc_dconst_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
/* 0x10 */ &&opc_bipush, &&opc_sipush, &&opc_ldc,    &&opc_ldc_w,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
/* 0x14 */ &&opc_ldc2_w, &&opc_iload,  &&opc_lload,  &&opc_fload,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
/* 0x18 */ &&opc_dload,  &&opc_aload,  &&opc_iload_0,&&opc_iload_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
/* 0x1C */ &&opc_iload_2,&&opc_iload_3,&&opc_lload_0,&&opc_lload_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
/* 0x20 */ &&opc_lload_2,&&opc_lload_3,&&opc_fload_0,&&opc_fload_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
/* 0x24 */ &&opc_fload_2,&&opc_fload_3,&&opc_dload_0,&&opc_dload_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
/* 0x28 */ &&opc_dload_2,&&opc_dload_3,&&opc_aload_0,&&opc_aload_1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
/* 0x2C */ &&opc_aload_2,&&opc_aload_3,&&opc_iaload, &&opc_laload,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
/* 0x30 */ &&opc_faload,  &&opc_daload,  &&opc_aaload,  &&opc_baload,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
/* 0x34 */ &&opc_caload,  &&opc_saload,  &&opc_istore,  &&opc_lstore,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
/* 0x38 */ &&opc_fstore,  &&opc_dstore,  &&opc_astore,  &&opc_istore_0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
/* 0x3C */ &&opc_istore_1,&&opc_istore_2,&&opc_istore_3,&&opc_lstore_0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
/* 0x40 */ &&opc_lstore_1,&&opc_lstore_2,&&opc_lstore_3,&&opc_fstore_0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
/* 0x44 */ &&opc_fstore_1,&&opc_fstore_2,&&opc_fstore_3,&&opc_dstore_0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
/* 0x48 */ &&opc_dstore_1,&&opc_dstore_2,&&opc_dstore_3,&&opc_astore_0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
/* 0x4C */ &&opc_astore_1,&&opc_astore_2,&&opc_astore_3,&&opc_iastore,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
/* 0x50 */ &&opc_lastore,&&opc_fastore,&&opc_dastore,&&opc_aastore,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
/* 0x54 */ &&opc_bastore,&&opc_castore,&&opc_sastore,&&opc_pop,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
/* 0x58 */ &&opc_pop2,   &&opc_dup,    &&opc_dup_x1, &&opc_dup_x2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
/* 0x5C */ &&opc_dup2,   &&opc_dup2_x1,&&opc_dup2_x2,&&opc_swap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
/* 0x60 */ &&opc_iadd,&&opc_ladd,&&opc_fadd,&&opc_dadd,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
/* 0x64 */ &&opc_isub,&&opc_lsub,&&opc_fsub,&&opc_dsub,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
/* 0x68 */ &&opc_imul,&&opc_lmul,&&opc_fmul,&&opc_dmul,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
/* 0x6C */ &&opc_idiv,&&opc_ldiv,&&opc_fdiv,&&opc_ddiv,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
/* 0x70 */ &&opc_irem, &&opc_lrem, &&opc_frem,&&opc_drem,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
/* 0x74 */ &&opc_ineg, &&opc_lneg, &&opc_fneg,&&opc_dneg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
/* 0x78 */ &&opc_ishl, &&opc_lshl, &&opc_ishr,&&opc_lshr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
/* 0x7C */ &&opc_iushr,&&opc_lushr,&&opc_iand,&&opc_land,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
/* 0x80 */ &&opc_ior, &&opc_lor,&&opc_ixor,&&opc_lxor,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
/* 0x84 */ &&opc_iinc,&&opc_i2l,&&opc_i2f, &&opc_i2d,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
/* 0x88 */ &&opc_l2i, &&opc_l2f,&&opc_l2d, &&opc_f2i,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
/* 0x8C */ &&opc_f2l, &&opc_f2d,&&opc_d2i, &&opc_d2l,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
/* 0x90 */ &&opc_d2f,  &&opc_i2b,  &&opc_i2c,  &&opc_i2s,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
/* 0x94 */ &&opc_lcmp, &&opc_fcmpl,&&opc_fcmpg,&&opc_dcmpl,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
/* 0x98 */ &&opc_dcmpg,&&opc_ifeq, &&opc_ifne, &&opc_iflt,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
/* 0x9C */ &&opc_ifge, &&opc_ifgt, &&opc_ifle, &&opc_if_icmpeq,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
/* 0xA0 */ &&opc_if_icmpne,&&opc_if_icmplt,&&opc_if_icmpge,  &&opc_if_icmpgt,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
/* 0xA4 */ &&opc_if_icmple,&&opc_if_acmpeq,&&opc_if_acmpne,  &&opc_goto,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
/* 0xA8 */ &&opc_jsr,      &&opc_ret,      &&opc_tableswitch,&&opc_lookupswitch,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
/* 0xAC */ &&opc_ireturn,  &&opc_lreturn,  &&opc_freturn,    &&opc_dreturn,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
/* 0xB0 */ &&opc_areturn,     &&opc_return,         &&opc_getstatic,    &&opc_putstatic,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
/* 0xB4 */ &&opc_getfield,    &&opc_putfield,       &&opc_invokevirtual,&&opc_invokespecial,
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
   568
/* 0xB8 */ &&opc_invokestatic,&&opc_invokeinterface,&&opc_invokedynamic,&&opc_new,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
/* 0xBC */ &&opc_newarray,    &&opc_anewarray,      &&opc_arraylength,  &&opc_athrow,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
/* 0xC0 */ &&opc_checkcast,   &&opc_instanceof,     &&opc_monitorenter, &&opc_monitorexit,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
/* 0xC4 */ &&opc_wide,        &&opc_multianewarray, &&opc_ifnull,       &&opc_ifnonnull,
370
33ba64c16c1f 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 1
diff changeset
   573
/* 0xC8 */ &&opc_goto_w,      &&opc_jsr_w,          &&opc_breakpoint,   &&opc_default,
33ba64c16c1f 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 1
diff changeset
   574
/* 0xCC */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
33ba64c16c1f 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 1
diff changeset
   575
33ba64c16c1f 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 1
diff changeset
   576
/* 0xD0 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
/* 0xD4 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
/* 0xD8 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
/* 0xDC */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
30117
cce2cdac56dc 8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents: 29468
diff changeset
   581
/* 0xE0 */ &&opc_default,     &&opc_default,        &&opc_default,         &&opc_default,
38063
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37480
diff changeset
   582
/* 0xE4 */ &&opc_default,     &&opc_default,        &&opc_fast_aldc,    &&opc_fast_aldc_w,
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37480
diff changeset
   583
/* 0xE8 */ &&opc_return_register_finalizer,
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37480
diff changeset
   584
                              &&opc_invokehandle,   &&opc_default,      &&opc_default,
30126
89b8253271bd 8076181: bytecodeInterpreter.cpp refers to unknown labels.
sgehwolf
parents: 30117
diff changeset
   585
/* 0xEC */ &&opc_default,     &&opc_default,        &&opc_default,         &&opc_default,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
/* 0xF0 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
/* 0xF4 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
/* 0xF8 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
/* 0xFC */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  };
51050
96ea37459ca7 8207011: Remove uses of the register storage class specifier
mikael
parents: 50736
diff changeset
   592
  uintptr_t *dispatch_table = (uintptr_t*)&opclabels_data[0];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
#endif /* USELABELS */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  // this will trigger a VERIFY_OOP on entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  if (istate->msg() != initialize && ! METHOD->is_static()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
    oop rcvr = LOCALS_OBJECT(0);
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   599
    VERIFY_OOP(rcvr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  /* QQQ this should be a stack method so we don't know actual direction */
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   604
  guarantee(istate->msg() == initialize ||
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
         topOfStack >= istate->stack_limit() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
         topOfStack < istate->stack_base(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
         "Stack top out of range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   609
#ifdef CC_INTERP_PROFILE
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   610
  // MethodData's last branch taken count.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   611
  uint mdo_last_branch_taken_count = 0;
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   612
#else
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   613
  const uint mdo_last_branch_taken_count = 0;
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   614
#endif
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   615
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  switch (istate->msg()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
    case initialize: {
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   618
      if (initialized++) ShouldNotReachHere(); // Only one initialize call.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
      _compiling = (UseCompiler || CountCompiledCalls);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
#ifdef VM_JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
      _jvmti_interp_events = JvmtiExport::can_post_interpreter_events();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
    case method_entry: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
      THREAD->set_do_not_unlock();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
      // count invocations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
      assert(initialized, "Interpreter not initialized");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
      if (_compiling) {
17314
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   631
        MethodCounters* mcs;
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   632
        GET_METHOD_COUNTERS(mcs);
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 36508
diff changeset
   633
#if COMPILER2_OR_JVMCI
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
        if (ProfileInterpreter) {
17314
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   635
          METHOD->increment_interpreter_invocation_count(THREAD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
        }
37272
c427db4ea8c4 8148639: Some MethodCounter fields can be excluded when not including C2
cjplummer
parents: 36508
diff changeset
   637
#endif
17314
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15475
diff changeset
   638
        mcs->invocation_counter()->increment();
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   639
        if (mcs->invocation_counter()->reached_InvocationLimit(mcs->backedge_counter())) {
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   640
          CALL_VM((void)InterpreterRuntime::frequency_counter_overflow(THREAD, NULL), handle_exception);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   641
          // We no longer retry on a counter overflow.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
        }
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   643
        // Get or create profile data. Check for pending (async) exceptions.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   644
        BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
        SAFEPOINT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
      if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
        // initialize
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
        os::breakpoint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   653
      // Lock method if synchronized.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
      if (METHOD->is_synchronized()) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   655
        // oop rcvr = locals[0].j.r;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   656
        oop rcvr;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   657
        if (METHOD->is_static()) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   658
          rcvr = METHOD->constants()->pool_holder()->java_mirror();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   659
        } else {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   660
          rcvr = LOCALS_OBJECT(0);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   661
          VERIFY_OOP(rcvr);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   662
        }
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   663
        // The initial monitor is ours for the taking.
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   664
        // Monitor not filled in frame manager any longer as this caused race condition with biased locking.
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   665
        BasicObjectLock* mon = &istate->monitor_base()[-1];
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   666
        mon->set_obj(rcvr);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   667
        bool success = false;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   668
        uintptr_t epoch_mask_in_place = (uintptr_t)markOopDesc::epoch_mask_in_place;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   669
        markOop mark = rcvr->mark();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   670
        intptr_t hash = (intptr_t) markOopDesc::no_hash;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   671
        // Implies UseBiasedLocking.
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   672
        if (mark->has_bias_pattern()) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   673
          uintptr_t thread_ident;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   674
          uintptr_t anticipated_bias_locking_value;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   675
          thread_ident = (uintptr_t)istate->thread();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   676
          anticipated_bias_locking_value =
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   677
            (((uintptr_t)rcvr->klass()->prototype_header() | thread_ident) ^ (uintptr_t)mark) &
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   678
            ~((uintptr_t) markOopDesc::age_mask_in_place);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   679
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   680
          if (anticipated_bias_locking_value == 0) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   681
            // Already biased towards this thread, nothing to do.
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   682
            if (PrintBiasedLockingStatistics) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   683
              (* BiasedLocking::biased_lock_entry_count_addr())++;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   684
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   685
            success = true;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   686
          } else if ((anticipated_bias_locking_value & markOopDesc::biased_lock_mask_in_place) != 0) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   687
            // Try to revoke bias.
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   688
            markOop header = rcvr->klass()->prototype_header();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   689
            if (hash != markOopDesc::no_hash) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   690
              header = header->copy_set_hash(hash);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   691
            }
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
   692
            if (rcvr->cas_set_mark(header, mark) == mark) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   693
              if (PrintBiasedLockingStatistics)
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   694
                (*BiasedLocking::revoked_lock_entry_count_addr())++;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   695
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   696
          } else if ((anticipated_bias_locking_value & epoch_mask_in_place) != 0) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   697
            // Try to rebias.
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   698
            markOop new_header = (markOop) ( (intptr_t) rcvr->klass()->prototype_header() | thread_ident);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   699
            if (hash != markOopDesc::no_hash) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   700
              new_header = new_header->copy_set_hash(hash);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   701
            }
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
   702
            if (rcvr->cas_set_mark(new_header, mark) == mark) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   703
              if (PrintBiasedLockingStatistics) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   704
                (* BiasedLocking::rebiased_lock_entry_count_addr())++;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
            } else {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   707
              CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   708
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   709
            success = true;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   710
          } else {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   711
            // Try to bias towards thread in case object is anonymously biased.
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   712
            markOop header = (markOop) ((uintptr_t) mark &
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   713
                                        ((uintptr_t)markOopDesc::biased_lock_mask_in_place |
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   714
                                         (uintptr_t)markOopDesc::age_mask_in_place | epoch_mask_in_place));
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   715
            if (hash != markOopDesc::no_hash) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   716
              header = header->copy_set_hash(hash);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   717
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   718
            markOop new_header = (markOop) ((uintptr_t) header | thread_ident);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   719
            // Debugging hint.
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   720
            DEBUG_ONLY(mon->lock()->set_displaced_header((markOop) (uintptr_t) 0xdeaddead);)
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
   721
            if (rcvr->cas_set_mark(new_header, header) == header) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   722
              if (PrintBiasedLockingStatistics) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   723
                (* BiasedLocking::anonymously_biased_lock_entry_count_addr())++;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   724
              }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   725
            } else {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   726
              CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   727
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   728
            success = true;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   729
          }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   730
        }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   731
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   732
        // Traditional lightweight locking.
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   733
        if (!success) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   734
          markOop displaced = rcvr->mark()->set_unlocked();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   735
          mon->lock()->set_displaced_header(displaced);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   736
          bool call_vm = UseHeavyMonitors;
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
   737
          if (call_vm || rcvr->cas_set_mark((markOop)mon, displaced) != displaced) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   738
            // Is it simple recursive case?
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   739
            if (!call_vm && THREAD->is_lock_owned((address) displaced->clear_lock_bits())) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   740
              mon->lock()->set_displaced_header(NULL);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   741
            } else {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   742
              CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
          }
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   745
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
      THREAD->clr_do_not_unlock();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
      // Notify jvmti
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
#ifdef VM_JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
      if (_jvmti_interp_events) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
        // Whenever JVMTI puts a thread in interp_only_mode, method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
        // entry/exit events are sent for that thread to track stack depth.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
        if (THREAD->is_interp_only_mode()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
          CALL_VM(InterpreterRuntime::post_method_entry(THREAD),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
                  handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
#endif /* VM_JVMTI */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
      goto run;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
    case popping_frame: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
      // returned from a java call to pop the frame, restart the call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
      // clear the message so we don't confuse ourselves later
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
      assert(THREAD->pop_frame_in_process(), "wrong frame pop state");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
      istate->set_msg(no_request);
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   769
      if (_compiling) {
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   770
        // Set MDX back to the ProfileData of the invoke bytecode that will be
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   771
        // restarted.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   772
        SET_MDX(NULL);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   773
        BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   774
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
      THREAD->clr_pop_frame_in_process();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
      goto run;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
    case method_resume: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
      if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
        // resume
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
        os::breakpoint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
      // returned from a java call, continue executing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
      if (THREAD->pop_frame_pending() && !THREAD->pop_frame_in_process()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
        goto handle_Pop_Frame;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
      }
22816
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   788
      if (THREAD->jvmti_thread_state() &&
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   789
          THREAD->jvmti_thread_state()->is_earlyret_pending()) {
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   790
        goto handle_Early_Return;
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
   791
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
      if (THREAD->has_pending_exception()) goto handle_exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
      // Update the pc by the saved amount of the invoke bytecode size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
      UPDATE_PC(istate->bcp_advance());
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   796
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   797
      if (_compiling) {
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   798
        // Get or create profile data. Check for pending (async) exceptions.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   799
        BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   800
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
      goto run;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
    case deopt_resume2: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
      // Returned from an opcode that will reexecute. Deopt was
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
      // a result of a PopFrame request.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
      //
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   808
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   809
      if (_compiling) {
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   810
        // Get or create profile data. Check for pending (async) exceptions.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   811
        BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   812
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
      goto run;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
    case deopt_resume: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
      // Returned from an opcode that has completed. The stack has
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
      // the result all we need to do is skip across the bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
      // and continue (assuming there is no exception pending)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
      //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
      // compute continuation length
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
      //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
      // Note: it is possible to deopt at a return_register_finalizer opcode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
      // because this requires entering the vm to do the registering. While the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
      // opcode is complete we can't advance because there are no more opcodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
      // much like trying to deopt at a poll return. In that has we simply
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
      // get out of here
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
      //
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7407
diff changeset
   829
      if ( Bytecodes::code_at(METHOD, pc) == Bytecodes::_return_register_finalizer) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
        // this will do the right thing even if an exception is pending.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
        goto handle_return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
      }
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7407
diff changeset
   833
      UPDATE_PC(Bytecodes::length_at(METHOD, pc));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
      if (THREAD->has_pending_exception()) goto handle_exception;
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   835
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   836
      if (_compiling) {
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   837
        // Get or create profile data. Check for pending (async) exceptions.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   838
        BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
   839
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
      goto run;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
    case got_monitors: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
      // continue locking now that we have a monitor to use
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
      // we expect to find newly allocated monitor at the "top" of the monitor stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
      oop lockee = STACK_OBJECT(-1);
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   846
      VERIFY_OOP(lockee);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
      // derefing's lockee ought to provoke implicit null check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
      // find a free monitor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
      BasicObjectLock* entry = (BasicObjectLock*) istate->stack_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
      assert(entry->obj() == NULL, "Frame manager didn't allocate the monitor");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
      entry->set_obj(lockee);
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   852
      bool success = false;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   853
      uintptr_t epoch_mask_in_place = (uintptr_t)markOopDesc::epoch_mask_in_place;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   854
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   855
      markOop mark = lockee->mark();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   856
      intptr_t hash = (intptr_t) markOopDesc::no_hash;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   857
      // implies UseBiasedLocking
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   858
      if (mark->has_bias_pattern()) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   859
        uintptr_t thread_ident;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   860
        uintptr_t anticipated_bias_locking_value;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   861
        thread_ident = (uintptr_t)istate->thread();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   862
        anticipated_bias_locking_value =
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   863
          (((uintptr_t)lockee->klass()->prototype_header() | thread_ident) ^ (uintptr_t)mark) &
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   864
          ~((uintptr_t) markOopDesc::age_mask_in_place);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   865
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   866
        if  (anticipated_bias_locking_value == 0) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   867
          // already biased towards this thread, nothing to do
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   868
          if (PrintBiasedLockingStatistics) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   869
            (* BiasedLocking::biased_lock_entry_count_addr())++;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   870
          }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   871
          success = true;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   872
        } else if ((anticipated_bias_locking_value & markOopDesc::biased_lock_mask_in_place) != 0) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   873
          // try revoke bias
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   874
          markOop header = lockee->klass()->prototype_header();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   875
          if (hash != markOopDesc::no_hash) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   876
            header = header->copy_set_hash(hash);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   877
          }
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
   878
          if (lockee->cas_set_mark(header, mark) == mark) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   879
            if (PrintBiasedLockingStatistics) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   880
              (*BiasedLocking::revoked_lock_entry_count_addr())++;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   881
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   882
          }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   883
        } else if ((anticipated_bias_locking_value & epoch_mask_in_place) !=0) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   884
          // try rebias
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   885
          markOop new_header = (markOop) ( (intptr_t) lockee->klass()->prototype_header() | thread_ident);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   886
          if (hash != markOopDesc::no_hash) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   887
                new_header = new_header->copy_set_hash(hash);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   888
          }
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
   889
          if (lockee->cas_set_mark(new_header, mark) == mark) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   890
            if (PrintBiasedLockingStatistics) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   891
              (* BiasedLocking::rebiased_lock_entry_count_addr())++;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   892
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   893
          } else {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   894
            CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   895
          }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   896
          success = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
        } else {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   898
          // try to bias towards thread in case object is anonymously biased
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   899
          markOop header = (markOop) ((uintptr_t) mark & ((uintptr_t)markOopDesc::biased_lock_mask_in_place |
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   900
                                                          (uintptr_t)markOopDesc::age_mask_in_place | epoch_mask_in_place));
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   901
          if (hash != markOopDesc::no_hash) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   902
            header = header->copy_set_hash(hash);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   903
          }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   904
          markOop new_header = (markOop) ((uintptr_t) header | thread_ident);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   905
          // debugging hint
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   906
          DEBUG_ONLY(entry->lock()->set_displaced_header((markOop) (uintptr_t) 0xdeaddead);)
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
   907
          if (lockee->cas_set_mark(new_header, header) == header) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   908
            if (PrintBiasedLockingStatistics) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   909
              (* BiasedLocking::anonymously_biased_lock_entry_count_addr())++;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   910
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   911
          } else {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   912
            CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   913
          }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   914
          success = true;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   915
        }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   916
      }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   917
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   918
      // traditional lightweight locking
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   919
      if (!success) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   920
        markOop displaced = lockee->mark()->set_unlocked();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   921
        entry->lock()->set_displaced_header(displaced);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   922
        bool call_vm = UseHeavyMonitors;
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
   923
        if (call_vm || lockee->cas_set_mark((markOop)entry, displaced) != displaced) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   924
          // Is it simple recursive case?
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   925
          if (!call_vm && THREAD->is_lock_owned((address) displaced->clear_lock_bits())) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   926
            entry->lock()->set_displaced_header(NULL);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   927
          } else {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   928
            CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
   929
          }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
      UPDATE_PC_AND_TOS(1, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
      goto run;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
    default: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
      fatal("Unexpected message from frame manager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
run:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
  DO_UPDATE_INSTRUCTION_COUNT(*pc)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
  DEBUGGER_SINGLE_STEP_NOTIFY();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
#ifdef PREFETCH_OPCCODE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
  opcode = *pc;  /* prefetch first opcode */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
#ifndef USELABELS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
  while (1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
#ifndef PREFETCH_OPCCODE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
      opcode = *pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
      // Seems like this happens twice per opcode. At worst this is only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
      // need at entry to the loop.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
      // DEBUGGER_SINGLE_STEP_NOTIFY();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
      /* Using this labels avoids double breakpoints when quickening and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
       * when returing from transition frames.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
       */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
  opcode_switch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
      assert(istate == orig, "Corrupted istate");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
      /* QQQ Hmm this has knowledge of direction, ought to be a stack method */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
      assert(topOfStack >= istate->stack_limit(), "Stack overrun");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
      assert(topOfStack < istate->stack_base(), "Stack underrun");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
#ifdef USELABELS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
      DISPATCH(opcode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
      switch (opcode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
      CASE(_nop):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
          UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
          /* Push miscellaneous constants onto the stack. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
      CASE(_aconst_null):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
          SET_STACK_OBJECT(NULL, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
#undef  OPC_CONST_n
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
#define OPC_CONST_n(opcode, const_type, value)                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
      CASE(opcode):                                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
          SET_STACK_ ## const_type(value, 0);                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
          OPC_CONST_n(_iconst_m1,   INT,       -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
          OPC_CONST_n(_iconst_0,    INT,        0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
          OPC_CONST_n(_iconst_1,    INT,        1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
          OPC_CONST_n(_iconst_2,    INT,        2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
          OPC_CONST_n(_iconst_3,    INT,        3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
          OPC_CONST_n(_iconst_4,    INT,        4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
          OPC_CONST_n(_iconst_5,    INT,        5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
          OPC_CONST_n(_fconst_0,    FLOAT,      0.0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
          OPC_CONST_n(_fconst_1,    FLOAT,      1.0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
          OPC_CONST_n(_fconst_2,    FLOAT,      2.0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
#undef  OPC_CONST2_n
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
#define OPC_CONST2_n(opcname, value, key, kind)                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
      CASE(_##opcname):                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
      {                                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
          SET_STACK_ ## kind(VM##key##Const##value(), 1);               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
         OPC_CONST2_n(dconst_0, Zero, double, DOUBLE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
         OPC_CONST2_n(dconst_1, One,  double, DOUBLE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
         OPC_CONST2_n(lconst_0, Zero, long, LONG);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
         OPC_CONST2_n(lconst_1, One,  long, LONG);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
         /* Load constant from constant pool: */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
          /* Push a 1-byte signed integer value onto the stack. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
      CASE(_bipush):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
          SET_STACK_INT((jbyte)(pc[1]), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
          UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
          /* Push a 2-byte signed integer constant onto the stack. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
      CASE(_sipush):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
          SET_STACK_INT((int16_t)Bytes::get_Java_u2(pc + 1), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
          UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
          /* load from local variable */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
      CASE(_aload):
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  1026
          VERIFY_OOP(LOCALS_OBJECT(pc[1]));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
          SET_STACK_OBJECT(LOCALS_OBJECT(pc[1]), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
          UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
      CASE(_iload):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
      CASE(_fload):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
          SET_STACK_SLOT(LOCALS_SLOT(pc[1]), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
          UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
      CASE(_lload):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
          SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(pc[1]), 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
          UPDATE_PC_AND_TOS_AND_CONTINUE(2, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
      CASE(_dload):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
          SET_STACK_DOUBLE_FROM_ADDR(LOCALS_DOUBLE_AT(pc[1]), 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
          UPDATE_PC_AND_TOS_AND_CONTINUE(2, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
#undef  OPC_LOAD_n
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
#define OPC_LOAD_n(num)                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
      CASE(_aload_##num):                                               \
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  1046
          VERIFY_OOP(LOCALS_OBJECT(num));                               \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
          SET_STACK_OBJECT(LOCALS_OBJECT(num), 0);                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
                                                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
      CASE(_iload_##num):                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
      CASE(_fload_##num):                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
          SET_STACK_SLOT(LOCALS_SLOT(num), 0);                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
                                                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
      CASE(_lload_##num):                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
          SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(num), 1);             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
      CASE(_dload_##num):                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
          SET_STACK_DOUBLE_FROM_ADDR(LOCALS_DOUBLE_AT(num), 1);         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
          OPC_LOAD_n(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
          OPC_LOAD_n(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
          OPC_LOAD_n(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
          OPC_LOAD_n(3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
          /* store to a local variable */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
      CASE(_astore):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
          astore(topOfStack, -1, locals, pc[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
          UPDATE_PC_AND_TOS_AND_CONTINUE(2, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
      CASE(_istore):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
      CASE(_fstore):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
          SET_LOCALS_SLOT(STACK_SLOT(-1), pc[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
          UPDATE_PC_AND_TOS_AND_CONTINUE(2, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
      CASE(_lstore):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
          SET_LOCALS_LONG(STACK_LONG(-1), pc[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
          UPDATE_PC_AND_TOS_AND_CONTINUE(2, -2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
      CASE(_dstore):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
          SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), pc[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
          UPDATE_PC_AND_TOS_AND_CONTINUE(2, -2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
      CASE(_wide): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
          uint16_t reg = Bytes::get_Java_u2(pc + 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
          opcode = pc[1];
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1090
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1091
          // Wide and it's sub-bytecode are counted as separate instructions. If we
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1092
          // don't account for this here, the bytecode trace skips the next bytecode.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1093
          DO_UPDATE_INSTRUCTION_COUNT(opcode);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1094
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
          switch(opcode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
              case Bytecodes::_aload:
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  1097
                  VERIFY_OOP(LOCALS_OBJECT(reg));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
                  SET_STACK_OBJECT(LOCALS_OBJECT(reg), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
              case Bytecodes::_iload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
              case Bytecodes::_fload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
                  SET_STACK_SLOT(LOCALS_SLOT(reg), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
              case Bytecodes::_lload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
                  SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(reg), 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
              case Bytecodes::_dload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
                  SET_STACK_DOUBLE_FROM_ADDR(LOCALS_LONG_AT(reg), 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
              case Bytecodes::_astore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
                  astore(topOfStack, -1, locals, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
              case Bytecodes::_istore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
              case Bytecodes::_fstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
                  SET_LOCALS_SLOT(STACK_SLOT(-1), reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
              case Bytecodes::_lstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
                  SET_LOCALS_LONG(STACK_LONG(-1), reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, -2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
              case Bytecodes::_dstore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
                  SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, -2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
              case Bytecodes::_iinc: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
                  int16_t offset = (int16_t)Bytes::get_Java_u2(pc+4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
                  // Be nice to see what this generates.... QQQ
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
                  SET_LOCALS_INT(LOCALS_INT(reg) + offset, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
                  UPDATE_PC_AND_CONTINUE(6);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
              case Bytecodes::_ret:
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1138
                  // Profile ret.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1139
                  BI_PROFILE_UPDATE_RET(/*bci=*/((int)(intptr_t)(LOCALS_ADDR(reg))));
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1140
                  // Now, update the pc.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
                  pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(reg));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
                  UPDATE_PC_AND_CONTINUE(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
              default:
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1144
                  VM_JAVA_ERROR(vmSymbols::java_lang_InternalError(), "undefined opcode", note_no_trap);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
#undef  OPC_STORE_n
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
#define OPC_STORE_n(num)                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
      CASE(_astore_##num):                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
          astore(topOfStack, -1, locals, num);                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
      CASE(_istore_##num):                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
      CASE(_fstore_##num):                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
          SET_LOCALS_SLOT(STACK_SLOT(-1), num);                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
          OPC_STORE_n(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
          OPC_STORE_n(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
          OPC_STORE_n(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
          OPC_STORE_n(3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
#undef  OPC_DSTORE_n
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
#define OPC_DSTORE_n(num)                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
      CASE(_dstore_##num):                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
          SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), num);                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
      CASE(_lstore_##num):                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
          SET_LOCALS_LONG(STACK_LONG(-1), num);                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
          OPC_DSTORE_n(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
          OPC_DSTORE_n(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
          OPC_DSTORE_n(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
          OPC_DSTORE_n(3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
          /* stack pop, dup, and insert opcodes */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
      CASE(_pop):                /* Discard the top item on the stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
      CASE(_pop2):               /* Discard the top 2 items on the stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
      CASE(_dup):               /* Duplicate the top item on the stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
          dup(topOfStack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
      CASE(_dup2):              /* Duplicate the top 2 items on the stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
          dup2(topOfStack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
      CASE(_dup_x1):    /* insert top word two down */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
          dup_x1(topOfStack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
      CASE(_dup_x2):    /* insert top word three down  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
          dup_x2(topOfStack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
      CASE(_dup2_x1):   /* insert top 2 slots three down */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
          dup2_x1(topOfStack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
      CASE(_dup2_x2):   /* insert top 2 slots four down */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
          dup2_x2(topOfStack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
      CASE(_swap): {        /* swap top two elements on the stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
          swap(topOfStack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
          UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
          /* Perform various binary integer operations */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
#undef  OPC_INT_BINARY
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
#define OPC_INT_BINARY(opcname, opname, test)                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
      CASE(_i##opcname):                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
          if (test && (STACK_INT(-1) == 0)) {                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
              VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1225
                            "/ by zero", note_div0Check_trap);          \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
          }                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
          SET_STACK_INT(VMint##opname(STACK_INT(-2),                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
                                      STACK_INT(-1)),                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
                                      -2);                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
      CASE(_l##opcname):                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
      {                                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
          if (test) {                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
            jlong l1 = STACK_LONG(-1);                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
            if (VMlongEqz(l1)) {                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
              VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1237
                            "/ by long zero", note_div0Check_trap);     \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
            }                                                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
          }                                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
          /* First long at (-1,-2) next long at (-3,-4) */              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
          SET_STACK_LONG(VMlong##opname(STACK_LONG(-3),                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
                                        STACK_LONG(-1)),                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
                                        -3);                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
      OPC_INT_BINARY(add, Add, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
      OPC_INT_BINARY(sub, Sub, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
      OPC_INT_BINARY(mul, Mul, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
      OPC_INT_BINARY(and, And, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
      OPC_INT_BINARY(or,  Or,  0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
      OPC_INT_BINARY(xor, Xor, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
      OPC_INT_BINARY(div, Div, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
      OPC_INT_BINARY(rem, Rem, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
      /* Perform various binary floating number operations */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
      /* On some machine/platforms/compilers div zero check can be implicit */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
#undef  OPC_FLOAT_BINARY
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
#define OPC_FLOAT_BINARY(opcname, opname)                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
      CASE(_d##opcname): {                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
          SET_STACK_DOUBLE(VMdouble##opname(STACK_DOUBLE(-3),              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
                                            STACK_DOUBLE(-1)),             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
                                            -3);                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);                           \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
      }                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
      CASE(_f##opcname):                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
          SET_STACK_FLOAT(VMfloat##opname(STACK_FLOAT(-2),                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
                                          STACK_FLOAT(-1)),                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
                                          -2);                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
     OPC_FLOAT_BINARY(add, Add);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
     OPC_FLOAT_BINARY(sub, Sub);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
     OPC_FLOAT_BINARY(mul, Mul);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
     OPC_FLOAT_BINARY(div, Div);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
     OPC_FLOAT_BINARY(rem, Rem);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
      /* Shift operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
       * Shift left int and long: ishl, lshl
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
       * Logical shift right int and long w/zero extension: iushr, lushr
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
       * Arithmetic shift right int and long w/sign extension: ishr, lshr
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
       */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
#undef  OPC_SHIFT_BINARY
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
#define OPC_SHIFT_BINARY(opcname, opname)                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
      CASE(_i##opcname):                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
         SET_STACK_INT(VMint##opname(STACK_INT(-2),                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
                                     STACK_INT(-1)),                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
                                     -2);                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
         UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
      CASE(_l##opcname):                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
      {                                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
         SET_STACK_LONG(VMlong##opname(STACK_LONG(-2),                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
                                       STACK_INT(-1)),                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
                                       -2);                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
         UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1300
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
      OPC_SHIFT_BINARY(shl, Shl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
      OPC_SHIFT_BINARY(shr, Shr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
      OPC_SHIFT_BINARY(ushr, Ushr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
     /* Increment local variable by constant */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
      CASE(_iinc):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
          // locals[pc[1]].j.i += (jbyte)(pc[2]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
          SET_LOCALS_INT(LOCALS_INT(pc[1]) + (jbyte)(pc[2]), pc[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
          UPDATE_PC_AND_CONTINUE(3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
     /* negate the value on the top of the stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
      CASE(_ineg):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
         SET_STACK_INT(VMintNeg(STACK_INT(-1)), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
         UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
      CASE(_fneg):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
         SET_STACK_FLOAT(VMfloatNeg(STACK_FLOAT(-1)), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
         UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
      CASE(_lneg):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
         SET_STACK_LONG(VMlongNeg(STACK_LONG(-1)), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
         UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
      CASE(_dneg):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
         SET_STACK_DOUBLE(VMdoubleNeg(STACK_DOUBLE(-1)), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
         UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
      /* Conversion operations */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
      CASE(_i2f):       /* convert top of stack int to float */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
         SET_STACK_FLOAT(VMint2Float(STACK_INT(-1)), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
         UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
      CASE(_i2l):       /* convert top of stack int to long */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
          // this is ugly QQQ
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
          jlong r = VMint2Long(STACK_INT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
          MORE_STACK(-1); // Pop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
          SET_STACK_LONG(r, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
      CASE(_i2d):       /* convert top of stack int to double */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
          // this is ugly QQQ (why cast to jlong?? )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
          jdouble r = (jlong)STACK_INT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
          MORE_STACK(-1); // Pop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
          SET_STACK_DOUBLE(r, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
      CASE(_l2i):       /* convert top of stack long to int */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
          jint r = VMlong2Int(STACK_LONG(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
          MORE_STACK(-2); // Pop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
          SET_STACK_INT(r, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
      CASE(_l2f):   /* convert top of stack long to float */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
          jlong r = STACK_LONG(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
          MORE_STACK(-2); // Pop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
          SET_STACK_FLOAT(VMlong2Float(r), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
      CASE(_l2d):       /* convert top of stack long to double */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
          jlong r = STACK_LONG(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
          MORE_STACK(-2); // Pop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
          SET_STACK_DOUBLE(VMlong2Double(r), 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
      CASE(_f2i):  /* Convert top of stack float to int */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
          SET_STACK_INT(SharedRuntime::f2i(STACK_FLOAT(-1)), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
          UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
      CASE(_f2l):  /* convert top of stack float to long */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
          jlong r = SharedRuntime::f2l(STACK_FLOAT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
          MORE_STACK(-1); // POP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
          SET_STACK_LONG(r, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
      CASE(_f2d):  /* convert top of stack float to double */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
          jfloat f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
          jdouble r;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
          f = STACK_FLOAT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
          r = (jdouble) f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
          MORE_STACK(-1); // POP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
          SET_STACK_DOUBLE(r, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
      CASE(_d2i): /* convert top of stack double to int */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
          jint r1 = SharedRuntime::d2i(STACK_DOUBLE(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
          MORE_STACK(-2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
          SET_STACK_INT(r1, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
      CASE(_d2f): /* convert top of stack double to float */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
          jfloat r1 = VMdouble2Float(STACK_DOUBLE(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
          MORE_STACK(-2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
          SET_STACK_FLOAT(r1, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
      CASE(_d2l): /* convert top of stack double to long */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
          jlong r1 = SharedRuntime::d2l(STACK_DOUBLE(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
          MORE_STACK(-2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
          SET_STACK_LONG(r1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
      CASE(_i2b):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1434
          SET_STACK_INT(VMint2Byte(STACK_INT(-1)), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
          UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
      CASE(_i2c):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
          SET_STACK_INT(VMint2Char(STACK_INT(-1)), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
          UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
      CASE(_i2s):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
          SET_STACK_INT(VMint2Short(STACK_INT(-1)), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
          UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
      /* comparison operators */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
#define COMPARISON_OP(name, comparison)                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1449
      CASE(_if_icmp##name): {                                                \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1450
          const bool cmp = (STACK_INT(-2) comparison STACK_INT(-1));         \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1451
          int skip = cmp                                                     \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
                      ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3;             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
          address branch_pc = pc;                                            \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1454
          /* Profile branch. */                                              \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1455
          BI_PROFILE_UPDATE_BRANCH(/*is_taken=*/cmp);                        \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
          UPDATE_PC_AND_TOS(skip, -2);                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
          DO_BACKEDGE_CHECKS(skip, branch_pc);                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
          CONTINUE;                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
      }                                                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
      CASE(_if##name): {                                                     \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1461
          const bool cmp = (STACK_INT(-1) comparison 0);                     \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1462
          int skip = cmp                                                     \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
                      ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3;             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
          address branch_pc = pc;                                            \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1465
          /* Profile branch. */                                              \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1466
          BI_PROFILE_UPDATE_BRANCH(/*is_taken=*/cmp);                        \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
          UPDATE_PC_AND_TOS(skip, -1);                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
          DO_BACKEDGE_CHECKS(skip, branch_pc);                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
          CONTINUE;                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
#define COMPARISON_OP2(name, comparison)                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
      COMPARISON_OP(name, comparison)                                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
      CASE(_if_acmp##name): {                                                \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1475
          const bool cmp = (STACK_OBJECT(-2) comparison STACK_OBJECT(-1));   \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1476
          int skip = cmp                                                     \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
                       ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3;            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
          address branch_pc = pc;                                            \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1479
          /* Profile branch. */                                              \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1480
          BI_PROFILE_UPDATE_BRANCH(/*is_taken=*/cmp);                        \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
          UPDATE_PC_AND_TOS(skip, -2);                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
          DO_BACKEDGE_CHECKS(skip, branch_pc);                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
          CONTINUE;                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
#define NULL_COMPARISON_NOT_OP(name)                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
      CASE(_if##name): {                                                     \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1488
          const bool cmp = (!(STACK_OBJECT(-1) == NULL));                    \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1489
          int skip = cmp                                                     \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
                      ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3;             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
          address branch_pc = pc;                                            \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1492
          /* Profile branch. */                                              \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1493
          BI_PROFILE_UPDATE_BRANCH(/*is_taken=*/cmp);                        \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
          UPDATE_PC_AND_TOS(skip, -1);                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
          DO_BACKEDGE_CHECKS(skip, branch_pc);                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
          CONTINUE;                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
#define NULL_COMPARISON_OP(name)                                             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
      CASE(_if##name): {                                                     \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1501
          const bool cmp = ((STACK_OBJECT(-1) == NULL));                     \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1502
          int skip = cmp                                                     \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
                      ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3;             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
          address branch_pc = pc;                                            \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1505
          /* Profile branch. */                                              \
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1506
          BI_PROFILE_UPDATE_BRANCH(/*is_taken=*/cmp);                        \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
          UPDATE_PC_AND_TOS(skip, -1);                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
          DO_BACKEDGE_CHECKS(skip, branch_pc);                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
          CONTINUE;                                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
      COMPARISON_OP(lt, <);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
      COMPARISON_OP(gt, >);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
      COMPARISON_OP(le, <=);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
      COMPARISON_OP(ge, >=);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
      COMPARISON_OP2(eq, ==);  /* include ref comparison */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
      COMPARISON_OP2(ne, !=);  /* include ref comparison */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
      NULL_COMPARISON_OP(null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
      NULL_COMPARISON_NOT_OP(nonnull);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
      /* Goto pc at specified offset in switch table. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
      CASE(_tableswitch): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
          jint* lpc  = (jint*)VMalignWordUp(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
          int32_t  key  = STACK_INT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
          int32_t  low  = Bytes::get_Java_u4((address)&lpc[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
          int32_t  high = Bytes::get_Java_u4((address)&lpc[2]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
          int32_t  skip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
          key -= low;
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1529
          if (((uint32_t) key > (uint32_t)(high - low))) {
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1530
            key = -1;
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1531
            skip = Bytes::get_Java_u4((address)&lpc[0]);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1532
          } else {
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1533
            skip = Bytes::get_Java_u4((address)&lpc[key + 3]);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1534
          }
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1535
          // Profile switch.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1536
          BI_PROFILE_UPDATE_SWITCH(/*switch_index=*/key);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1537
          // Does this really need a full backedge check (osr)?
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
          address branch_pc = pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
          UPDATE_PC_AND_TOS(skip, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1540
          DO_BACKEDGE_CHECKS(skip, branch_pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
          CONTINUE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1543
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1544
      /* Goto pc whose table entry matches specified key. */
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1546
      CASE(_lookupswitch): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
          jint* lpc  = (jint*)VMalignWordUp(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
          int32_t  key  = STACK_INT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1549
          int32_t  skip = Bytes::get_Java_u4((address) lpc); /* default amount */
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1550
          // Remember index.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1551
          int      index = -1;
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1552
          int      newindex = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
          int32_t  npairs = Bytes::get_Java_u4((address) &lpc[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1554
          while (--npairs >= 0) {
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1555
            lpc += 2;
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1556
            if (key == (int32_t)Bytes::get_Java_u4((address)lpc)) {
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1557
              skip = Bytes::get_Java_u4((address)&lpc[1]);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1558
              index = newindex;
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1559
              break;
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1560
            }
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1561
            newindex += 1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1562
          }
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1563
          // Profile switch.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1564
          BI_PROFILE_UPDATE_SWITCH(/*switch_index=*/index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1565
          address branch_pc = pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1566
          UPDATE_PC_AND_TOS(skip, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
          DO_BACKEDGE_CHECKS(skip, branch_pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1568
          CONTINUE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1569
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1570
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1571
      CASE(_fcmpl):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1572
      CASE(_fcmpg):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1573
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1574
          SET_STACK_INT(VMfloatCompare(STACK_FLOAT(-2),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1575
                                        STACK_FLOAT(-1),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1576
                                        (opcode == Bytecodes::_fcmpl ? -1 : 1)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1577
                        -2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1578
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1579
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
      CASE(_dcmpl):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
      CASE(_dcmpg):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
          int r = VMdoubleCompare(STACK_DOUBLE(-3),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
                                  STACK_DOUBLE(-1),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
                                  (opcode == Bytecodes::_dcmpl ? -1 : 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
          MORE_STACK(-4); // Pop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
          SET_STACK_INT(r, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1592
      CASE(_lcmp):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1593
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1594
          int r = VMlongCompare(STACK_LONG(-3), STACK_LONG(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
          MORE_STACK(-4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
          SET_STACK_INT(r, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1597
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1598
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1599
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1600
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
      /* Return from a method */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1603
      CASE(_areturn):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
      CASE(_ireturn):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
      CASE(_freturn):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
          // Allow a safepoint before returning to frame manager.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
          SAFEPOINT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
          goto handle_return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
      CASE(_lreturn):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
      CASE(_dreturn):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
          // Allow a safepoint before returning to frame manager.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
          SAFEPOINT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
          goto handle_return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
      CASE(_return_register_finalizer): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1623
          oop rcvr = LOCALS_OBJECT(0);
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  1624
          VERIFY_OOP(rcvr);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1625
          if (rcvr->klass()->has_finalizer()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
            CALL_VM(InterpreterRuntime::register_finalizer(THREAD, rcvr), handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1627
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1628
          goto handle_return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1629
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
      CASE(_return): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
          // Allow a safepoint before returning to frame manager.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
          SAFEPOINT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1634
          goto handle_return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1636
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1637
      /* Array access byte-codes */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1638
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1639
      /* Every array access byte-code starts out like this */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
//        arrayOopDesc* arrObj = (arrayOopDesc*)STACK_OBJECT(arrayOff);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
#define ARRAY_INTRO(arrayOff)                                                  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
      arrayOop arrObj = (arrayOop)STACK_OBJECT(arrayOff);                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1643
      jint     index  = STACK_INT(arrayOff + 1);                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1644
      char message[jintAsStringSize];                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1645
      CHECK_NULL(arrObj);                                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1646
      if ((uint32_t)index >= (uint32_t)arrObj->length()) {                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1647
          sprintf(message, "%d", index);                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1648
          VM_JAVA_ERROR(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), \
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1649
                        message, note_rangeCheck_trap);                        \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1652
      /* 32-bit loads. These handle conversion from < 32-bit types */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1653
#define ARRAY_LOADTO32(T, T2, format, stackRes, extra)                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
      {                                                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
          ARRAY_INTRO(-2);                                                            \
18504
b116e46230d2 8019382: PPC64: Fix bytecodeInterpreter to compile with '-Wunused-value'
simonis
parents: 18451
diff changeset
  1656
          (void)extra;                                                                \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
          SET_ ## stackRes(*(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)), \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1658
                           -2);                                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1660
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1661
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
      /* 64-bit loads */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1663
#define ARRAY_LOADTO64(T,T2, stackRes, extra)                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
      {                                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1665
          ARRAY_INTRO(-2);                                                                 \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1666
          SET_ ## stackRes(*(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)), -1); \
18504
b116e46230d2 8019382: PPC64: Fix bytecodeInterpreter to compile with '-Wunused-value'
simonis
parents: 18451
diff changeset
  1667
          (void)extra;                                                                     \
b116e46230d2 8019382: PPC64: Fix bytecodeInterpreter to compile with '-Wunused-value'
simonis
parents: 18451
diff changeset
  1668
          UPDATE_PC_AND_CONTINUE(1);                                                       \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1669
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1670
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
      CASE(_iaload):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1672
          ARRAY_LOADTO32(T_INT, jint,   "%d",   STACK_INT, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1673
      CASE(_faload):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1674
          ARRAY_LOADTO32(T_FLOAT, jfloat, "%f",   STACK_FLOAT, 0);
22815
fba9b7111615 8019518: PPC64 (part 103): cppInterpreter: implement support for compressed Oops
goetz
parents: 22814
diff changeset
  1675
      CASE(_aaload): {
fba9b7111615 8019518: PPC64 (part 103): cppInterpreter: implement support for compressed Oops
goetz
parents: 22814
diff changeset
  1676
          ARRAY_INTRO(-2);
fba9b7111615 8019518: PPC64 (part 103): cppInterpreter: implement support for compressed Oops
goetz
parents: 22814
diff changeset
  1677
          SET_STACK_OBJECT(((objArrayOop) arrObj)->obj_at(index), -2);
fba9b7111615 8019518: PPC64 (part 103): cppInterpreter: implement support for compressed Oops
goetz
parents: 22814
diff changeset
  1678
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
fba9b7111615 8019518: PPC64 (part 103): cppInterpreter: implement support for compressed Oops
goetz
parents: 22814
diff changeset
  1679
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1680
      CASE(_baload):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
          ARRAY_LOADTO32(T_BYTE, jbyte,  "%d",   STACK_INT, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1682
      CASE(_caload):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1683
          ARRAY_LOADTO32(T_CHAR,  jchar, "%d",   STACK_INT, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
      CASE(_saload):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
          ARRAY_LOADTO32(T_SHORT, jshort, "%d",   STACK_INT, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
      CASE(_laload):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
          ARRAY_LOADTO64(T_LONG, jlong, STACK_LONG, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1688
      CASE(_daload):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1689
          ARRAY_LOADTO64(T_DOUBLE, jdouble, STACK_DOUBLE, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1690
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1691
      /* 32-bit stores. These handle conversion to < 32-bit types */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
#define ARRAY_STOREFROM32(T, T2, format, stackSrc, extra)                            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1693
      {                                                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
          ARRAY_INTRO(-3);                                                           \
18504
b116e46230d2 8019382: PPC64: Fix bytecodeInterpreter to compile with '-Wunused-value'
simonis
parents: 18451
diff changeset
  1695
          (void)extra;                                                               \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1696
          *(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)) = stackSrc( -1); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1697
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1700
      /* 64-bit stores */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1701
#define ARRAY_STOREFROM64(T, T2, stackSrc, extra)                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1702
      {                                                                              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
          ARRAY_INTRO(-4);                                                           \
18504
b116e46230d2 8019382: PPC64: Fix bytecodeInterpreter to compile with '-Wunused-value'
simonis
parents: 18451
diff changeset
  1704
          (void)extra;                                                               \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
          *(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)) = stackSrc( -1); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -4);                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1709
      CASE(_iastore):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
          ARRAY_STOREFROM32(T_INT, jint,   "%d",   STACK_INT, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
      CASE(_fastore):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
          ARRAY_STOREFROM32(T_FLOAT, jfloat, "%f",   STACK_FLOAT, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
      /*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1714
       * This one looks different because of the assignability check
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
       */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
      CASE(_aastore): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
          oop rhsObject = STACK_OBJECT(-1);
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  1718
          VERIFY_OOP(rhsObject);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1719
          ARRAY_INTRO( -3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
          // arrObj, index are set
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1721
          if (rhsObject != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1722
            /* Check assignability of rhsObject into arrObj */
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1723
            Klass* rhsKlass = rhsObject->klass(); // EBX (subclass)
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1724
            Klass* elemKlass = ObjArrayKlass::cast(arrObj->klass())->element_klass(); // superklass EAX
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
            //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1726
            // Check for compatibilty. This check must not GC!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
            // Seems way more expensive now that we must dispatch
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1728
            //
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1729
            if (rhsKlass != elemKlass && !rhsKlass->is_subtype_of(elemKlass)) { // ebx->is...
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1730
              // Decrement counter if subtype check failed.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1731
              BI_PROFILE_SUBTYPECHECK_FAILED(rhsKlass);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1732
              VM_JAVA_ERROR(vmSymbols::java_lang_ArrayStoreException(), "", note_arrayCheck_trap);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1733
            }
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1734
            // Profile checkcast with null_seen and receiver.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1735
            BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/false, rhsKlass);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1736
          } else {
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1737
            // Profile checkcast with null_seen and receiver.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  1738
            BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/true, NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
          }
22849
b8670e920530 8028514: PPC64: Fix C++ Interpreter after '7195622: CheckUnhandledOops has limited usefulness now'
simonis
parents: 22836
diff changeset
  1740
          ((objArrayOop) arrObj)->obj_at_put(index, rhsObject);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
      }
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1743
      CASE(_bastore): {
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1744
          ARRAY_INTRO(-3);
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1745
          int item = STACK_INT(-1);
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1746
          // if it is a T_BOOLEAN array, mask the stored value to 0/1
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1747
          if (arrObj->klass() == Universe::boolArrayKlassObj()) {
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1748
            item &= 1;
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1749
          } else {
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1750
            assert(arrObj->klass() == Universe::byteArrayKlassObj(),
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1751
                   "should be byte array otherwise");
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1752
          }
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1753
          ((typeArrayOop)arrObj)->byte_at_put(index, item);
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1754
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1755
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
      CASE(_castore):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
          ARRAY_STOREFROM32(T_CHAR, jchar,  "%d",   STACK_INT, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
      CASE(_sastore):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
          ARRAY_STOREFROM32(T_SHORT, jshort, "%d",   STACK_INT, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
      CASE(_lastore):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1761
          ARRAY_STOREFROM64(T_LONG, jlong, STACK_LONG, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
      CASE(_dastore):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
          ARRAY_STOREFROM64(T_DOUBLE, jdouble, STACK_DOUBLE, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
      CASE(_arraylength):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1766
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
          arrayOop ary = (arrayOop) STACK_OBJECT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
          CHECK_NULL(ary);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
          SET_STACK_INT(ary->length(), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
          UPDATE_PC_AND_CONTINUE(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1773
      /* monitorenter and monitorexit for locking/unlocking an object */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1774
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1775
      CASE(_monitorenter): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1776
        oop lockee = STACK_OBJECT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1777
        // derefing's lockee ought to provoke implicit null check
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1778
        CHECK_NULL(lockee);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1779
        // find a free monitor or one already allocated for this object
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1780
        // if we find a matching object then we need a new monitor
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
        // since this is recursive enter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
        BasicObjectLock* limit = istate->monitor_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
        BasicObjectLock* most_recent = (BasicObjectLock*) istate->stack_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
        BasicObjectLock* entry = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
        while (most_recent != limit ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
          if (most_recent->obj() == NULL) entry = most_recent;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
          else if (most_recent->obj() == lockee) break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
          most_recent++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
        if (entry != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
          entry->set_obj(lockee);
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1792
          int success = false;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1793
          uintptr_t epoch_mask_in_place = (uintptr_t)markOopDesc::epoch_mask_in_place;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1794
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1795
          markOop mark = lockee->mark();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1796
          intptr_t hash = (intptr_t) markOopDesc::no_hash;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1797
          // implies UseBiasedLocking
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1798
          if (mark->has_bias_pattern()) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1799
            uintptr_t thread_ident;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1800
            uintptr_t anticipated_bias_locking_value;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1801
            thread_ident = (uintptr_t)istate->thread();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1802
            anticipated_bias_locking_value =
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1803
              (((uintptr_t)lockee->klass()->prototype_header() | thread_ident) ^ (uintptr_t)mark) &
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1804
              ~((uintptr_t) markOopDesc::age_mask_in_place);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1805
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1806
            if  (anticipated_bias_locking_value == 0) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1807
              // already biased towards this thread, nothing to do
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1808
              if (PrintBiasedLockingStatistics) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1809
                (* BiasedLocking::biased_lock_entry_count_addr())++;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1810
              }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1811
              success = true;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1812
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1813
            else if ((anticipated_bias_locking_value & markOopDesc::biased_lock_mask_in_place) != 0) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1814
              // try revoke bias
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1815
              markOop header = lockee->klass()->prototype_header();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1816
              if (hash != markOopDesc::no_hash) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1817
                header = header->copy_set_hash(hash);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1818
              }
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
  1819
              if (lockee->cas_set_mark(header, mark) == mark) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1820
                if (PrintBiasedLockingStatistics)
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1821
                  (*BiasedLocking::revoked_lock_entry_count_addr())++;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1822
              }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1823
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1824
            else if ((anticipated_bias_locking_value & epoch_mask_in_place) !=0) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1825
              // try rebias
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1826
              markOop new_header = (markOop) ( (intptr_t) lockee->klass()->prototype_header() | thread_ident);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1827
              if (hash != markOopDesc::no_hash) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1828
                new_header = new_header->copy_set_hash(hash);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1829
              }
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
  1830
              if (lockee->cas_set_mark(new_header, mark) == mark) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1831
                if (PrintBiasedLockingStatistics)
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1832
                  (* BiasedLocking::rebiased_lock_entry_count_addr())++;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1833
              }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1834
              else {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1835
                CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1836
              }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1837
              success = true;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1838
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1839
            else {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1840
              // try to bias towards thread in case object is anonymously biased
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1841
              markOop header = (markOop) ((uintptr_t) mark & ((uintptr_t)markOopDesc::biased_lock_mask_in_place |
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1842
                                                              (uintptr_t)markOopDesc::age_mask_in_place |
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1843
                                                              epoch_mask_in_place));
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1844
              if (hash != markOopDesc::no_hash) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1845
                header = header->copy_set_hash(hash);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1846
              }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1847
              markOop new_header = (markOop) ((uintptr_t) header | thread_ident);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1848
              // debugging hint
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1849
              DEBUG_ONLY(entry->lock()->set_displaced_header((markOop) (uintptr_t) 0xdeaddead);)
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
  1850
              if (lockee->cas_set_mark(new_header, header) == header) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1851
                if (PrintBiasedLockingStatistics)
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1852
                  (* BiasedLocking::anonymously_biased_lock_entry_count_addr())++;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1853
              }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1854
              else {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1855
                CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1856
              }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1857
              success = true;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1858
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1859
          }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1860
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1861
          // traditional lightweight locking
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1862
          if (!success) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1863
            markOop displaced = lockee->mark()->set_unlocked();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1864
            entry->lock()->set_displaced_header(displaced);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1865
            bool call_vm = UseHeavyMonitors;
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49658
diff changeset
  1866
            if (call_vm || lockee->cas_set_mark((markOop)entry, displaced) != displaced) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1867
              // Is it simple recursive case?
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1868
              if (!call_vm && THREAD->is_lock_owned((address) displaced->clear_lock_bits())) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1869
                entry->lock()->set_displaced_header(NULL);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1870
              } else {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1871
                CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1872
              }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1873
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1874
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1875
          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1877
          istate->set_msg(more_monitors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1878
          UPDATE_PC_AND_RETURN(0); // Re-execute
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1879
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1880
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1881
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1882
      CASE(_monitorexit): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1883
        oop lockee = STACK_OBJECT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1884
        CHECK_NULL(lockee);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1885
        // derefing's lockee ought to provoke implicit null check
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1886
        // find our monitor slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1887
        BasicObjectLock* limit = istate->monitor_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1888
        BasicObjectLock* most_recent = (BasicObjectLock*) istate->stack_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1889
        while (most_recent != limit ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1890
          if ((most_recent)->obj() == lockee) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1891
            BasicLock* lock = most_recent->lock();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1892
            markOop header = lock->displaced_header();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1893
            most_recent->set_obj(NULL);
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1894
            if (!lockee->mark()->has_bias_pattern()) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1895
              bool call_vm = UseHeavyMonitors;
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1896
              // If it isn't recursive we either must swap old header or call the runtime
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1897
              if (header != NULL || call_vm) {
47634
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
  1898
                markOop old_header = markOopDesc::encode(lock);
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
  1899
                if (call_vm || lockee->cas_set_mark(header, old_header) != old_header) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1900
                  // restore object for the slow case
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1901
                  most_recent->set_obj(lockee);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1902
                  CALL_VM(InterpreterRuntime::monitorexit(THREAD, most_recent), handle_exception);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  1903
                }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1904
              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1905
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1906
            UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1907
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1908
          most_recent++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1909
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1910
        // Need to throw illegal monitor state exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1911
        CALL_VM(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD), handle_exception);
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  1912
        ShouldNotReachHere();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1913
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
      /* All of the non-quick opcodes. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
      /* -Set clobbersCpIndex true if the quickened opcode clobbers the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1918
       *  constant pool index in the instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
       */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
      CASE(_getfield):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
      CASE(_getstatic):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1922
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1923
          u2 index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1924
          ConstantPoolCacheEntry* cache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1925
          index = Bytes::get_native_u2(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1926
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1927
          // QQQ Need to make this as inlined as possible. Probably need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1928
          // split all the bytecode cases out so c++ compiler has a chance
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1929
          // for constant prop to fold everything possible away.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1930
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1931
          cache = cp->entry_at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1932
          if (!cache->is_resolved((Bytecodes::Code)opcode)) {
30132
1f788eb36811 8076492: Make common code from template interpreter code
coleenp
parents: 30126
diff changeset
  1933
            CALL_VM(InterpreterRuntime::resolve_from_cache(THREAD, (Bytecodes::Code)opcode),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
                    handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
            cache = cp->entry_at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1936
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1938
#ifdef VM_JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1939
          if (_jvmti_interp_events) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1940
            int *count_addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1941
            oop obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1942
            // Check to see if a field modification watch has been set
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
            // before we take the time to call into the VM.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1944
            count_addr = (int *)JvmtiExport::get_field_access_count_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1945
            if ( *count_addr > 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1946
              if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1947
                obj = (oop)NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1948
              } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1949
                obj = (oop) STACK_OBJECT(-1);
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  1950
                VERIFY_OOP(obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1951
              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
              CALL_VM(InterpreterRuntime::post_field_access(THREAD,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
                                          obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1954
                                          cache),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1955
                                          handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1956
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1957
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1958
#endif /* VM_JVMTI */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1959
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
          oop obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
          if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) {
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  1962
            Klass* k = cache->f1_as_klass();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1963
            obj = k->java_mirror();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1964
            MORE_STACK(1);  // Assume single slot push
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1965
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1966
            obj = (oop) STACK_OBJECT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1967
            CHECK_NULL(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1968
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1969
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1970
          //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1971
          // Now store the result on the stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
          //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1973
          TosState tos_type = cache->flag_state();
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10565
diff changeset
  1974
          int field_offset = cache->f2_as_index();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1975
          if (cache->is_volatile()) {
22868
7f6eb436873b 8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents: 22862
diff changeset
  1976
            if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
7f6eb436873b 8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents: 22862
diff changeset
  1977
              OrderAccess::fence();
7f6eb436873b 8029101: PPC64 (part 211): ordering of Independent Reads of Independent Writes
goetz
parents: 22862
diff changeset
  1978
            }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
            if (tos_type == atos) {
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  1980
              VERIFY_OOP(obj->obj_field_acquire(field_offset));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1981
              SET_STACK_OBJECT(obj->obj_field_acquire(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1982
            } else if (tos_type == itos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1983
              SET_STACK_INT(obj->int_field_acquire(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
            } else if (tos_type == ltos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1985
              SET_STACK_LONG(obj->long_field_acquire(field_offset), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1986
              MORE_STACK(1);
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  1987
            } else if (tos_type == btos || tos_type == ztos) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1988
              SET_STACK_INT(obj->byte_field_acquire(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1989
            } else if (tos_type == ctos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
              SET_STACK_INT(obj->char_field_acquire(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1991
            } else if (tos_type == stos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1992
              SET_STACK_INT(obj->short_field_acquire(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1993
            } else if (tos_type == ftos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1994
              SET_STACK_FLOAT(obj->float_field_acquire(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1995
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1996
              SET_STACK_DOUBLE(obj->double_field_acquire(field_offset), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1997
              MORE_STACK(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1998
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1999
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2000
            if (tos_type == atos) {
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  2001
              VERIFY_OOP(obj->obj_field(field_offset));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2002
              SET_STACK_OBJECT(obj->obj_field(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2003
            } else if (tos_type == itos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2004
              SET_STACK_INT(obj->int_field(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2005
            } else if (tos_type == ltos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2006
              SET_STACK_LONG(obj->long_field(field_offset), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2007
              MORE_STACK(1);
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  2008
            } else if (tos_type == btos || tos_type == ztos) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
              SET_STACK_INT(obj->byte_field(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2010
            } else if (tos_type == ctos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2011
              SET_STACK_INT(obj->char_field(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
            } else if (tos_type == stos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2013
              SET_STACK_INT(obj->short_field(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2014
            } else if (tos_type == ftos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2015
              SET_STACK_FLOAT(obj->float_field(field_offset), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2016
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2017
              SET_STACK_DOUBLE(obj->double_field(field_offset), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2018
              MORE_STACK(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2019
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2022
          UPDATE_PC_AND_CONTINUE(3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2023
         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2024
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2025
      CASE(_putfield):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2026
      CASE(_putstatic):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2027
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
          u2 index = Bytes::get_native_u2(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2029
          ConstantPoolCacheEntry* cache = cp->entry_at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2030
          if (!cache->is_resolved((Bytecodes::Code)opcode)) {
30132
1f788eb36811 8076492: Make common code from template interpreter code
coleenp
parents: 30126
diff changeset
  2031
            CALL_VM(InterpreterRuntime::resolve_from_cache(THREAD, (Bytecodes::Code)opcode),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2032
                    handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2033
            cache = cp->entry_at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2034
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2035
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
#ifdef VM_JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
          if (_jvmti_interp_events) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
            int *count_addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2039
            oop obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
            // Check to see if a field modification watch has been set
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2041
            // before we take the time to call into the VM.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
            count_addr = (int *)JvmtiExport::get_field_modification_count_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
            if ( *count_addr > 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
              if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
                obj = (oop)NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2046
              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
              else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2048
                if (cache->is_long() || cache->is_double()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2049
                  obj = (oop) STACK_OBJECT(-3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
                } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
                  obj = (oop) STACK_OBJECT(-2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
                }
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  2053
                VERIFY_OOP(obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2054
              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
              CALL_VM(InterpreterRuntime::post_field_modification(THREAD,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
                                          obj,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
                                          cache,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
                                          (jvalue *)STACK_SLOT(-1)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
                                          handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
#endif /* VM_JVMTI */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2064
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2065
          // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2066
          // out so c++ compiler has a chance for constant prop to fold everything possible away.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2067
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2068
          oop obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2069
          int count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2070
          TosState tos_type = cache->flag_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2071
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2072
          count = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2073
          if (tos_type == ltos || tos_type == dtos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2074
            --count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2075
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
          if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) {
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2077
            Klass* k = cache->f1_as_klass();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2078
            obj = k->java_mirror();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2079
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2080
            --count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2081
            obj = (oop) STACK_OBJECT(count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2082
            CHECK_NULL(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2083
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2084
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2085
          //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2086
          // Now store the result
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2087
          //
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10565
diff changeset
  2088
          int field_offset = cache->f2_as_index();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
          if (cache->is_volatile()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
            if (tos_type == itos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
              obj->release_int_field_put(field_offset, STACK_INT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2092
            } else if (tos_type == atos) {
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  2093
              VERIFY_OOP(STACK_OBJECT(-1));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
              obj->release_obj_field_put(field_offset, STACK_OBJECT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
            } else if (tos_type == btos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2096
              obj->release_byte_field_put(field_offset, STACK_INT(-1));
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  2097
            } else if (tos_type == ztos) {
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  2098
              int bool_field = STACK_INT(-1);  // only store LSB
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  2099
              obj->release_byte_field_put(field_offset, (bool_field & 1));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2100
            } else if (tos_type == ltos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2101
              obj->release_long_field_put(field_offset, STACK_LONG(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2102
            } else if (tos_type == ctos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2103
              obj->release_char_field_put(field_offset, STACK_INT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2104
            } else if (tos_type == stos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2105
              obj->release_short_field_put(field_offset, STACK_INT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2106
            } else if (tos_type == ftos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
              obj->release_float_field_put(field_offset, STACK_FLOAT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2108
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2109
              obj->release_double_field_put(field_offset, STACK_DOUBLE(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2110
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2111
            OrderAccess::storeload();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2112
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2113
            if (tos_type == itos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2114
              obj->int_field_put(field_offset, STACK_INT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
            } else if (tos_type == atos) {
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  2116
              VERIFY_OOP(STACK_OBJECT(-1));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2117
              obj->obj_field_put(field_offset, STACK_OBJECT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2118
            } else if (tos_type == btos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2119
              obj->byte_field_put(field_offset, STACK_INT(-1));
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  2120
            } else if (tos_type == ztos) {
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  2121
              int bool_field = STACK_INT(-1);  // only store LSB
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37296
diff changeset
  2122
              obj->byte_field_put(field_offset, (bool_field & 1));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2123
            } else if (tos_type == ltos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2124
              obj->long_field_put(field_offset, STACK_LONG(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2125
            } else if (tos_type == ctos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2126
              obj->char_field_put(field_offset, STACK_INT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2127
            } else if (tos_type == stos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2128
              obj->short_field_put(field_offset, STACK_INT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2129
            } else if (tos_type == ftos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2130
              obj->float_field_put(field_offset, STACK_FLOAT(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2131
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2132
              obj->double_field_put(field_offset, STACK_DOUBLE(-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2133
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2134
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2135
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2136
          UPDATE_PC_AND_TOS_AND_CONTINUE(3, count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2137
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2138
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2139
      CASE(_new): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
        u2 index = Bytes::get_Java_u2(pc+1);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2141
        ConstantPool* constants = istate->method()->constants();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
        if (!constants->tag_at(index).is_unresolved_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2143
          // Make sure klass is initialized and doesn't have a finalizer
46427
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 40655
diff changeset
  2144
          Klass* entry = constants->resolved_klass_at(index);
33602
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33208
diff changeset
  2145
          InstanceKlass* ik = InstanceKlass::cast(entry);
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33208
diff changeset
  2146
          if (ik->is_initialized() && ik->can_be_fastpath_allocated() ) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
            size_t obj_size = ik->size_helper();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
            oop result = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2149
            // If the TLAB isn't pre-zeroed then we'll have to do it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
            bool need_zero = !ZeroTLAB;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
            if (UseTLAB) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
              result = (oop) THREAD->tlab().allocate(obj_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
            }
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2154
            // Disable non-TLAB-based fast-path, because profiling requires that all
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2155
            // allocations go through InterpreterRuntime::_new() if THREAD->tlab().allocate
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2156
            // returns NULL.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2157
#ifndef CC_INTERP_PROFILE
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2158
            if (result == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2159
              need_zero = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2160
              // Try allocate in shared eden
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2161
            retry:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2162
              HeapWord* compare_to = *Universe::heap()->top_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2163
              HeapWord* new_top = compare_to + obj_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2164
              if (new_top <= *Universe::heap()->end_addr()) {
47634
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
  2165
                if (Atomic::cmpxchg(new_top, Universe::heap()->top_addr(), compare_to) != compare_to) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2166
                  goto retry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2167
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2168
                result = (oop) compare_to;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2169
              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2170
            }
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2171
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2172
            if (result != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2173
              // Initialize object (if nonzero size and need) and then the header
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
              if (need_zero ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2175
                HeapWord* to_zero = (HeapWord*) result + sizeof(oopDesc) / oopSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2176
                obj_size -= sizeof(oopDesc) / oopSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2177
                if (obj_size > 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2178
                  memset(to_zero, 0, obj_size * HeapWordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2181
              if (UseBiasedLocking) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2182
                result->set_mark(ik->prototype_header());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
              } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2184
                result->set_mark(markOopDesc::prototype());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2185
              }
593
803947e176bd 6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents: 370
diff changeset
  2186
              result->set_klass_gap(0);
33749
6b67a05d2fcc 8141138: Zero fails to build
sgehwolf
parents: 33611
diff changeset
  2187
              result->set_klass(ik);
22862
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2188
              // Must prevent reordering of stores for object initialization
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2189
              // with stores that publish the new object.
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2190
              OrderAccess::storestore();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2191
              SET_STACK_OBJECT(result, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2192
              UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2193
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2194
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2195
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2196
        // Slow case allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2197
        CALL_VM(InterpreterRuntime::_new(THREAD, METHOD->constants(), index),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2198
                handle_exception);
22862
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2199
        // Must prevent reordering of stores for object initialization
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2200
        // with stores that publish the new object.
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2201
        OrderAccess::storestore();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2202
        SET_STACK_OBJECT(THREAD->vm_result(), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2203
        THREAD->set_vm_result(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2204
        UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2205
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2206
      CASE(_anewarray): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2207
        u2 index = Bytes::get_Java_u2(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2208
        jint size = STACK_INT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2209
        CALL_VM(InterpreterRuntime::anewarray(THREAD, METHOD->constants(), index, size),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2210
                handle_exception);
22862
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2211
        // Must prevent reordering of stores for object initialization
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2212
        // with stores that publish the new object.
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2213
        OrderAccess::storestore();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2214
        SET_STACK_OBJECT(THREAD->vm_result(), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2215
        THREAD->set_vm_result(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2216
        UPDATE_PC_AND_CONTINUE(3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2217
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2218
      CASE(_multianewarray): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2219
        jint dims = *(pc+3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2220
        jint size = STACK_INT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2221
        // stack grows down, dimensions are up!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2222
        jint *dimarray =
5422
6a9d399e7401 6949423: remove tagged stack interpreter for Zero
twisti
parents: 5419
diff changeset
  2223
                   (jint*)&topOfStack[dims * Interpreter::stackElementWords+
6a9d399e7401 6949423: remove tagged stack interpreter for Zero
twisti
parents: 5419
diff changeset
  2224
                                      Interpreter::stackElementWords-1];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2225
        //adjust pointer to start of stack element
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2226
        CALL_VM(InterpreterRuntime::multianewarray(THREAD, dimarray),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2227
                handle_exception);
22862
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2228
        // Must prevent reordering of stores for object initialization
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2229
        // with stores that publish the new object.
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2230
        OrderAccess::storestore();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2231
        SET_STACK_OBJECT(THREAD->vm_result(), -dims);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2232
        THREAD->set_vm_result(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2233
        UPDATE_PC_AND_TOS_AND_CONTINUE(4, -(dims-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2234
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2235
      CASE(_checkcast):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2236
          if (STACK_OBJECT(-1) != NULL) {
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  2237
            VERIFY_OOP(STACK_OBJECT(-1));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2238
            u2 index = Bytes::get_Java_u2(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2239
            // Constant pool may have actual klass or unresolved klass. If it is
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2240
            // unresolved we must resolve it.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2241
            if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2242
              CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2243
            }
46427
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 40655
diff changeset
  2244
            Klass* klassOf = (Klass*) METHOD->constants()->resolved_klass_at(index);
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2245
            Klass* objKlass = STACK_OBJECT(-1)->klass(); // ebx
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2246
            //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2247
            // Check for compatibilty. This check must not GC!!
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2248
            // Seems way more expensive now that we must dispatch.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2249
            //
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2250
            if (objKlass != klassOf && !objKlass->is_subtype_of(klassOf)) {
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2251
              // Decrement counter at checkcast.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2252
              BI_PROFILE_SUBTYPECHECK_FAILED(objKlass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2253
              ResourceMark rm(THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2254
              char* message = SharedRuntime::generate_class_cast_message(
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35928
diff changeset
  2255
                objKlass, klassOf);
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2256
              VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message, note_classCheck_trap);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2257
            }
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2258
            // Profile checkcast with null_seen and receiver.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2259
            BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/false, objKlass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2260
          } else {
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2261
            // Profile checkcast with null_seen and receiver.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2262
            BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/true, NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2263
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2264
          UPDATE_PC_AND_CONTINUE(3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2265
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2266
      CASE(_instanceof):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2267
          if (STACK_OBJECT(-1) == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2268
            SET_STACK_INT(0, -1);
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2269
            // Profile instanceof with null_seen and receiver.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2270
            BI_PROFILE_UPDATE_INSTANCEOF(/*null_seen=*/true, NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2271
          } else {
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  2272
            VERIFY_OOP(STACK_OBJECT(-1));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2273
            u2 index = Bytes::get_Java_u2(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2274
            // Constant pool may have actual klass or unresolved klass. If it is
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2275
            // unresolved we must resolve it.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2276
            if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2277
              CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2278
            }
46427
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 40655
diff changeset
  2279
            Klass* klassOf = (Klass*) METHOD->constants()->resolved_klass_at(index);
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2280
            Klass* objKlass = STACK_OBJECT(-1)->klass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2281
            //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2282
            // Check for compatibilty. This check must not GC!!
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2283
            // Seems way more expensive now that we must dispatch.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2284
            //
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2285
            if ( objKlass == klassOf || objKlass->is_subtype_of(klassOf)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2286
              SET_STACK_INT(1, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2287
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2288
              SET_STACK_INT(0, -1);
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2289
              // Decrement counter at checkcast.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2290
              BI_PROFILE_SUBTYPECHECK_FAILED(objKlass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2291
            }
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2292
            // Profile instanceof with null_seen and receiver.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2293
            BI_PROFILE_UPDATE_INSTANCEOF(/*null_seen=*/false, objKlass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2294
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2295
          UPDATE_PC_AND_CONTINUE(3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2296
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2297
      CASE(_ldc_w):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2298
      CASE(_ldc):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2299
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2300
          u2 index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2301
          bool wide = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2302
          int incr = 2; // frequent case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2303
          if (opcode == Bytecodes::_ldc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2304
            index = pc[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2305
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2306
            index = Bytes::get_Java_u2(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2307
            incr = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2308
            wide = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2309
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2310
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2311
          ConstantPool* constants = METHOD->constants();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2312
          switch (constants->tag_at(index).value()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2313
          case JVM_CONSTANT_Integer:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2314
            SET_STACK_INT(constants->int_at(index), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2315
            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2316
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2317
          case JVM_CONSTANT_Float:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2318
            SET_STACK_FLOAT(constants->float_at(index), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2319
            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2320
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2321
          case JVM_CONSTANT_String:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2322
            {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2323
              oop result = constants->resolved_references()->obj_at(index);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2324
              if (result == NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2325
                CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), handle_exception);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2326
                SET_STACK_OBJECT(THREAD->vm_result(), 0);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2327
                THREAD->set_vm_result(NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2328
              } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2329
                VERIFY_OOP(result);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2330
                SET_STACK_OBJECT(result, 0);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2331
              }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2332
            break;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2333
            }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2334
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2335
          case JVM_CONSTANT_Class:
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 8330
diff changeset
  2336
            VERIFY_OOP(constants->resolved_klass_at(index)->java_mirror());
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 8330
diff changeset
  2337
            SET_STACK_OBJECT(constants->resolved_klass_at(index)->java_mirror(), 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2338
            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2339
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2340
          case JVM_CONSTANT_UnresolvedClass:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2341
          case JVM_CONSTANT_UnresolvedClassInError:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2342
            CALL_VM(InterpreterRuntime::ldc(THREAD, wide), handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2343
            SET_STACK_OBJECT(THREAD->vm_result(), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2344
            THREAD->set_vm_result(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2345
            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2346
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2347
          case JVM_CONSTANT_Dynamic:
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2348
            {
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2349
              oop result = constants->resolved_references()->obj_at(index);
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2350
              if (result == NULL) {
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2351
                CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), handle_exception);
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2352
                result = THREAD->vm_result();
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2353
              }
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2354
              VERIFY_OOP(result);
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2355
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2356
              jvalue value;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2357
              BasicType type = java_lang_boxing_object::get_value(result, &value);
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2358
              switch (type) {
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2359
              case T_FLOAT:   SET_STACK_FLOAT(value.f, 0); break;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2360
              case T_INT:     SET_STACK_INT(value.i, 0); break;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2361
              case T_SHORT:   SET_STACK_INT(value.s, 0); break;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2362
              case T_BYTE:    SET_STACK_INT(value.b, 0); break;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2363
              case T_CHAR:    SET_STACK_INT(value.c, 0); break;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2364
              case T_BOOLEAN: SET_STACK_INT(value.z, 0); break;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2365
              default:  ShouldNotReachHere();
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2366
              }
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2367
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2368
              break;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2369
            }
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2370
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2371
          default:  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2372
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2373
          UPDATE_PC_AND_TOS_AND_CONTINUE(incr, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2374
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2375
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2376
      CASE(_ldc2_w):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2377
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2378
          u2 index = Bytes::get_Java_u2(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2379
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2380
          ConstantPool* constants = METHOD->constants();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2381
          switch (constants->tag_at(index).value()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2382
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2383
          case JVM_CONSTANT_Long:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2384
             SET_STACK_LONG(constants->long_at(index), 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2385
            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2386
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2387
          case JVM_CONSTANT_Double:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2388
             SET_STACK_DOUBLE(constants->double_at(index), 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2389
            break;
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2390
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2391
          case JVM_CONSTANT_Dynamic:
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2392
            {
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2393
              oop result = constants->resolved_references()->obj_at(index);
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2394
              if (result == NULL) {
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2395
                CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode), handle_exception);
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2396
                result = THREAD->vm_result();
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2397
              }
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2398
              VERIFY_OOP(result);
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2399
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2400
              jvalue value;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2401
              BasicType type = java_lang_boxing_object::get_value(result, &value);
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2402
              switch (type) {
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2403
              case T_DOUBLE: SET_STACK_DOUBLE(value.d, 1); break;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2404
              case T_LONG:   SET_STACK_LONG(value.j, 1); break;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2405
              default:  ShouldNotReachHere();
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2406
              }
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2407
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2408
              break;
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2409
            }
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2410
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2411
          default:  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2412
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2413
          UPDATE_PC_AND_TOS_AND_CONTINUE(3, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2414
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2415
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2416
      CASE(_fast_aldc_w):
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2417
      CASE(_fast_aldc): {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2418
        u2 index;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2419
        int incr;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2420
        if (opcode == Bytecodes::_fast_aldc) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2421
          index = pc[1];
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2422
          incr = 2;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2423
        } else {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2424
          index = Bytes::get_native_u2(pc+1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2425
          incr = 3;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2426
        }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2427
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2428
        // We are resolved if the resolved_references array contains a non-null object (CallSite, etc.)
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2429
        // This kind of CP cache entry does not need to match the flags byte, because
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2430
        // there is a 1-1 relation between bytecode type and CP entry type.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2431
        ConstantPool* constants = METHOD->constants();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2432
        oop result = constants->resolved_references()->obj_at(index);
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10565
diff changeset
  2433
        if (result == NULL) {
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2434
          CALL_VM(InterpreterRuntime::resolve_ldc(THREAD, (Bytecodes::Code) opcode),
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2435
                  handle_exception);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2436
          result = THREAD->vm_result();
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2437
        }
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49597
diff changeset
  2438
        if (oopDesc::equals(result, Universe::the_null_sentinel()))
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2439
          result = NULL;
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2440
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10565
diff changeset
  2441
        VERIFY_OOP(result);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10565
diff changeset
  2442
        SET_STACK_OBJECT(result, 0);
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2443
        UPDATE_PC_AND_TOS_AND_CONTINUE(incr, 1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2444
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2445
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2446
      CASE(_invokedynamic): {
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2447
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2448
        u4 index = Bytes::get_native_u4(pc+1);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2449
        ConstantPoolCacheEntry* cache = cp->constant_pool()->invokedynamic_cp_cache_entry_at(index);
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2450
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47906
diff changeset
  2451
        // We are resolved if the resolved_references array contains a non-null object (CallSite, etc.)
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2452
        // This kind of CP cache entry does not need to match the flags byte, because
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2453
        // there is a 1-1 relation between bytecode type and CP entry type.
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2454
        if (! cache->is_resolved((Bytecodes::Code) opcode)) {
30132
1f788eb36811 8076492: Make common code from template interpreter code
coleenp
parents: 30126
diff changeset
  2455
          CALL_VM(InterpreterRuntime::resolve_from_cache(THREAD, (Bytecodes::Code)opcode),
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2456
                  handle_exception);
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2457
          cache = cp->constant_pool()->invokedynamic_cp_cache_entry_at(index);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2458
        }
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2459
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2460
        Method* method = cache->f1_as_method();
18451
1c46952f2909 8017531: 8010460 changes broke bytecodeInterpreter.cpp
goetz
parents: 17875
diff changeset
  2461
        if (VerifyOops) method->verify();
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2462
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2463
        if (cache->has_appendix()) {
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2464
          ConstantPool* constants = METHOD->constants();
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2465
          SET_STACK_OBJECT(cache->appendix_if_resolved(constants), 0);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2466
          MORE_STACK(1);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2467
        }
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2468
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2469
        istate->set_msg(call_method);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2470
        istate->set_callee(method);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2471
        istate->set_callee_entry_point(method->from_interpreted_entry());
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2472
        istate->set_bcp_advance(5);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2473
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2474
        // Invokedynamic has got a call counter, just like an invokestatic -> increment!
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2475
        BI_PROFILE_UPDATE_CALL();
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2476
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2477
        UPDATE_PC_AND_RETURN(0); // I'll be back...
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2478
      }
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2479
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2480
      CASE(_invokehandle): {
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2481
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2482
        u2 index = Bytes::get_native_u2(pc+1);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2483
        ConstantPoolCacheEntry* cache = cp->entry_at(index);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2484
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2485
        if (! cache->is_resolved((Bytecodes::Code) opcode)) {
30132
1f788eb36811 8076492: Make common code from template interpreter code
coleenp
parents: 30126
diff changeset
  2486
          CALL_VM(InterpreterRuntime::resolve_from_cache(THREAD, (Bytecodes::Code)opcode),
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2487
                  handle_exception);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2488
          cache = cp->entry_at(index);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2489
        }
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2490
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2491
        Method* method = cache->f1_as_method();
18451
1c46952f2909 8017531: 8010460 changes broke bytecodeInterpreter.cpp
goetz
parents: 17875
diff changeset
  2492
        if (VerifyOops) method->verify();
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2493
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2494
        if (cache->has_appendix()) {
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2495
          ConstantPool* constants = METHOD->constants();
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2496
          SET_STACK_OBJECT(cache->appendix_if_resolved(constants), 0);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2497
          MORE_STACK(1);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2498
        }
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2499
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2500
        istate->set_msg(call_method);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2501
        istate->set_callee(method);
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2502
        istate->set_callee_entry_point(method->from_interpreted_entry());
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13952
diff changeset
  2503
        istate->set_bcp_advance(3);
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2504
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2505
        // Invokehandle has got a call counter, just like a final call -> increment!
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2506
        BI_PROFILE_UPDATE_FINALCALL();
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2507
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2508
        UPDATE_PC_AND_RETURN(0); // I'll be back...
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2509
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 9103
diff changeset
  2510
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2511
      CASE(_invokeinterface): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2512
        u2 index = Bytes::get_native_u2(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2513
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2514
        // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2515
        // out so c++ compiler has a chance for constant prop to fold everything possible away.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2516
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2517
        ConstantPoolCacheEntry* cache = cp->entry_at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2518
        if (!cache->is_resolved((Bytecodes::Code)opcode)) {
30132
1f788eb36811 8076492: Make common code from template interpreter code
coleenp
parents: 30126
diff changeset
  2519
          CALL_VM(InterpreterRuntime::resolve_from_cache(THREAD, (Bytecodes::Code)opcode),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2520
                  handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2521
          cache = cp->entry_at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2522
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2523
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2524
        istate->set_msg(call_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2525
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2526
        // Special case of invokeinterface called for virtual method of
50736
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2527
        // java.lang.Object.  See cpCache.cpp for details.
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2528
        Method* callee = NULL;
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10565
diff changeset
  2529
        if (cache->is_forced_virtual()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2530
          CHECK_NULL(STACK_OBJECT(-(cache->parameter_size())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2531
          if (cache->is_vfinal()) {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10565
diff changeset
  2532
            callee = cache->f2_as_vfinal_method();
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2533
            // Profile 'special case of invokeinterface' final call.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2534
            BI_PROFILE_UPDATE_FINALCALL();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2535
          } else {
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2536
            // Get receiver.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2537
            int parms = cache->parameter_size();
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2538
            // Same comments as invokevirtual apply here.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2539
            oop rcvr = STACK_OBJECT(-parms);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2540
            VERIFY_OOP(rcvr);
35928
084d5cb04276 8148945: JDK-8148481: Devirtualize Klass::vtable breaks Zero build
sgehwolf
parents: 35518
diff changeset
  2541
            Klass* rcvrKlass = rcvr->klass();
084d5cb04276 8148945: JDK-8148481: Devirtualize Klass::vtable breaks Zero build
sgehwolf
parents: 35518
diff changeset
  2542
            callee = (Method*) rcvrKlass->method_at_vtable(cache->f2_as_index());
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2543
            // Profile 'special case of invokeinterface' virtual call.
35928
084d5cb04276 8148945: JDK-8148481: Devirtualize Klass::vtable breaks Zero build
sgehwolf
parents: 35518
diff changeset
  2544
            BI_PROFILE_UPDATE_VIRTUALCALL(rcvrKlass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2545
          }
50736
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2546
        } else if (cache->is_vfinal()) {
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2547
          // private interface method invocations
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2548
          //
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2549
          // Ensure receiver class actually implements
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2550
          // the resolved interface class. The link resolver
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2551
          // does this, but only for the first time this
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2552
          // interface is being called.
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2553
          int parms = cache->parameter_size();
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2554
          oop rcvr = STACK_OBJECT(-parms);
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2555
          CHECK_NULL(rcvr);
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2556
          Klass* recv_klass = rcvr->klass();
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2557
          Klass* resolved_klass = cache->f1_as_klass();
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2558
          if (!recv_klass->is_subtype_of(resolved_klass)) {
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2559
            ResourceMark rm(THREAD);
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2560
            char buf[200];
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2561
            jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s",
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2562
              recv_klass->external_name(),
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2563
              resolved_klass->external_name());
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2564
            VM_JAVA_ERROR(vmSymbols::java_lang_IncompatibleClassChangeError(), buf, note_no_trap);
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2565
          }
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2566
          callee = cache->f2_as_vfinal_method();
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2567
        }
f703d45c5687 8203188: Add JEP-181 support to the Zero interpreter
sgehwolf
parents: 50429
diff changeset
  2568
        if (callee != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2569
          istate->set_callee(callee);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2570
          istate->set_callee_entry_point(callee->from_interpreted_entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2571
#ifdef VM_JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2572
          if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2573
            istate->set_callee_entry_point(callee->interpreter_entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2574
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2575
#endif /* VM_JVMTI */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2576
          istate->set_bcp_advance(5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2577
          UPDATE_PC_AND_RETURN(0); // I'll be back...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2578
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2579
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2580
        // this could definitely be cleaned up QQQ
48706
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2581
        Method *interface_method = cache->f2_as_interface_method();
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2582
        InstanceKlass* iclass = interface_method->method_holder();
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2583
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2584
        // get receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2585
        int parms = cache->parameter_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2586
        oop rcvr = STACK_OBJECT(-parms);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2587
        CHECK_NULL(rcvr);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2588
        InstanceKlass* int2 = (InstanceKlass*) rcvr->klass();
48706
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2589
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2590
        // Receiver subtype check against resolved interface klass (REFC).
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2591
        {
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2592
          Klass* refc = cache->f1_as_klass();
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2593
          itableOffsetEntry* scan;
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2594
          for (scan = (itableOffsetEntry*) int2->start_of_itable();
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2595
               scan->interface_klass() != NULL;
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2596
               scan++) {
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2597
            if (scan->interface_klass() == refc) {
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2598
              break;
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2599
            }
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2600
          }
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2601
          // Check that the entry is non-null.  A null entry means
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2602
          // that the receiver class doesn't implement the
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2603
          // interface, and wasn't the same as when the caller was
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2604
          // compiled.
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2605
          if (scan->interface_klass() == NULL) {
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2606
            VM_JAVA_ERROR(vmSymbols::java_lang_IncompatibleClassChangeError(), "", note_no_trap);
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2607
          }
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2608
        }
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2609
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2610
        itableOffsetEntry* ki = (itableOffsetEntry*) int2->start_of_itable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2611
        int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2612
        for ( i = 0 ; i < int2->itable_length() ; i++, ki++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2613
          if (ki->interface_klass() == iclass) break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2614
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2615
        // If the interface isn't found, this class doesn't implement this
49368
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49340
diff changeset
  2616
        // interface. The link resolver checks this but only for the first
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2617
        // time this interface is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2618
        if (i == int2->itable_length()) {
49368
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49340
diff changeset
  2619
          CALL_VM(InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose(THREAD, rcvr->klass(), iclass),
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49340
diff changeset
  2620
                  handle_exception);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2621
        }
48706
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2622
        int mindex = interface_method->itable_index();
69d1a1590485 8194739: Zero port of 8174962: Better interface invocations
aph
parents: 47906
diff changeset
  2623
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2624
        itableMethodEntry* im = ki->first_method_entry(rcvr->klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2625
        callee = im[mindex].method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2626
        if (callee == NULL) {
49368
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49340
diff changeset
  2627
          CALL_VM(InterpreterRuntime::throw_AbstractMethodErrorVerbose(THREAD, rcvr->klass(), interface_method),
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49340
diff changeset
  2628
                  handle_exception);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2629
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2630
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2631
        // Profile virtual call.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2632
        BI_PROFILE_UPDATE_VIRTUALCALL(rcvr->klass());
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2633
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2634
        istate->set_callee(callee);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2635
        istate->set_callee_entry_point(callee->from_interpreted_entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2636
#ifdef VM_JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2637
        if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2638
          istate->set_callee_entry_point(callee->interpreter_entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2639
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2640
#endif /* VM_JVMTI */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2641
        istate->set_bcp_advance(5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2642
        UPDATE_PC_AND_RETURN(0); // I'll be back...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2643
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2644
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2645
      CASE(_invokevirtual):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2646
      CASE(_invokespecial):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2647
      CASE(_invokestatic): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2648
        u2 index = Bytes::get_native_u2(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2649
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2650
        ConstantPoolCacheEntry* cache = cp->entry_at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2651
        // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2652
        // out so c++ compiler has a chance for constant prop to fold everything possible away.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2653
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2654
        if (!cache->is_resolved((Bytecodes::Code)opcode)) {
30132
1f788eb36811 8076492: Make common code from template interpreter code
coleenp
parents: 30126
diff changeset
  2655
          CALL_VM(InterpreterRuntime::resolve_from_cache(THREAD, (Bytecodes::Code)opcode),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2656
                  handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2657
          cache = cp->entry_at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2658
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2659
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2660
        istate->set_msg(call_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2661
        {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2662
          Method* callee;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2663
          if ((Bytecodes::Code)opcode == Bytecodes::_invokevirtual) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2664
            CHECK_NULL(STACK_OBJECT(-(cache->parameter_size())));
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2665
            if (cache->is_vfinal()) {
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2666
              callee = cache->f2_as_vfinal_method();
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2667
              // Profile final call.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2668
              BI_PROFILE_UPDATE_FINALCALL();
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2669
            } else {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2670
              // get receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2671
              int parms = cache->parameter_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2672
              // this works but needs a resourcemark and seems to create a vtable on every call:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2673
              // Method* callee = rcvr->klass()->vtable()->method_at(cache->f2_as_index());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2674
              //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2675
              // this fails with an assert
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2676
              // InstanceKlass* rcvrKlass = InstanceKlass::cast(STACK_OBJECT(-parms)->klass());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2677
              // but this works
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2678
              oop rcvr = STACK_OBJECT(-parms);
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2679
              VERIFY_OOP(rcvr);
35928
084d5cb04276 8148945: JDK-8148481: Devirtualize Klass::vtable breaks Zero build
sgehwolf
parents: 35518
diff changeset
  2680
              Klass* rcvrKlass = rcvr->klass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2681
              /*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2682
                Executing this code in java.lang.String:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2683
                    public String(char value[]) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2684
                          this.count = value.length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2685
                          this.value = (char[])value.clone();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2686
                     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2687
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2688
                 a find on rcvr->klass() reports:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2689
                 {type array char}{type array class}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2690
                  - klass: {other class}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2691
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2692
                  but using InstanceKlass::cast(STACK_OBJECT(-parms)->klass()) causes in assertion failure
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 33602
diff changeset
  2693
                  because rcvr->klass()->is_instance_klass() == 0
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2694
                  However it seems to have a vtable in the right location. Huh?
33602
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33208
diff changeset
  2695
                  Because vtables have the same offset for ArrayKlass and InstanceKlass.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2696
              */
35928
084d5cb04276 8148945: JDK-8148481: Devirtualize Klass::vtable breaks Zero build
sgehwolf
parents: 35518
diff changeset
  2697
              callee = (Method*) rcvrKlass->method_at_vtable(cache->f2_as_index());
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2698
              // Profile virtual call.
35928
084d5cb04276 8148945: JDK-8148481: Devirtualize Klass::vtable breaks Zero build
sgehwolf
parents: 35518
diff changeset
  2699
              BI_PROFILE_UPDATE_VIRTUALCALL(rcvrKlass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2700
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2701
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2702
            if ((Bytecodes::Code)opcode == Bytecodes::_invokespecial) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2703
              CHECK_NULL(STACK_OBJECT(-(cache->parameter_size())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2704
            }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10565
diff changeset
  2705
            callee = cache->f1_as_method();
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2706
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2707
            // Profile call.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2708
            BI_PROFILE_UPDATE_CALL();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2709
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2710
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2711
          istate->set_callee(callee);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2712
          istate->set_callee_entry_point(callee->from_interpreted_entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2713
#ifdef VM_JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2714
          if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2715
            istate->set_callee_entry_point(callee->interpreter_entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2716
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2717
#endif /* VM_JVMTI */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2718
          istate->set_bcp_advance(3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2719
          UPDATE_PC_AND_RETURN(0); // I'll be back...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2720
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2721
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2722
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2723
      /* Allocate memory for a new java object. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2724
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2725
      CASE(_newarray): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2726
        BasicType atype = (BasicType) *(pc+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2727
        jint size = STACK_INT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2728
        CALL_VM(InterpreterRuntime::newarray(THREAD, atype, size),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2729
                handle_exception);
22862
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2730
        // Must prevent reordering of stores for object initialization
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2731
        // with stores that publish the new object.
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2732
        OrderAccess::storestore();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2733
        SET_STACK_OBJECT(THREAD->vm_result(), -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2734
        THREAD->set_vm_result(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2735
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2736
        UPDATE_PC_AND_CONTINUE(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2737
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2738
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2739
      /* Throw an exception. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2740
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2741
      CASE(_athrow): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2742
          oop except_oop = STACK_OBJECT(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2743
          CHECK_NULL(except_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2744
          // set pending_exception so we use common code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2745
          THREAD->set_pending_exception(except_oop, NULL, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2746
          goto handle_exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2747
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2748
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2749
      /* goto and jsr. They are exactly the same except jsr pushes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2750
       * the address of the next instruction first.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2751
       */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2752
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2753
      CASE(_jsr): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2754
          /* push bytecode index on stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2755
          SET_STACK_ADDR(((address)pc - (intptr_t)(istate->method()->code_base()) + 3), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2756
          MORE_STACK(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2757
          /* FALL THROUGH */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2758
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2759
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2760
      CASE(_goto):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2761
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2762
          int16_t offset = (int16_t)Bytes::get_Java_u2(pc + 1);
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2763
          // Profile jump.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2764
          BI_PROFILE_UPDATE_JUMP();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2765
          address branch_pc = pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2766
          UPDATE_PC(offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2767
          DO_BACKEDGE_CHECKS(offset, branch_pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2768
          CONTINUE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2769
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2770
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2771
      CASE(_jsr_w): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2772
          /* push return address on the stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2773
          SET_STACK_ADDR(((address)pc - (intptr_t)(istate->method()->code_base()) + 5), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2774
          MORE_STACK(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2775
          /* FALL THROUGH */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2776
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2777
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2778
      CASE(_goto_w):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2779
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2780
          int32_t offset = Bytes::get_Java_u4(pc + 1);
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2781
          // Profile jump.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2782
          BI_PROFILE_UPDATE_JUMP();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2783
          address branch_pc = pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2784
          UPDATE_PC(offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2785
          DO_BACKEDGE_CHECKS(offset, branch_pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2786
          CONTINUE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2787
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2788
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2789
      /* return from a jsr or jsr_w */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2790
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2791
      CASE(_ret): {
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2792
          // Profile ret.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2793
          BI_PROFILE_UPDATE_RET(/*bci=*/((int)(intptr_t)(LOCALS_ADDR(pc[1]))));
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2794
          // Now, update the pc.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2795
          pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(pc[1]));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2796
          UPDATE_PC_AND_CONTINUE(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2797
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2798
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2799
      /* debugger breakpoint */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2800
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2801
      CASE(_breakpoint): {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2802
          Bytecodes::Code original_bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2803
          DECACHE_STATE();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2804
          SET_LAST_JAVA_FRAME();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2805
          original_bytecode = InterpreterRuntime::get_original_bytecode_at(THREAD,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2806
                              METHOD, pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2807
          RESET_LAST_JAVA_FRAME();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2808
          CACHE_STATE();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2809
          if (THREAD->has_pending_exception()) goto handle_exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2810
            CALL_VM(InterpreterRuntime::_breakpoint(THREAD, METHOD, pc),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2811
                                                    handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2812
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2813
          opcode = (jubyte)original_bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2814
          goto opcode_switch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2815
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2816
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2817
      DEFAULT:
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
  2818
          fatal("Unimplemented opcode %d = %s", opcode,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
  2819
                Bytecodes::name((Bytecodes::Code)opcode));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2820
          goto finish;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2821
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2822
      } /* switch(opc) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2823
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2824
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2825
#ifdef USELABELS
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2826
    check_for_exception:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2827
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2828
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2829
      if (!THREAD->has_pending_exception()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2830
        CONTINUE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2831
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2832
      /* We will be gcsafe soon, so flush our state. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2833
      DECACHE_PC();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2834
      goto handle_exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2835
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2836
  do_continue: ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2837
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2838
  } /* while (1) interpreter loop */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2839
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2840
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2841
  // An exception exists in the thread state see whether this activation can handle it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2842
  handle_exception: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2843
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2844
    HandleMarkCleaner __hmc(THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2845
    Handle except_oop(THREAD, THREAD->pending_exception());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2846
    // Prevent any subsequent HandleMarkCleaner in the VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2847
    // from freeing the except_oop handle.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2848
    HandleMark __hm(THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2849
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2850
    THREAD->clear_pending_exception();
49390
95f0b54a3024 8199220: Zero build broken after 8195103, 8191102 and 8189871
enevill
parents: 49368
diff changeset
  2851
    assert(except_oop() != NULL, "No exception to process");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2852
    intptr_t continuation_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2853
    // expression stack is emptied
5422
6a9d399e7401 6949423: remove tagged stack interpreter for Zero
twisti
parents: 5419
diff changeset
  2854
    topOfStack = istate->stack_base() - Interpreter::stackElementWords;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2855
    CALL_VM(continuation_bci = (intptr_t)InterpreterRuntime::exception_handler_for_exception(THREAD, except_oop()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2856
            handle_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2857
46724
a4653c2a4e65 8185263: Fix zero build after 8169881, 8175318, 8178350
stuefe
parents: 46427
diff changeset
  2858
    except_oop = Handle(THREAD, THREAD->vm_result());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2859
    THREAD->set_vm_result(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2860
    if (continuation_bci >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2861
      // Place exception on top of stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2862
      SET_STACK_OBJECT(except_oop(), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2863
      MORE_STACK(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2864
      pc = METHOD->code_base() + continuation_bci;
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 33749
diff changeset
  2865
      if (log_is_enabled(Info, exceptions)) {
35518
cd2749cebb92 8147482: Zero build fails after 8144953
sgehwolf
parents: 35477
diff changeset
  2866
        ResourceMark rm(THREAD);
35477
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2867
        stringStream tempst;
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2868
        tempst.print("interpreter method <%s>\n"
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2869
                     " at bci %d, continuing at %d for thread " INTPTR_FORMAT,
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2870
                     METHOD->print_value_string(),
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2871
                     (int)(istate->bcp() - METHOD->code_base()),
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2872
                     (int)continuation_bci, p2i(THREAD));
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2873
        Exceptions::log_exception(except_oop, tempst);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2874
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2875
      // for AbortVMOnException flag
33208
5ec6ffa63c57 8136577: Make AbortVMOnException available in product builds
poonam
parents: 33105
diff changeset
  2876
      Exceptions::debug_check_abort(except_oop);
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2877
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2878
      // Update profiling data.
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  2879
      BI_PROFILE_ALIGN_TO_CURRENT_BCI();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2880
      goto run;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2881
    }
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 33749
diff changeset
  2882
    if (log_is_enabled(Info, exceptions)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2883
      ResourceMark rm;
35477
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2884
      stringStream tempst;
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2885
      tempst.print("interpreter method <%s>\n"
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2886
             " at bci %d, unwinding for thread " INTPTR_FORMAT,
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2887
             METHOD->print_value_string(),
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2888
             (int)(istate->bcp() - METHOD->code_base()),
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2889
             p2i(THREAD));
7a00b08d27bc 8144953: runtime/CommandLine/TraceExceptionsTest.java fails when exception is thrown in compiled code
rprotacio
parents: 35216
diff changeset
  2890
      Exceptions::log_exception(except_oop, tempst);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2891
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2892
    // for AbortVMOnException flag
33208
5ec6ffa63c57 8136577: Make AbortVMOnException available in product builds
poonam
parents: 33105
diff changeset
  2893
    Exceptions::debug_check_abort(except_oop);
5ec6ffa63c57 8136577: Make AbortVMOnException available in product builds
poonam
parents: 33105
diff changeset
  2894
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2895
    // No handler in this activation, unwind and try again
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2896
    THREAD->set_pending_exception(except_oop(), NULL, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2897
    goto handle_return;
22816
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2898
  }  // handle_exception:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2899
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2900
  // Return from an interpreter invocation with the result of the interpretation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2901
  // on the top of the Java Stack (or a pending exception)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2902
22816
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2903
  handle_Pop_Frame: {
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2904
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2905
    // We don't really do anything special here except we must be aware
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2906
    // that we can get here without ever locking the method (if sync).
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2907
    // Also we skip the notification of the exit.
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2908
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2909
    istate->set_msg(popping_frame);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2910
    // Clear pending so while the pop is in process
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2911
    // we don't start another one if a call_vm is done.
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2912
    THREAD->clr_pop_frame_pending();
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2913
    // Let interpreter (only) see the we're in the process of popping a frame
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2914
    THREAD->set_pop_frame_in_process();
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2915
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2916
    goto handle_return;
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2917
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2918
  } // handle_Pop_Frame
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2919
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2920
  // ForceEarlyReturn ends a method, and returns to the caller with a return value
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2921
  // given by the invoker of the early return.
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2922
  handle_Early_Return: {
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2923
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2924
    istate->set_msg(early_return);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2925
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2926
    // Clear expression stack.
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2927
    topOfStack = istate->stack_base() - Interpreter::stackElementWords;
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2928
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2929
    JvmtiThreadState *ts = THREAD->jvmti_thread_state();
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2930
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2931
    // Push the value to be returned.
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2932
    switch (istate->method()->result_type()) {
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2933
      case T_BOOLEAN:
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2934
      case T_SHORT:
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2935
      case T_BYTE:
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2936
      case T_CHAR:
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2937
      case T_INT:
22817
58900c191539 8020121: PPC64: fix build in cppInterpreter after 8019519
goetz
parents: 22816
diff changeset
  2938
        SET_STACK_INT(ts->earlyret_value().i, 0);
22816
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2939
        MORE_STACK(1);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2940
        break;
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2941
      case T_LONG:
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2942
        SET_STACK_LONG(ts->earlyret_value().j, 1);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2943
        MORE_STACK(2);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2944
        break;
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2945
      case T_FLOAT:
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2946
        SET_STACK_FLOAT(ts->earlyret_value().f, 0);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2947
        MORE_STACK(1);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2948
        break;
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2949
      case T_DOUBLE:
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2950
        SET_STACK_DOUBLE(ts->earlyret_value().d, 1);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2951
        MORE_STACK(2);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2952
        break;
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2953
      case T_ARRAY:
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2954
      case T_OBJECT:
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2955
        SET_STACK_OBJECT(ts->earlyret_oop(), 0);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2956
        MORE_STACK(1);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2957
        break;
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2958
    }
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2959
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2960
    ts->clr_earlyret_value();
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2961
    ts->set_earlyret_oop(NULL);
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2962
    ts->clr_earlyret_pending();
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2963
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2964
    // Fall through to handle_return.
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2965
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2966
  } // handle_Early_Return
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2967
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2968
  handle_return: {
22862
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2969
    // A storestore barrier is required to order initialization of
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2970
    // final fields with publishing the reference to the object that
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2971
    // holds the field. Without the barrier the value of final fields
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2972
    // can be observed to change.
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2973
    OrderAccess::storestore();
495f1688b8b1 8029957: PPC64 (part 213): cppInterpreter: memory ordering for object initialization
goetz
parents: 22849
diff changeset
  2974
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2975
    DECACHE_STATE();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2976
22816
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2977
    bool suppress_error = istate->msg() == popping_frame || istate->msg() == early_return;
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  2978
    bool suppress_exit_event = THREAD->has_pending_exception() || istate->msg() == popping_frame;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2979
    Handle original_exception(THREAD, THREAD->pending_exception());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2980
    Handle illegal_state_oop(THREAD, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2981
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2982
    // We'd like a HandleMark here to prevent any subsequent HandleMarkCleaner
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2983
    // in any following VM entries from freeing our live handles, but illegal_state_oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2984
    // isn't really allocated yet and so doesn't become live until later and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2985
    // in unpredicatable places. Instead we must protect the places where we enter the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2986
    // VM. It would be much simpler (and safer) if we could allocate a real handle with
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2987
    // a NULL oop in it and then overwrite the oop later as needed. This isn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2988
    // unfortunately isn't possible.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2989
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2990
    THREAD->clear_pending_exception();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2991
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2992
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2993
    // As far as we are concerned we have returned. If we have a pending exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2994
    // that will be returned as this invocation's result. However if we get any
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2995
    // exception(s) while checking monitor state one of those IllegalMonitorStateExceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2996
    // will be our final result (i.e. monitor exception trumps a pending exception).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2997
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2998
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2999
    // If we never locked the method (or really passed the point where we would have),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3000
    // there is no need to unlock it (or look for other monitors), since that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3001
    // could not have happened.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3002
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3003
    if (THREAD->do_not_unlock()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3004
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3005
      // Never locked, reset the flag now because obviously any caller must
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3006
      // have passed their point of locking for us to have gotten here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3007
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3008
      THREAD->clr_do_not_unlock();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3009
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3010
      // At this point we consider that we have returned. We now check that the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3011
      // locks were properly block structured. If we find that they were not
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3012
      // used properly we will return with an illegal monitor exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3013
      // The exception is checked by the caller not the callee since this
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3014
      // checking is considered to be part of the invocation and therefore
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3015
      // in the callers scope (JVM spec 8.13).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3016
      //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3017
      // Another weird thing to watch for is if the method was locked
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3018
      // recursively and then not exited properly. This means we must
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3019
      // examine all the entries in reverse time(and stack) order and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3020
      // unlock as we find them. If we find the method monitor before
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3021
      // we are at the initial entry then we should throw an exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3022
      // It is not clear the template based interpreter does this
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3023
      // correctly
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3024
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3025
      BasicObjectLock* base = istate->monitor_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3026
      BasicObjectLock* end = (BasicObjectLock*) istate->stack_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3027
      bool method_unlock_needed = METHOD->is_synchronized();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3028
      // We know the initial monitor was used for the method don't check that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3029
      // slot in the loop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3030
      if (method_unlock_needed) base--;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3031
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3032
      // Check all the monitors to see they are unlocked. Install exception if found to be locked.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3033
      while (end < base) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3034
        oop lockee = end->obj();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3035
        if (lockee != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3036
          BasicLock* lock = end->lock();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3037
          markOop header = lock->displaced_header();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3038
          end->set_obj(NULL);
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3039
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3040
          if (!lockee->mark()->has_bias_pattern()) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3041
            // If it isn't recursive we either must swap old header or call the runtime
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3042
            if (header != NULL) {
47634
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
  3043
              markOop old_header = markOopDesc::encode(lock);
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
  3044
              if (lockee->cas_set_mark(header, old_header) != old_header) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3045
                // restore object for the slow case
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3046
                end->set_obj(lockee);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3047
                {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3048
                  // Prevent any HandleMarkCleaner from freeing our live handles
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3049
                  HandleMark __hm(THREAD);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3050
                  CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, end));
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3051
                }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3052
              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3053
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3054
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3055
          // One error is plenty
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3056
          if (illegal_state_oop() == NULL && !suppress_error) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3057
            {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3058
              // Prevent any HandleMarkCleaner from freeing our live handles
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3059
              HandleMark __hm(THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3060
              CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3061
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3062
            assert(THREAD->has_pending_exception(), "Lost our exception!");
46724
a4653c2a4e65 8185263: Fix zero build after 8169881, 8175318, 8178350
stuefe
parents: 46427
diff changeset
  3063
            illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3064
            THREAD->clear_pending_exception();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3065
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3066
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3067
        end++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3068
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3069
      // Unlock the method if needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3070
      if (method_unlock_needed) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3071
        if (base->obj() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3072
          // The method is already unlocked this is not good.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3073
          if (illegal_state_oop() == NULL && !suppress_error) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3074
            {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3075
              // Prevent any HandleMarkCleaner from freeing our live handles
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3076
              HandleMark __hm(THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3077
              CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3078
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3079
            assert(THREAD->has_pending_exception(), "Lost our exception!");
46724
a4653c2a4e65 8185263: Fix zero build after 8169881, 8175318, 8178350
stuefe
parents: 46427
diff changeset
  3080
            illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3081
            THREAD->clear_pending_exception();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3082
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3083
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3084
          //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3085
          // The initial monitor is always used for the method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3086
          // However if that slot is no longer the oop for the method it was unlocked
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3087
          // and reused by something that wasn't unlocked!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3088
          //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3089
          // deopt can come in with rcvr dead because c2 knows
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3090
          // its value is preserved in the monitor. So we can't use locals[0] at all
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3091
          // and must use first monitor slot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3092
          //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3093
          oop rcvr = base->obj();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3094
          if (rcvr == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3095
            if (!suppress_error) {
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  3096
              VM_JAVA_ERROR_NO_JUMP(vmSymbols::java_lang_NullPointerException(), "", note_nullCheck_trap);
46724
a4653c2a4e65 8185263: Fix zero build after 8169881, 8175318, 8178350
stuefe
parents: 46427
diff changeset
  3097
              illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3098
              THREAD->clear_pending_exception();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3099
            }
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3100
          } else if (UseHeavyMonitors) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3101
            {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3102
              // Prevent any HandleMarkCleaner from freeing our live handles.
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3103
              HandleMark __hm(THREAD);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3104
              CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, base));
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3105
            }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3106
            if (THREAD->has_pending_exception()) {
46724
a4653c2a4e65 8185263: Fix zero build after 8169881, 8175318, 8178350
stuefe
parents: 46427
diff changeset
  3107
              if (!suppress_error) illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3108
              THREAD->clear_pending_exception();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3109
            }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3110
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3111
            BasicLock* lock = base->lock();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3112
            markOop header = lock->displaced_header();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3113
            base->set_obj(NULL);
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3114
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3115
            if (!rcvr->mark()->has_bias_pattern()) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3116
              base->set_obj(NULL);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3117
              // If it isn't recursive we either must swap old header or call the runtime
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3118
              if (header != NULL) {
47634
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
  3119
                markOop old_header = markOopDesc::encode(lock);
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
  3120
                if (rcvr->cas_set_mark(header, old_header) != old_header) {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3121
                  // restore object for the slow case
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3122
                  base->set_obj(rcvr);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3123
                  {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3124
                    // Prevent any HandleMarkCleaner from freeing our live handles
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3125
                    HandleMark __hm(THREAD);
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3126
                    CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, base));
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3127
                  }
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3128
                  if (THREAD->has_pending_exception()) {
46724
a4653c2a4e65 8185263: Fix zero build after 8169881, 8175318, 8178350
stuefe
parents: 46427
diff changeset
  3129
                    if (!suppress_error) illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3130
                    THREAD->clear_pending_exception();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3131
                  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3132
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3133
              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3134
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3135
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3136
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3137
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3138
    }
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3139
    // Clear the do_not_unlock flag now.
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3140
    THREAD->clr_do_not_unlock();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3141
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3142
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3143
    // Notify jvmti/jvmdi
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3144
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3145
    // NOTE: we do not notify a method_exit if we have a pending exception,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3146
    // including an exception we generate for unlocking checks.  In the former
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3147
    // case, JVMDI has already been notified by our call for the exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3148
    // and in both cases as far as JVMDI is concerned we have already returned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3149
    // If we notify it again JVMDI will be all confused about how many frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3150
    // are still on the stack (4340444).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3151
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3152
    // NOTE Further! It turns out the the JVMTI spec in fact expects to see
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3153
    // method_exit events whenever we leave an activation unless it was done
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3154
    // for popframe. This is nothing like jvmdi. However we are passing the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3155
    // tests at the moment (apparently because they are jvmdi based) so rather
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3156
    // than change this code and possibly fail tests we will leave it alone
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3157
    // (with this note) in anticipation of changing the vm and the tests
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3158
    // simultaneously.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3159
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3160
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3161
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3162
    suppress_exit_event = suppress_exit_event || illegal_state_oop() != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3163
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3164
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3165
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3166
#ifdef VM_JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3167
      if (_jvmti_interp_events) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3168
        // Whenever JVMTI puts a thread in interp_only_mode, method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3169
        // entry/exit events are sent for that thread to track stack depth.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3170
        if ( !suppress_exit_event && THREAD->is_interp_only_mode() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3171
          {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3172
            // Prevent any HandleMarkCleaner from freeing our live handles
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3173
            HandleMark __hm(THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3174
            CALL_VM_NOCHECK(InterpreterRuntime::post_method_exit(THREAD));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3175
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3176
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3177
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3178
#endif /* VM_JVMTI */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3179
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3180
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3181
    // See if we are returning any exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3182
    // A pending exception that was pending prior to a possible popping frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3183
    // overrides the popping frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3184
    //
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  3185
    assert(!suppress_error || (suppress_error && illegal_state_oop() == NULL), "Error was not suppressed");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3186
    if (illegal_state_oop() != NULL || original_exception() != NULL) {
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 22833
diff changeset
  3187
      // Inform the frame manager we have no result.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3188
      istate->set_msg(throwing_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3189
      if (illegal_state_oop() != NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3190
        THREAD->set_pending_exception(illegal_state_oop(), NULL, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3191
      else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3192
        THREAD->set_pending_exception(original_exception(), NULL, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3193
      UPDATE_PC_AND_RETURN(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3194
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3195
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3196
    if (istate->msg() == popping_frame) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3197
      // Make it simpler on the assembly code and set the message for the frame pop.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3198
      // returns
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3199
      if (istate->prev() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3200
        // We must be returning to a deoptimized frame (because popframe only happens between
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3201
        // two interpreted frames). We need to save the current arguments in C heap so that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3202
        // the deoptimized frame when it restarts can copy the arguments to its expression
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3203
        // stack and re-execute the call. We also have to notify deoptimization that this
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1896
diff changeset
  3204
        // has occurred and to pick the preserved args copy them to the deoptimized frame's
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3205
        // java expression stack. Yuck.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3206
        //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3207
        THREAD->popframe_preserve_args(in_ByteSize(METHOD->size_of_parameters() * wordSize),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3208
                                LOCALS_SLOT(METHOD->size_of_parameters() - 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3209
        THREAD->set_popframe_condition_bit(JavaThread::popframe_force_deopt_reexecution_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3210
      }
22816
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  3211
    } else {
3ec00abe2942 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.
goetz
parents: 22815
diff changeset
  3212
      istate->set_msg(return_from_method);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3213
    }
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  3214
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  3215
    // Normal return
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  3216
    // Advance the pc and return to frame manager
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
  3217
    UPDATE_PC_AND_RETURN(1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3218
  } /* handle_return: */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3219
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3220
// This is really a fatal error return
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3221
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3222
finish:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3223
  DECACHE_TOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3224
  DECACHE_PC();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3225
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3226
  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3227
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3228
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3229
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3230
 * All the code following this point is only produced once and is not present
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3231
 * in the JVMTI version of the interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3232
*/
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3233
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3234
#ifndef VM_JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3235
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3236
// This constructor should only be used to contruct the object to signal
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3237
// interpreter initialization. All other instances should be created by
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3238
// the frame manager.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3239
BytecodeInterpreter::BytecodeInterpreter(messages msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3240
  if (msg != initialize) ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3241
  _msg = msg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3242
  _self_link = this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3243
  _prev_link = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3244
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3245
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3246
// Inline static functions for Java Stack and Local manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3247
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3248
// The implementations are platform dependent. We have to worry about alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3249
// issues on some machines which can change on the same platform depending on
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3250
// whether it is an LP64 machine also.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3251
address BytecodeInterpreter::stack_slot(intptr_t *tos, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3252
  return (address) tos[Interpreter::expr_index_at(-offset)];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3253
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3254
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3255
jint BytecodeInterpreter::stack_int(intptr_t *tos, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3256
  return *((jint*) &tos[Interpreter::expr_index_at(-offset)]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3257
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3258
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3259
jfloat BytecodeInterpreter::stack_float(intptr_t *tos, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3260
  return *((jfloat *) &tos[Interpreter::expr_index_at(-offset)]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3261
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3262
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3263
oop BytecodeInterpreter::stack_object(intptr_t *tos, int offset) {
22849
b8670e920530 8028514: PPC64: Fix C++ Interpreter after '7195622: CheckUnhandledOops has limited usefulness now'
simonis
parents: 22836
diff changeset
  3264
  return cast_to_oop(tos [Interpreter::expr_index_at(-offset)]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3265
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3266
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3267
jdouble BytecodeInterpreter::stack_double(intptr_t *tos, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3268
  return ((VMJavaVal64*) &tos[Interpreter::expr_index_at(-offset)])->d;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3269
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3270
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3271
jlong BytecodeInterpreter::stack_long(intptr_t *tos, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3272
  return ((VMJavaVal64 *) &tos[Interpreter::expr_index_at(-offset)])->l;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3273
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3274
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3275
// only used for value types
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3276
void BytecodeInterpreter::set_stack_slot(intptr_t *tos, address value,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3277
                                                        int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3278
  *((address *)&tos[Interpreter::expr_index_at(-offset)]) = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3279
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3280
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3281
void BytecodeInterpreter::set_stack_int(intptr_t *tos, int value,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3282
                                                       int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3283
  *((jint *)&tos[Interpreter::expr_index_at(-offset)]) = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3284
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3285
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3286
void BytecodeInterpreter::set_stack_float(intptr_t *tos, jfloat value,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3287
                                                         int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3288
  *((jfloat *)&tos[Interpreter::expr_index_at(-offset)]) = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3289
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3290
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3291
void BytecodeInterpreter::set_stack_object(intptr_t *tos, oop value,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3292
                                                          int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3293
  *((oop *)&tos[Interpreter::expr_index_at(-offset)]) = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3294
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3295
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3296
// needs to be platform dep for the 32 bit platforms.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3297
void BytecodeInterpreter::set_stack_double(intptr_t *tos, jdouble value,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3298
                                                          int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3299
  ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3300
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3301
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3302
void BytecodeInterpreter::set_stack_double_from_addr(intptr_t *tos,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3303
                                              address addr, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3304
  (((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3305
                        ((VMJavaVal64*)addr)->d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3306
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3307
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3308
void BytecodeInterpreter::set_stack_long(intptr_t *tos, jlong value,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3309
                                                        int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3310
  ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3311
  ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3312
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3313
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3314
void BytecodeInterpreter::set_stack_long_from_addr(intptr_t *tos,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3315
                                            address addr, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3316
  ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3317
  ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3318
                        ((VMJavaVal64*)addr)->l;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3319
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3320
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3321
// Locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3322
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3323
address BytecodeInterpreter::locals_slot(intptr_t* locals, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3324
  return (address)locals[Interpreter::local_index_at(-offset)];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3325
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3326
jint BytecodeInterpreter::locals_int(intptr_t* locals, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3327
  return (jint)locals[Interpreter::local_index_at(-offset)];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3328
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3329
jfloat BytecodeInterpreter::locals_float(intptr_t* locals, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3330
  return (jfloat)locals[Interpreter::local_index_at(-offset)];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3331
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3332
oop BytecodeInterpreter::locals_object(intptr_t* locals, int offset) {
22849
b8670e920530 8028514: PPC64: Fix C++ Interpreter after '7195622: CheckUnhandledOops has limited usefulness now'
simonis
parents: 22836
diff changeset
  3333
  return cast_to_oop(locals[Interpreter::local_index_at(-offset)]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3334
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3335
jdouble BytecodeInterpreter::locals_double(intptr_t* locals, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3336
  return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3337
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3338
jlong BytecodeInterpreter::locals_long(intptr_t* locals, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3339
  return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3340
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3341
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3342
// Returns the address of locals value.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3343
address BytecodeInterpreter::locals_long_at(intptr_t* locals, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3344
  return ((address)&locals[Interpreter::local_index_at(-(offset+1))]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3345
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3346
address BytecodeInterpreter::locals_double_at(intptr_t* locals, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3347
  return ((address)&locals[Interpreter::local_index_at(-(offset+1))]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3348
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3349
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3350
// Used for local value or returnAddress
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3351
void BytecodeInterpreter::set_locals_slot(intptr_t *locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3352
                                   address value, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3353
  *((address*)&locals[Interpreter::local_index_at(-offset)]) = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3354
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3355
void BytecodeInterpreter::set_locals_int(intptr_t *locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3356
                                   jint value, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3357
  *((jint *)&locals[Interpreter::local_index_at(-offset)]) = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3358
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3359
void BytecodeInterpreter::set_locals_float(intptr_t *locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3360
                                   jfloat value, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3361
  *((jfloat *)&locals[Interpreter::local_index_at(-offset)]) = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3362
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3363
void BytecodeInterpreter::set_locals_object(intptr_t *locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3364
                                   oop value, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3365
  *((oop *)&locals[Interpreter::local_index_at(-offset)]) = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3366
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3367
void BytecodeInterpreter::set_locals_double(intptr_t *locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3368
                                   jdouble value, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3369
  ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3370
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3371
void BytecodeInterpreter::set_locals_long(intptr_t *locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3372
                                   jlong value, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3373
  ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3374
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3375
void BytecodeInterpreter::set_locals_double_from_addr(intptr_t *locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3376
                                   address addr, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3377
  ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = ((VMJavaVal64*)addr)->d;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3378
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3379
void BytecodeInterpreter::set_locals_long_from_addr(intptr_t *locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3380
                                   address addr, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3381
  ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = ((VMJavaVal64*)addr)->l;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3382
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3383
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3384
void BytecodeInterpreter::astore(intptr_t* tos,    int stack_offset,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3385
                          intptr_t* locals, int locals_offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3386
  intptr_t value = tos[Interpreter::expr_index_at(-stack_offset)];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3387
  locals[Interpreter::local_index_at(-locals_offset)] = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3388
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3389
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3390
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3391
void BytecodeInterpreter::copy_stack_slot(intptr_t *tos, int from_offset,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3392
                                   int to_offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3393
  tos[Interpreter::expr_index_at(-to_offset)] =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3394
                      (intptr_t)tos[Interpreter::expr_index_at(-from_offset)];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3395
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3396
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3397
void BytecodeInterpreter::dup(intptr_t *tos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3398
  copy_stack_slot(tos, -1, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3399
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3400
void BytecodeInterpreter::dup2(intptr_t *tos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3401
  copy_stack_slot(tos, -2, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3402
  copy_stack_slot(tos, -1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3403
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3404
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3405
void BytecodeInterpreter::dup_x1(intptr_t *tos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3406
  /* insert top word two down */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3407
  copy_stack_slot(tos, -1, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3408
  copy_stack_slot(tos, -2, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3409
  copy_stack_slot(tos, 0, -2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3410
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3411
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3412
void BytecodeInterpreter::dup_x2(intptr_t *tos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3413
  /* insert top word three down  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3414
  copy_stack_slot(tos, -1, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3415
  copy_stack_slot(tos, -2, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3416
  copy_stack_slot(tos, -3, -2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3417
  copy_stack_slot(tos, 0, -3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3418
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3419
void BytecodeInterpreter::dup2_x1(intptr_t *tos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3420
  /* insert top 2 slots three down */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3421
  copy_stack_slot(tos, -1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3422
  copy_stack_slot(tos, -2, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3423
  copy_stack_slot(tos, -3, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3424
  copy_stack_slot(tos, 1, -2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3425
  copy_stack_slot(tos, 0, -3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3426
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3427
void BytecodeInterpreter::dup2_x2(intptr_t *tos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3428
  /* insert top 2 slots four down */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3429
  copy_stack_slot(tos, -1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3430
  copy_stack_slot(tos, -2, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3431
  copy_stack_slot(tos, -3, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3432
  copy_stack_slot(tos, -4, -2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3433
  copy_stack_slot(tos, 1, -3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3434
  copy_stack_slot(tos, 0, -4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3435
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3436
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3437
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3438
void BytecodeInterpreter::swap(intptr_t *tos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3439
  // swap top two elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3440
  intptr_t val = tos[Interpreter::expr_index_at(1)];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3441
  // Copy -2 entry to -1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3442
  copy_stack_slot(tos, -2, -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3443
  // Store saved -1 entry into -2
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3444
  tos[Interpreter::expr_index_at(2)] = val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3445
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3446
// --------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3447
// Non-product code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3448
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3449
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3450
const char* BytecodeInterpreter::C_msg(BytecodeInterpreter::messages msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3451
  switch (msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3452
     case BytecodeInterpreter::no_request:  return("no_request");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3453
     case BytecodeInterpreter::initialize:  return("initialize");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3454
     // status message to C++ interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3455
     case BytecodeInterpreter::method_entry:  return("method_entry");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3456
     case BytecodeInterpreter::method_resume:  return("method_resume");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3457
     case BytecodeInterpreter::got_monitors:  return("got_monitors");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3458
     case BytecodeInterpreter::rethrow_exception:  return("rethrow_exception");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3459
     // requests to frame manager from C++ interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3460
     case BytecodeInterpreter::call_method:  return("call_method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3461
     case BytecodeInterpreter::return_from_method:  return("return_from_method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3462
     case BytecodeInterpreter::more_monitors:  return("more_monitors");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3463
     case BytecodeInterpreter::throwing_exception:  return("throwing_exception");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3464
     case BytecodeInterpreter::popping_frame:  return("popping_frame");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3465
     case BytecodeInterpreter::do_osr:  return("do_osr");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3466
     // deopt
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3467
     case BytecodeInterpreter::deopt_resume:  return("deopt_resume");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3468
     case BytecodeInterpreter::deopt_resume2:  return("deopt_resume2");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3469
     default: return("BAD MSG");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3470
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3471
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3472
void
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3473
BytecodeInterpreter::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3474
  tty->print_cr("thread: " INTPTR_FORMAT, (uintptr_t) this->_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3475
  tty->print_cr("bcp: " INTPTR_FORMAT, (uintptr_t) this->_bcp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3476
  tty->print_cr("locals: " INTPTR_FORMAT, (uintptr_t) this->_locals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3477
  tty->print_cr("constants: " INTPTR_FORMAT, (uintptr_t) this->_constants);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3478
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3479
    ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3480
    char *method_name = _method->name_and_sig_as_C_string();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3481
    tty->print_cr("method: " INTPTR_FORMAT "[ %s ]",  (uintptr_t) this->_method, method_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3482
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3483
  tty->print_cr("mdx: " INTPTR_FORMAT, (uintptr_t) this->_mdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3484
  tty->print_cr("stack: " INTPTR_FORMAT, (uintptr_t) this->_stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3485
  tty->print_cr("msg: %s", C_msg(this->_msg));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3486
  tty->print_cr("result_to_call._callee: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3487
  tty->print_cr("result_to_call._callee_entry_point: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee_entry_point);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3488
  tty->print_cr("result_to_call._bcp_advance: %d ", this->_result._to_call._bcp_advance);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3489
  tty->print_cr("osr._osr_buf: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_buf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3490
  tty->print_cr("osr._osr_entry: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3491
  tty->print_cr("prev_link: " INTPTR_FORMAT, (uintptr_t) this->_prev_link);
26142
038e0f01b4a9 8055231: ZERO variant build is broken
coleenp
parents: 25374
diff changeset
  3492
  tty->print_cr("native_mirror: " INTPTR_FORMAT, (uintptr_t) p2i(this->_oop_temp));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3493
  tty->print_cr("stack_base: " INTPTR_FORMAT, (uintptr_t) this->_stack_base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3494
  tty->print_cr("stack_limit: " INTPTR_FORMAT, (uintptr_t) this->_stack_limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3495
  tty->print_cr("monitor_base: " INTPTR_FORMAT, (uintptr_t) this->_monitor_base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3496
#ifdef SPARC
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3497
  tty->print_cr("last_Java_pc: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3498
  tty->print_cr("frame_bottom: " INTPTR_FORMAT, (uintptr_t) this->_frame_bottom);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3499
  tty->print_cr("&native_fresult: " INTPTR_FORMAT, (uintptr_t) &this->_native_fresult);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3500
  tty->print_cr("native_lresult: " INTPTR_FORMAT, (uintptr_t) this->_native_lresult);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3501
#endif
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 22878
diff changeset
  3502
#if !defined(ZERO) && defined(PPC)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3503
  tty->print_cr("last_Java_fp: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_fp);
15475
73896d91270c 6518907: cleanup IA64 specific code in Hotspot
morris
parents: 14488
diff changeset
  3504
#endif // !ZERO
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3505
  tty->print_cr("self_link: " INTPTR_FORMAT, (uintptr_t) this->_self_link);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3506
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3507
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3508
extern "C" {
22811
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3509
  void PI(uintptr_t arg) {
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3510
    ((BytecodeInterpreter*)arg)->print();
3a58336f9ace 8017317: PPC64 (part 7): cppInterpreter: implement support for biased locking
goetz
parents: 17875
diff changeset
  3511
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3512
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3513
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3514
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3515
#endif // JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3516
#endif // CC_INTERP