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