hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
author jmasa
Wed, 20 Apr 2011 20:32:45 -0700
changeset 9187 a719b53bd4ba
parent 9136 94ebba447157
parent 9176 42d9d1010f38
child 9636 363ca5579aff
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
     1
/*
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 7397
diff changeset
     2
 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
     3
 * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
     5
 *
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
     8
 * published by the Free Software Foundation.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
     9
 *
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    14
 * accompanied this code).
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    15
 *
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    19
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5427
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5427
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5427
diff changeset
    22
 * questions.
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    23
 *
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    24
 */
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    25
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    26
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    27
#include "asm/assembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    28
#include "interpreter/bytecodeHistogram.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    29
#include "interpreter/cppInterpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    30
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    31
#include "interpreter/interpreterGenerator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    32
#include "interpreter/interpreterRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    33
#include "oops/arrayOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    34
#include "oops/methodDataOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    35
#include "oops/methodOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    36
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    37
#include "prims/jvmtiExport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    38
#include "prims/jvmtiThreadState.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    39
#include "runtime/arguments.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    40
#include "runtime/deoptimization.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    41
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    42
#include "runtime/interfaceSupport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    43
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    44
#include "runtime/stubRoutines.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    45
#include "runtime/synchronizer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    46
#include "runtime/timer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    47
#include "runtime/vframeArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    48
#include "stack_zero.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    49
#include "utilities/debug.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    50
#ifdef SHARK
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    51
#include "shark/shark_globals.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    52
#endif
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    53
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    54
#ifdef CC_INTERP
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    55
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    56
#define fixup_after_potential_safepoint()       \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    57
  method = istate->method()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    58
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
    59
#define CALL_VM_NOCHECK_NOFIX(func)             \
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    60
  thread->set_last_Java_frame();                \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    61
  func;                                         \
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
    62
  thread->reset_last_Java_frame();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
    63
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
    64
#define CALL_VM_NOCHECK(func)                   \
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
    65
  CALL_VM_NOCHECK_NOFIX(func)                   \
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    66
  fixup_after_potential_safepoint()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    67
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
    68
int CppInterpreter::normal_entry(methodOop method, intptr_t UNUSED, TRAPS) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    69
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    70
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    71
  // Allocate and initialize our frame.
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
    72
  InterpreterFrame *frame = InterpreterFrame::build(method, CHECK_0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    73
  thread->push_zero_frame(frame);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    74
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    75
  // Execute those bytecodes!
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    76
  main_loop(0, THREAD);
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
    77
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
    78
  // No deoptimized frames on the stack
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
    79
  return 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    80
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    81
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    82
void CppInterpreter::main_loop(int recurse, TRAPS) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    83
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    84
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    85
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    86
  // If we are entering from a deopt we may need to call
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    87
  // ourself a few times in order to get to our frame.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    88
  if (recurse)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    89
    main_loop(recurse - 1, THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    90
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    91
  InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    92
  interpreterState istate = frame->interpreter_state();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    93
  methodOop method = istate->method();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    94
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    95
  intptr_t *result = NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    96
  int result_slots = 0;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    97
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    98
  while (true) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    99
    // We can set up the frame anchor with everything we want at
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   100
    // this point as we are thread_in_Java and no safepoints can
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   101
    // occur until we go to vm mode.  We do have to clear flags
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   102
    // on return from vm but that is it.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   103
    thread->set_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   104
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   105
    // Call the interpreter
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   106
    if (JvmtiExport::can_post_interpreter_events())
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   107
      BytecodeInterpreter::runWithChecks(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   108
    else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   109
      BytecodeInterpreter::run(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   110
    fixup_after_potential_safepoint();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   111
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   112
    // Clear the frame anchor
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   113
    thread->reset_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   114
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   115
    // Examine the message from the interpreter to decide what to do
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   116
    if (istate->msg() == BytecodeInterpreter::call_method) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   117
      methodOop callee = istate->callee();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   118
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   119
      // Trim back the stack to put the parameters at the top
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   120
      stack->set_sp(istate->stack() + 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   121
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   122
      // Make the call
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   123
      Interpreter::invoke_method(callee, istate->callee_entry_point(), THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   124
      fixup_after_potential_safepoint();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   125
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   126
      // Convert the result
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   127
      istate->set_stack(stack->sp() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   128
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   129
      // Restore the stack
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   130
      stack->set_sp(istate->stack_limit() + 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   131
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   132
      // Resume the interpreter
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   133
      istate->set_msg(BytecodeInterpreter::method_resume);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   134
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   135
    else if (istate->msg() == BytecodeInterpreter::more_monitors) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   136
      int monitor_words = frame::interpreter_frame_monitor_size();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   137
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   138
      // Allocate the space
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   139
      stack->overflow_check(monitor_words, THREAD);
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   140
      if (HAS_PENDING_EXCEPTION)
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   141
        break;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   142
      stack->alloc(monitor_words * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   143
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   144
      // Move the expression stack contents
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   145
      for (intptr_t *p = istate->stack() + 1; p < istate->stack_base(); p++)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   146
        *(p - monitor_words) = *p;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   147
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   148
      // Move the expression stack pointers
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   149
      istate->set_stack_limit(istate->stack_limit() - monitor_words);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   150
      istate->set_stack(istate->stack() - monitor_words);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   151
      istate->set_stack_base(istate->stack_base() - monitor_words);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   152
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   153
      // Zero the new monitor so the interpreter can find it.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   154
      ((BasicObjectLock *) istate->stack_base())->set_obj(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   155
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   156
      // Resume the interpreter
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   157
      istate->set_msg(BytecodeInterpreter::got_monitors);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   158
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   159
    else if (istate->msg() == BytecodeInterpreter::return_from_method) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   160
      // Copy the result into the caller's frame
4897
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
   161
      result_slots = type2size[result_type_of(method)];
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   162
      assert(result_slots >= 0 && result_slots <= 2, "what?");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   163
      result = istate->stack() + result_slots;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   164
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   165
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   166
    else if (istate->msg() == BytecodeInterpreter::throwing_exception) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   167
      assert(HAS_PENDING_EXCEPTION, "should do");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   168
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   169
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   170
    else if (istate->msg() == BytecodeInterpreter::do_osr) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   171
      // Unwind the current frame
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   172
      thread->pop_zero_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   173
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   174
      // Remove any extension of the previous frame
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   175
      int extra_locals = method->max_locals() - method->size_of_parameters();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   176
      stack->set_sp(stack->sp() + extra_locals);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   177
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   178
      // Jump into the OSR method
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   179
      Interpreter::invoke_osr(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   180
        method, istate->osr_entry(), istate->osr_buf(), THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   181
      return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   182
    }
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   183
    else if (istate->msg() == BytecodeInterpreter::call_method_handle) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   184
      oop method_handle = istate->callee();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   185
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   186
      // Trim back the stack to put the parameters at the top
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   187
      stack->set_sp(istate->stack() + 1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   188
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   189
      // Make the call
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   190
      process_method_handle(method_handle, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   191
      fixup_after_potential_safepoint();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   192
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   193
      // Convert the result
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   194
      istate->set_stack(stack->sp() - 1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   195
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   196
      // Restore the stack
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   197
      stack->set_sp(istate->stack_limit() + 1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   198
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   199
      // Resume the interpreter
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   200
      istate->set_msg(BytecodeInterpreter::method_resume);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   201
    }
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   202
    else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   203
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   204
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   205
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   206
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   207
  // Unwind the current frame
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   208
  thread->pop_zero_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   209
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   210
  // Pop our local variables
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   211
  stack->set_sp(stack->sp() + method->max_locals());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   212
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   213
  // Push our result
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   214
  for (int i = 0; i < result_slots; i++)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   215
    stack->push(result[-i]);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   216
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   217
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   218
int CppInterpreter::native_entry(methodOop method, intptr_t UNUSED, TRAPS) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   219
  // Make sure method is native and not abstract
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   220
  assert(method->is_native() && !method->is_abstract(), "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   221
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   222
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   223
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   224
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   225
  // Allocate and initialize our frame
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   226
  InterpreterFrame *frame = InterpreterFrame::build(method, CHECK_0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   227
  thread->push_zero_frame(frame);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   228
  interpreterState istate = frame->interpreter_state();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   229
  intptr_t *locals = istate->locals();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   230
4448
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   231
  // Update the invocation counter
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   232
  if ((UseCompiler || CountCompiledCalls) && !method->is_synchronized()) {
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   233
    InvocationCounter *counter = method->invocation_counter();
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   234
    counter->increment();
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   235
    if (counter->reached_InvocationLimit()) {
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   236
      CALL_VM_NOCHECK(
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   237
        InterpreterRuntime::frequency_counter_overflow(thread, NULL));
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   238
      if (HAS_PENDING_EXCEPTION)
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   239
        goto unwind_and_return;
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   240
    }
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   241
  }
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   242
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   243
  // Lock if necessary
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   244
  BasicObjectLock *monitor;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   245
  monitor = NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   246
  if (method->is_synchronized()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   247
    monitor = (BasicObjectLock*) istate->stack_base();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   248
    oop lockee = monitor->obj();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   249
    markOop disp = lockee->mark()->set_unlocked();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   250
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   251
    monitor->lock()->set_displaced_header(disp);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   252
    if (Atomic::cmpxchg_ptr(monitor, lockee->mark_addr(), disp) != disp) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   253
      if (thread->is_lock_owned((address) disp->clear_lock_bits())) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   254
        monitor->lock()->set_displaced_header(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   255
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   256
      else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   257
        CALL_VM_NOCHECK(InterpreterRuntime::monitorenter(thread, monitor));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   258
        if (HAS_PENDING_EXCEPTION)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   259
          goto unwind_and_return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   260
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   261
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   262
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   263
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   264
  // Get the signature handler
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   265
  InterpreterRuntime::SignatureHandler *handler; {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   266
    address handlerAddr = method->signature_handler();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   267
    if (handlerAddr == NULL) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   268
      CALL_VM_NOCHECK(InterpreterRuntime::prepare_native_call(thread, method));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   269
      if (HAS_PENDING_EXCEPTION)
4568
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   270
        goto unlock_unwind_and_return;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   271
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   272
      handlerAddr = method->signature_handler();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   273
      assert(handlerAddr != NULL, "eh?");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   274
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   275
    if (handlerAddr == (address) InterpreterRuntime::slow_signature_handler) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   276
      CALL_VM_NOCHECK(handlerAddr =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   277
        InterpreterRuntime::slow_signature_handler(thread, method, NULL,NULL));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   278
      if (HAS_PENDING_EXCEPTION)
4568
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   279
        goto unlock_unwind_and_return;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   280
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   281
    handler = \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   282
      InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   283
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   284
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   285
  // Get the native function entry point
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   286
  address function;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   287
  function = method->native_function();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   288
  assert(function != NULL, "should be set if signature handler is");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   289
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   290
  // Build the argument list
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   291
  stack->overflow_check(handler->argument_count() * 2, THREAD);
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   292
  if (HAS_PENDING_EXCEPTION)
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   293
    goto unlock_unwind_and_return;
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   294
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   295
  void **arguments;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   296
  void *mirror; {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   297
    arguments =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   298
      (void **) stack->alloc(handler->argument_count() * sizeof(void **));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   299
    void **dst = arguments;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   300
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   301
    void *env = thread->jni_environment();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   302
    *(dst++) = &env;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   303
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   304
    if (method->is_static()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   305
      istate->set_oop_temp(
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 7397
diff changeset
   306
        method->constants()->pool_holder()->java_mirror());
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   307
      mirror = istate->oop_temp_addr();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   308
      *(dst++) = &mirror;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   309
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   310
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   311
    intptr_t *src = locals;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   312
    for (int i = dst - arguments; i < handler->argument_count(); i++) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   313
      ffi_type *type = handler->argument_type(i);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   314
      if (type == &ffi_type_pointer) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   315
        if (*src) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   316
          stack->push((intptr_t) src);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   317
          *(dst++) = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   318
        }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   319
        else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   320
          *(dst++) = src;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   321
        }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   322
        src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   323
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   324
      else if (type->size == 4) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   325
        *(dst++) = src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   326
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   327
      else if (type->size == 8) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   328
        src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   329
        *(dst++) = src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   330
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   331
      else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   332
        ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   333
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   334
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   335
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   336
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   337
  // Set up the Java frame anchor
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   338
  thread->set_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   339
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   340
  // Change the thread state to _thread_in_native
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   341
  ThreadStateTransition::transition_from_java(thread, _thread_in_native);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   342
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   343
  // Make the call
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   344
  intptr_t result[4 - LogBytesPerWord];
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   345
  ffi_call(handler->cif(), (void (*)()) function, result, arguments);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   346
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   347
  // Change the thread state back to _thread_in_Java.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   348
  // ThreadStateTransition::transition_from_native() cannot be used
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   349
  // here because it does not check for asynchronous exceptions.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   350
  // We have to manage the transition ourself.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   351
  thread->set_thread_state(_thread_in_native_trans);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   352
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   353
  // Make sure new state is visible in the GC thread
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   354
  if (os::is_MP()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   355
    if (UseMembar) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   356
      OrderAccess::fence();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   357
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   358
    else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   359
      InterfaceSupport::serialize_memory(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   360
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   361
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   362
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   363
  // Handle safepoint operations, pending suspend requests,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   364
  // and pending asynchronous exceptions.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   365
  if (SafepointSynchronize::do_call_back() ||
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   366
      thread->has_special_condition_for_native_trans()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   367
    JavaThread::check_special_condition_for_native_trans(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   368
    CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   369
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   370
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   371
  // Finally we can change the thread state to _thread_in_Java.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   372
  thread->set_thread_state(_thread_in_Java);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   373
  fixup_after_potential_safepoint();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   374
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   375
  // Clear the frame anchor
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   376
  thread->reset_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   377
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   378
  // If the result was an oop then unbox it and store it in
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   379
  // oop_temp where the garbage collector can see it before
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   380
  // we release the handle it might be protected by.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   381
  if (handler->result_type() == &ffi_type_pointer) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   382
    if (result[0])
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   383
      istate->set_oop_temp(*(oop *) result[0]);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   384
    else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   385
      istate->set_oop_temp(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   386
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   387
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   388
  // Reset handle block
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   389
  thread->active_handles()->clear();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   390
4568
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   391
 unlock_unwind_and_return:
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   392
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   393
  // Unlock if necessary
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   394
  if (monitor) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   395
    BasicLock *lock = monitor->lock();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   396
    markOop header = lock->displaced_header();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   397
    oop rcvr = monitor->obj();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   398
    monitor->set_obj(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   399
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   400
    if (header != NULL) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   401
      if (Atomic::cmpxchg_ptr(header, rcvr->mark_addr(), lock) != lock) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   402
        monitor->set_obj(rcvr); {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   403
          HandleMark hm(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   404
          CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(thread, monitor));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   405
        }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   406
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   407
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   408
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   409
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   410
 unwind_and_return:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   411
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   412
  // Unwind the current activation
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   413
  thread->pop_zero_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   414
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   415
  // Pop our parameters
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   416
  stack->set_sp(stack->sp() + method->size_of_parameters());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   417
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   418
  // Push our result
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   419
  if (!HAS_PENDING_EXCEPTION) {
4897
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
   420
    BasicType type = result_type_of(method);
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
   421
    stack->set_sp(stack->sp() - type2size[type]);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   422
4897
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
   423
    switch (type) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   424
    case T_VOID:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   425
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   426
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   427
    case T_BOOLEAN:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   428
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   429
      result[0] <<= (BitsPerWord - BitsPerByte);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   430
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   431
      SET_LOCALS_INT(*(jboolean *) result != 0, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   432
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   433
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   434
    case T_CHAR:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   435
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   436
      result[0] <<= (BitsPerWord - BitsPerShort);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   437
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   438
      SET_LOCALS_INT(*(jchar *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   439
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   440
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   441
    case T_BYTE:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   442
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   443
      result[0] <<= (BitsPerWord - BitsPerByte);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   444
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   445
      SET_LOCALS_INT(*(jbyte *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   446
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   447
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   448
    case T_SHORT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   449
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   450
      result[0] <<= (BitsPerWord - BitsPerShort);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   451
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   452
      SET_LOCALS_INT(*(jshort *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   453
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   454
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   455
    case T_INT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   456
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   457
      result[0] <<= (BitsPerWord - BitsPerInt);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   458
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   459
      SET_LOCALS_INT(*(jint *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   460
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   461
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   462
    case T_LONG:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   463
      SET_LOCALS_LONG(*(jlong *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   464
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   465
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   466
    case T_FLOAT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   467
      SET_LOCALS_FLOAT(*(jfloat *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   468
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   469
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   470
    case T_DOUBLE:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   471
      SET_LOCALS_DOUBLE(*(jdouble *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   472
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   473
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   474
    case T_OBJECT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   475
    case T_ARRAY:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   476
      SET_LOCALS_OBJECT(istate->oop_temp(), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   477
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   478
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   479
    default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   480
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   481
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   482
  }
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   483
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   484
  // No deoptimized frames on the stack
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   485
  return 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   486
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   487
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   488
int CppInterpreter::accessor_entry(methodOop method, intptr_t UNUSED, TRAPS) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   489
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   490
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   491
  intptr_t *locals = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   492
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   493
  // Drop into the slow path if we need a safepoint check
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   494
  if (SafepointSynchronize::do_call_back()) {
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   495
    return normal_entry(method, 0, THREAD);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   496
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   497
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   498
  // Load the object pointer and drop into the slow path
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   499
  // if we have a NullPointerException
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   500
  oop object = LOCALS_OBJECT(0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   501
  if (object == NULL) {
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   502
    return normal_entry(method, 0, THREAD);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   503
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   504
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   505
  // Read the field index from the bytecode, which looks like this:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   506
  //  0:  aload_0
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   507
  //  1:  getfield
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   508
  //  2:    index
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   509
  //  3:    index
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   510
  //  4:  ireturn/areturn
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   511
  // NB this is not raw bytecode: index is in machine order
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   512
  u1 *code = method->code_base();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   513
  assert(code[0] == Bytecodes::_aload_0 &&
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   514
         code[1] == Bytecodes::_getfield &&
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   515
         (code[4] == Bytecodes::_ireturn ||
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   516
          code[4] == Bytecodes::_areturn), "should do");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   517
  u2 index = Bytes::get_native_u2(&code[2]);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   518
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   519
  // Get the entry from the constant pool cache, and drop into
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   520
  // the slow path if it has not been resolved
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   521
  constantPoolCacheOop cache = method->constants()->cache();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   522
  ConstantPoolCacheEntry* entry = cache->entry_at(index);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   523
  if (!entry->is_resolved(Bytecodes::_getfield)) {
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   524
    return normal_entry(method, 0, THREAD);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   525
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   526
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   527
  // Get the result and push it onto the stack
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   528
  switch (entry->flag_state()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   529
  case ltos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   530
  case dtos:
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   531
    stack->overflow_check(1, CHECK_0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   532
    stack->alloc(wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   533
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   534
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   535
  if (entry->is_volatile()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   536
    switch (entry->flag_state()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   537
    case ctos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   538
      SET_LOCALS_INT(object->char_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   539
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   540
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   541
    case btos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   542
      SET_LOCALS_INT(object->byte_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   543
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   544
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   545
    case stos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   546
      SET_LOCALS_INT(object->short_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   547
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   548
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   549
    case itos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   550
      SET_LOCALS_INT(object->int_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   551
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   552
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   553
    case ltos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   554
      SET_LOCALS_LONG(object->long_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   555
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   556
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   557
    case ftos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   558
      SET_LOCALS_FLOAT(object->float_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   559
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   560
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   561
    case dtos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   562
      SET_LOCALS_DOUBLE(object->double_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   563
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   564
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   565
    case atos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   566
      SET_LOCALS_OBJECT(object->obj_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   567
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   568
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   569
    default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   570
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   571
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   572
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   573
  else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   574
    switch (entry->flag_state()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   575
    case ctos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   576
      SET_LOCALS_INT(object->char_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   577
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   578
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   579
    case btos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   580
      SET_LOCALS_INT(object->byte_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   581
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   582
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   583
    case stos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   584
      SET_LOCALS_INT(object->short_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   585
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   586
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   587
    case itos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   588
      SET_LOCALS_INT(object->int_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   589
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   590
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   591
    case ltos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   592
      SET_LOCALS_LONG(object->long_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   593
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   594
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   595
    case ftos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   596
      SET_LOCALS_FLOAT(object->float_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   597
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   598
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   599
    case dtos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   600
      SET_LOCALS_DOUBLE(object->double_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   601
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   602
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   603
    case atos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   604
      SET_LOCALS_OBJECT(object->obj_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   605
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   606
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   607
    default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   608
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   609
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   610
  }
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   611
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   612
  // No deoptimized frames on the stack
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   613
  return 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   614
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   615
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   616
int CppInterpreter::empty_entry(methodOop method, intptr_t UNUSED, TRAPS) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   617
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   618
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   619
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   620
  // Drop into the slow path if we need a safepoint check
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   621
  if (SafepointSynchronize::do_call_back()) {
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   622
    return normal_entry(method, 0, THREAD);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   623
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   624
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   625
  // Pop our parameters
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   626
  stack->set_sp(stack->sp() + method->size_of_parameters());
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   627
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   628
  // No deoptimized frames on the stack
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   629
  return 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   630
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   631
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   632
int CppInterpreter::method_handle_entry(methodOop method,
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   633
                                        intptr_t UNUSED, TRAPS) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   634
  JavaThread *thread = (JavaThread *) THREAD;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   635
  ZeroStack *stack = thread->zero_stack();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   636
  int argument_slots = method->size_of_parameters();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   637
  int result_slots = type2size[result_type_of(method)];
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   638
  intptr_t *vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   639
  intptr_t *unwind_sp = vmslots + argument_slots;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   640
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   641
  // Find the MethodType
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   642
  address p = (address) method;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   643
  for (jint* pc = method->method_type_offsets_chain(); (*pc) != -1; pc++) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   644
    p = *(address*)(p + (*pc));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   645
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   646
  oop method_type = (oop) p;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   647
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   648
  // The MethodHandle is in the slot after the arguments
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   649
  oop form = java_lang_invoke_MethodType::form(method_type);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   650
  int num_vmslots = java_lang_invoke_MethodTypeForm::vmslots(form);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   651
  assert(argument_slots == num_vmslots + 1, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   652
  oop method_handle = VMSLOTS_OBJECT(num_vmslots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   653
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   654
  // InvokeGeneric requires some extra shuffling
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   655
  oop mhtype = java_lang_invoke_MethodHandle::type(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   656
  bool is_exact = mhtype == method_type;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   657
  if (!is_exact) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   658
    if (method->intrinsic_id() == vmIntrinsics::_invokeExact) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   659
      CALL_VM_NOCHECK_NOFIX(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   660
        InterpreterRuntime::throw_WrongMethodTypeException(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   661
          thread, method_type, mhtype));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   662
      // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   663
      assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   664
      stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   665
      return 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   666
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   667
    assert(method->intrinsic_id() == vmIntrinsics::_invokeGeneric, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   668
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   669
    // Load up an adapter from the calling type
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   670
    // NB the x86 code for this (in methodHandles_x86.cpp, search for
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   671
    // "genericInvoker") is really really odd.  I'm hoping it's trying
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   672
    // to accomodate odd VM/class library combinations I can ignore.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   673
    oop adapter = java_lang_invoke_MethodTypeForm::genericInvoker(form);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   674
    if (adapter == NULL) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   675
      CALL_VM_NOCHECK_NOFIX(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   676
        InterpreterRuntime::throw_WrongMethodTypeException(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   677
          thread, method_type, mhtype));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   678
      // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   679
      assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   680
      stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   681
      return 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   682
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   683
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   684
    // Adapters are shared among form-families of method-type.  The
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   685
    // type being called is passed as a trusted first argument so that
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   686
    // the adapter knows the actual types of its arguments and return
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   687
    // values.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   688
    insert_vmslots(num_vmslots + 1, 1, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   689
    if (HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   690
      // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   691
      stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   692
      return 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   693
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   694
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   695
    vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   696
    num_vmslots++;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   697
    SET_VMSLOTS_OBJECT(method_type, num_vmslots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   698
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   699
    method_handle = adapter;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   700
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   701
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   702
  // Start processing
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   703
  process_method_handle(method_handle, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   704
  if (HAS_PENDING_EXCEPTION)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   705
    result_slots = 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   706
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   707
  // If this is an invokeExact then the eventual callee will not
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   708
  // have unwound the method handle argument so we have to do it.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   709
  // If a result is being returned the it will be above the method
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   710
  // handle argument we're unwinding.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   711
  if (is_exact) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   712
    intptr_t result[2];
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   713
    for (int i = 0; i < result_slots; i++)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   714
      result[i] = stack->pop();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   715
    stack->pop();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   716
    for (int i = result_slots - 1; i >= 0; i--)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   717
      stack->push(result[i]);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   718
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   719
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   720
  // Check
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   721
  assert(stack->sp() == unwind_sp - result_slots, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   722
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   723
  // No deoptimized frames on the stack
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   724
  return 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   725
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   726
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   727
void CppInterpreter::process_method_handle(oop method_handle, TRAPS) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   728
  JavaThread *thread = (JavaThread *) THREAD;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   729
  ZeroStack *stack = thread->zero_stack();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   730
  intptr_t *vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   731
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   732
  bool direct_to_method = false;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   733
  BasicType src_rtype = T_ILLEGAL;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   734
  BasicType dst_rtype = T_ILLEGAL;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   735
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   736
  MethodHandleEntry *entry =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   737
    java_lang_invoke_MethodHandle::vmentry(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   738
  MethodHandles::EntryKind entry_kind =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   739
    (MethodHandles::EntryKind) (((intptr_t) entry) & 0xffffffff);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   740
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   741
  methodOop method = NULL;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   742
  switch (entry_kind) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   743
  case MethodHandles::_invokestatic_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   744
    direct_to_method = true;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   745
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   746
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   747
  case MethodHandles::_invokespecial_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   748
  case MethodHandles::_invokevirtual_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   749
  case MethodHandles::_invokeinterface_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   750
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   751
      oop receiver =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   752
        VMSLOTS_OBJECT(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   753
          java_lang_invoke_MethodHandle::vmslots(method_handle) - 1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   754
      if (receiver == NULL) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   755
          stack->set_sp(calculate_unwind_sp(stack, method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   756
          CALL_VM_NOCHECK_NOFIX(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   757
            throw_exception(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   758
              thread, vmSymbols::java_lang_NullPointerException()));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   759
          // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   760
          assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   761
          return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   762
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   763
      if (entry_kind != MethodHandles::_invokespecial_mh) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   764
        int index = java_lang_invoke_DirectMethodHandle::vmindex(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   765
        instanceKlass* rcvrKlass =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   766
          (instanceKlass *) receiver->klass()->klass_part();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   767
        if (entry_kind == MethodHandles::_invokevirtual_mh) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   768
          method = (methodOop) rcvrKlass->start_of_vtable()[index];
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   769
        }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   770
        else {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   771
          oop iclass = java_lang_invoke_MethodHandle::vmtarget(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   772
          itableOffsetEntry* ki =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   773
            (itableOffsetEntry *) rcvrKlass->start_of_itable();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   774
          int i, length = rcvrKlass->itable_length();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   775
          for (i = 0; i < length; i++, ki++ ) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   776
            if (ki->interface_klass() == iclass)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   777
              break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   778
          }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   779
          if (i == length) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   780
            stack->set_sp(calculate_unwind_sp(stack, method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   781
            CALL_VM_NOCHECK_NOFIX(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   782
              throw_exception(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   783
                thread, vmSymbols::java_lang_IncompatibleClassChangeError()));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   784
            // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   785
            assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   786
            return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   787
          }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   788
          itableMethodEntry* im = ki->first_method_entry(receiver->klass());
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   789
          method = im[index].method();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   790
          if (method == NULL) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   791
            stack->set_sp(calculate_unwind_sp(stack, method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   792
            CALL_VM_NOCHECK_NOFIX(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   793
              throw_exception(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   794
                thread, vmSymbols::java_lang_AbstractMethodError()));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   795
            // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   796
            assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   797
            return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   798
          }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   799
        }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   800
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   801
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   802
    direct_to_method = true;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   803
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   804
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   805
  case MethodHandles::_bound_ref_direct_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   806
  case MethodHandles::_bound_int_direct_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   807
  case MethodHandles::_bound_long_direct_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   808
    direct_to_method = true;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   809
    // fall through
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   810
  case MethodHandles::_bound_ref_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   811
  case MethodHandles::_bound_int_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   812
  case MethodHandles::_bound_long_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   813
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   814
      BasicType arg_type  = T_ILLEGAL;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   815
      int       arg_mask  = -1;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   816
      int       arg_slots = -1;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   817
      MethodHandles::get_ek_bound_mh_info(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   818
        entry_kind, arg_type, arg_mask, arg_slots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   819
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   820
        java_lang_invoke_BoundMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   821
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   822
      // Create the new slot(s)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   823
      intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   824
      insert_vmslots(arg_slot, arg_slots, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   825
      if (HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   826
        // all oops trashed
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   827
        stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   828
        return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   829
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   830
      vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   831
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   832
      // Store bound argument into new stack slot
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   833
      oop arg = java_lang_invoke_BoundMethodHandle::argument(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   834
      if (arg_type == T_OBJECT) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   835
        assert(arg_slots == 1, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   836
        SET_VMSLOTS_OBJECT(arg, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   837
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   838
      else {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   839
        jvalue arg_value;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   840
        arg_type = java_lang_boxing_object::get_value(arg, &arg_value);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   841
        switch (arg_type) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   842
        case T_BOOLEAN:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   843
          SET_VMSLOTS_INT(arg_value.z, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   844
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   845
        case T_CHAR:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   846
          SET_VMSLOTS_INT(arg_value.c, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   847
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   848
        case T_BYTE:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   849
          SET_VMSLOTS_INT(arg_value.b, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   850
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   851
        case T_SHORT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   852
          SET_VMSLOTS_INT(arg_value.s, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   853
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   854
        case T_INT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   855
          SET_VMSLOTS_INT(arg_value.i, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   856
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   857
        case T_FLOAT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   858
          SET_VMSLOTS_FLOAT(arg_value.f, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   859
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   860
        case T_LONG:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   861
          SET_VMSLOTS_LONG(arg_value.j, arg_slot + 1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   862
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   863
        case T_DOUBLE:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   864
          SET_VMSLOTS_DOUBLE(arg_value.d, arg_slot + 1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   865
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   866
        default:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   867
          tty->print_cr("unhandled type %s", type2name(arg_type));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   868
          ShouldNotReachHere();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   869
        }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   870
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   871
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   872
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   873
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   874
  case MethodHandles::_adapter_retype_only:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   875
  case MethodHandles::_adapter_retype_raw:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   876
    src_rtype = result_type_of_handle(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   877
      java_lang_invoke_MethodHandle::vmtarget(method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   878
    dst_rtype = result_type_of_handle(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   879
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   880
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   881
  case MethodHandles::_adapter_check_cast:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   882
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   883
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   884
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   885
      oop arg = VMSLOTS_OBJECT(arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   886
      if (arg != NULL) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   887
        klassOop objKlassOop = arg->klass();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   888
        klassOop klassOf = java_lang_Class::as_klassOop(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   889
          java_lang_invoke_AdapterMethodHandle::argument(method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   890
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   891
        if (objKlassOop != klassOf &&
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   892
            !objKlassOop->klass_part()->is_subtype_of(klassOf)) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   893
          ResourceMark rm(THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   894
          const char* objName = Klass::cast(objKlassOop)->external_name();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   895
          const char* klassName = Klass::cast(klassOf)->external_name();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   896
          char* message = SharedRuntime::generate_class_cast_message(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   897
            objName, klassName);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   898
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   899
          stack->set_sp(calculate_unwind_sp(stack, method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   900
          CALL_VM_NOCHECK_NOFIX(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   901
            throw_exception(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   902
              thread, vmSymbols::java_lang_ClassCastException(), message));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   903
          // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   904
          assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   905
          return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   906
        }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   907
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   908
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   909
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   910
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   911
  case MethodHandles::_adapter_dup_args:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   912
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   913
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   914
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   915
      int conv =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   916
        java_lang_invoke_AdapterMethodHandle::conversion(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   917
      int num_slots = -MethodHandles::adapter_conversion_stack_move(conv);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   918
      assert(num_slots > 0, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   919
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   920
      // Create the new slot(s)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   921
      intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   922
      stack->overflow_check(num_slots, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   923
      if (HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   924
        // all oops trashed
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   925
        stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   926
        return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   927
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   928
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   929
      // Duplicate the arguments
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   930
      for (int i = num_slots - 1; i >= 0; i--)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   931
        stack->push(*VMSLOTS_SLOT(arg_slot + i));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   932
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   933
      vmslots = stack->sp(); // unused, but let the compiler figure that out
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   934
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   935
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   936
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   937
  case MethodHandles::_adapter_drop_args:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   938
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   939
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   940
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   941
      int conv =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   942
        java_lang_invoke_AdapterMethodHandle::conversion(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   943
      int num_slots = MethodHandles::adapter_conversion_stack_move(conv);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   944
      assert(num_slots > 0, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   945
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   946
      remove_vmslots(arg_slot, num_slots, THREAD); // doesn't trap
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   947
      vmslots = stack->sp(); // unused, but let the compiler figure that out
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   948
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   949
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   950
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   951
  case MethodHandles::_adapter_opt_swap_1:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   952
  case MethodHandles::_adapter_opt_swap_2:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   953
  case MethodHandles::_adapter_opt_rot_1_up:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   954
  case MethodHandles::_adapter_opt_rot_1_down:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   955
  case MethodHandles::_adapter_opt_rot_2_up:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   956
  case MethodHandles::_adapter_opt_rot_2_down:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   957
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   958
      int arg1 =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   959
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   960
      int conv =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   961
        java_lang_invoke_AdapterMethodHandle::conversion(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   962
      int arg2 = MethodHandles::adapter_conversion_vminfo(conv);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   963
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   964
      int swap_bytes = 0, rotate = 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   965
      MethodHandles::get_ek_adapter_opt_swap_rot_info(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   966
        entry_kind, swap_bytes, rotate);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   967
      int swap_slots = swap_bytes >> LogBytesPerWord;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   968
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   969
      intptr_t tmp;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   970
      switch (rotate) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   971
      case 0: // swap
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   972
        for (int i = 0; i < swap_slots; i++) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   973
          tmp = *VMSLOTS_SLOT(arg1 + i);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   974
          SET_VMSLOTS_SLOT(VMSLOTS_SLOT(arg2 + i), arg1 + i);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   975
          SET_VMSLOTS_SLOT(&tmp, arg2 + i);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   976
        }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   977
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   978
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   979
      case 1: // up
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   980
        assert(arg1 - swap_slots > arg2, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   981
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   982
        tmp = *VMSLOTS_SLOT(arg1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   983
        for (int i = arg1 - swap_slots; i >= arg2; i--)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   984
          SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i + swap_slots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   985
        SET_VMSLOTS_SLOT(&tmp, arg2);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   986
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   987
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   988
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   989
      case -1: // down
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   990
        assert(arg2 - swap_slots > arg1, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   991
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   992
        tmp = *VMSLOTS_SLOT(arg1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   993
        for (int i = arg1 + swap_slots; i <= arg2; i++)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   994
          SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i - swap_slots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   995
        SET_VMSLOTS_SLOT(&tmp, arg2);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   996
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   997
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   998
      default:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   999
        ShouldNotReachHere();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1000
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1001
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1002
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1003
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1004
  case MethodHandles::_adapter_opt_i2l:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1005
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1006
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1007
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1008
      int arg = VMSLOTS_INT(arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1009
      intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1010
      insert_vmslots(arg_slot, 1, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1011
      if (HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1012
        // all oops trashed
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1013
        stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1014
        return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1015
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1016
      vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1017
      arg_slot++;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1018
      SET_VMSLOTS_LONG(arg, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1019
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1020
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1021
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1022
  case MethodHandles::_adapter_opt_unboxi:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1023
  case MethodHandles::_adapter_opt_unboxl:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1024
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1025
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1026
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1027
      oop arg = VMSLOTS_OBJECT(arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1028
      jvalue arg_value;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1029
      BasicType arg_type = java_lang_boxing_object::get_value(arg, &arg_value);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1030
      if (arg_type == T_LONG || arg_type == T_DOUBLE) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1031
        intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1032
        insert_vmslots(arg_slot, 1, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1033
        if (HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1034
          // all oops trashed
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1035
          stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1036
          return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1037
        }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1038
        vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1039
        arg_slot++;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1040
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1041
      switch (arg_type) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1042
      case T_BOOLEAN:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1043
        SET_VMSLOTS_INT(arg_value.z, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1044
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1045
      case T_CHAR:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1046
        SET_VMSLOTS_INT(arg_value.c, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1047
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1048
      case T_BYTE:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1049
        SET_VMSLOTS_INT(arg_value.b, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1050
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1051
      case T_SHORT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1052
        SET_VMSLOTS_INT(arg_value.s, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1053
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1054
      case T_INT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1055
        SET_VMSLOTS_INT(arg_value.i, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1056
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1057
      case T_FLOAT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1058
        SET_VMSLOTS_FLOAT(arg_value.f, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1059
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1060
      case T_LONG:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1061
        SET_VMSLOTS_LONG(arg_value.j, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1062
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1063
      case T_DOUBLE:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1064
        SET_VMSLOTS_DOUBLE(arg_value.d, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1065
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1066
      default:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1067
        tty->print_cr("unhandled type %s", type2name(arg_type));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1068
        ShouldNotReachHere();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1069
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1070
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1071
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1072
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1073
  default:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1074
    tty->print_cr("unhandled entry_kind %s",
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1075
                  MethodHandles::entry_name(entry_kind));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1076
    ShouldNotReachHere();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1077
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1078
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1079
  // Continue along the chain
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1080
  if (direct_to_method) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1081
    if (method == NULL) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1082
      method =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1083
        (methodOop) java_lang_invoke_MethodHandle::vmtarget(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1084
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1085
    address entry_point = method->from_interpreted_entry();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1086
    Interpreter::invoke_method(method, entry_point, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1087
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1088
  else {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1089
    process_method_handle(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1090
      java_lang_invoke_MethodHandle::vmtarget(method_handle), THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1091
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1092
  // NB all oops now trashed
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1093
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1094
  // Adapt the result type, if necessary
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1095
  if (src_rtype != dst_rtype && !HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1096
    switch (dst_rtype) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1097
    case T_VOID:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1098
      for (int i = 0; i < type2size[src_rtype]; i++)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1099
        stack->pop();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1100
      return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1101
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1102
    case T_INT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1103
      switch (src_rtype) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1104
      case T_VOID:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1105
        stack->overflow_check(1, CHECK);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1106
        stack->push(0);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1107
        return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1108
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1109
      case T_BOOLEAN:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1110
      case T_CHAR:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1111
      case T_BYTE:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1112
      case T_SHORT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1113
        return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1114
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1115
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1116
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1117
    tty->print_cr("unhandled conversion:");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1118
    tty->print_cr("src_rtype = %s", type2name(src_rtype));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1119
    tty->print_cr("dst_rtype = %s", type2name(dst_rtype));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1120
    ShouldNotReachHere();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1121
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1122
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1123
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1124
// The new slots will be inserted before slot insert_before.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1125
// Slots < insert_before will have the same slot number after the insert.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1126
// Slots >= insert_before will become old_slot + num_slots.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1127
void CppInterpreter::insert_vmslots(int insert_before, int num_slots, TRAPS) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1128
  JavaThread *thread = (JavaThread *) THREAD;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1129
  ZeroStack *stack = thread->zero_stack();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1130
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1131
  // Allocate the space
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1132
  stack->overflow_check(num_slots, CHECK);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1133
  stack->alloc(num_slots * wordSize);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1134
  intptr_t *vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1135
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1136
  // Shuffle everything up
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1137
  for (int i = 0; i < insert_before; i++)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1138
    SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i + num_slots), i);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1139
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1140
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1141
void CppInterpreter::remove_vmslots(int first_slot, int num_slots, TRAPS) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1142
  JavaThread *thread = (JavaThread *) THREAD;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1143
  ZeroStack *stack = thread->zero_stack();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1144
  intptr_t *vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1145
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1146
  // Move everything down
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1147
  for (int i = first_slot - 1; i >= 0; i--)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1148
    SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i + num_slots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1149
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1150
  // Deallocate the space
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1151
  stack->set_sp(stack->sp() + num_slots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1152
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1153
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1154
BasicType CppInterpreter::result_type_of_handle(oop method_handle) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1155
  oop method_type = java_lang_invoke_MethodHandle::type(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1156
  oop return_type = java_lang_invoke_MethodType::rtype(method_type);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1157
  return java_lang_Class::as_BasicType(return_type, (klassOop *) NULL);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1158
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1159
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1160
intptr_t* CppInterpreter::calculate_unwind_sp(ZeroStack* stack,
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1161
                                              oop method_handle) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1162
  oop method_type = java_lang_invoke_MethodHandle::type(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1163
  oop form = java_lang_invoke_MethodType::form(method_type);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1164
  int argument_slots = java_lang_invoke_MethodTypeForm::vmslots(form);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1165
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1166
  return stack->sp() + argument_slots;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1167
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1168
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1169
IRT_ENTRY(void, CppInterpreter::throw_exception(JavaThread* thread,
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1170
                                                Symbol*     name,
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1171
                                                char*       message))
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1172
  THROW_MSG(name, message);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1173
IRT_END
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1174
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1175
InterpreterFrame *InterpreterFrame::build(const methodOop method, TRAPS) {
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1176
  JavaThread *thread = (JavaThread *) THREAD;
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1177
  ZeroStack *stack = thread->zero_stack();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1178
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1179
  // Calculate the size of the frame we'll build, including
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1180
  // any adjustments to the caller's frame that we'll make.
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1181
  int extra_locals  = 0;
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1182
  int monitor_words = 0;
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1183
  int stack_words   = 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1184
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1185
  if (!method->is_native()) {
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1186
    extra_locals = method->max_locals() - method->size_of_parameters();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1187
    stack_words  = method->max_stack();
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1188
  }
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1189
  if (method->is_synchronized()) {
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1190
    monitor_words = frame::interpreter_frame_monitor_size();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1191
  }
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1192
  stack->overflow_check(
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1193
    extra_locals + header_words + monitor_words + stack_words, CHECK_NULL);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1194
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1195
  // Adjust the caller's stack frame to accomodate any additional
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1196
  // local variables we have contiguously with our parameters.
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1197
  for (int i = 0; i < extra_locals; i++)
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1198
    stack->push(0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1199
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1200
  intptr_t *locals;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1201
  if (method->is_native())
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1202
    locals = stack->sp() + (method->size_of_parameters() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1203
  else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1204
    locals = stack->sp() + (method->max_locals() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1205
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1206
  stack->push(0); // next_frame, filled in later
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1207
  intptr_t *fp = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1208
  assert(fp - stack->sp() == next_frame_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1209
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1210
  stack->push(INTERPRETER_FRAME);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1211
  assert(fp - stack->sp() == frame_type_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1212
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1213
  interpreterState istate =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1214
    (interpreterState) stack->alloc(sizeof(BytecodeInterpreter));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1215
  assert(fp - stack->sp() == istate_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1216
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1217
  istate->set_locals(locals);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1218
  istate->set_method(method);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1219
  istate->set_self_link(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1220
  istate->set_prev_link(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1221
  istate->set_thread(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1222
  istate->set_bcp(method->is_native() ? NULL : method->code_base());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1223
  istate->set_constants(method->constants()->cache());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1224
  istate->set_msg(BytecodeInterpreter::method_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1225
  istate->set_oop_temp(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1226
  istate->set_mdx(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1227
  istate->set_callee(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1228
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1229
  istate->set_monitor_base((BasicObjectLock *) stack->sp());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1230
  if (method->is_synchronized()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1231
    BasicObjectLock *monitor =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1232
      (BasicObjectLock *) stack->alloc(monitor_words * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1233
    oop object;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1234
    if (method->is_static())
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 7397
diff changeset
  1235
      object = method->constants()->pool_holder()->java_mirror();
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1236
    else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1237
      object = (oop) locals[0];
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1238
    monitor->set_obj(object);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1239
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1240
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1241
  istate->set_stack_base(stack->sp());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1242
  istate->set_stack(stack->sp() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1243
  if (stack_words)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1244
    stack->alloc(stack_words * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1245
  istate->set_stack_limit(stack->sp() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1246
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1247
  return (InterpreterFrame *) fp;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1248
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1249
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1250
int AbstractInterpreter::BasicType_as_index(BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1251
  int i = 0;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1252
  switch (type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1253
    case T_BOOLEAN: i = 0; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1254
    case T_CHAR   : i = 1; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1255
    case T_BYTE   : i = 2; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1256
    case T_SHORT  : i = 3; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1257
    case T_INT    : i = 4; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1258
    case T_LONG   : i = 5; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1259
    case T_VOID   : i = 6; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1260
    case T_FLOAT  : i = 7; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1261
    case T_DOUBLE : i = 8; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1262
    case T_OBJECT : i = 9; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1263
    case T_ARRAY  : i = 9; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1264
    default       : ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1265
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1266
  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1267
         "index out of bounds");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1268
  return i;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1269
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1270
4897
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1271
BasicType CppInterpreter::result_type_of(methodOop method) {
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1272
  BasicType t;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1273
  switch (method->result_index()) {
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1274
    case 0 : t = T_BOOLEAN; break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1275
    case 1 : t = T_CHAR;    break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1276
    case 2 : t = T_BYTE;    break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1277
    case 3 : t = T_SHORT;   break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1278
    case 4 : t = T_INT;     break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1279
    case 5 : t = T_LONG;    break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1280
    case 6 : t = T_VOID;    break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1281
    case 7 : t = T_FLOAT;   break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1282
    case 8 : t = T_DOUBLE;  break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1283
    case 9 : t = T_OBJECT;  break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1284
    default: ShouldNotReachHere();
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1285
  }
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1286
  assert(AbstractInterpreter::BasicType_as_index(t) == method->result_index(),
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1287
         "out of step with AbstractInterpreter::BasicType_as_index");
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1288
  return t;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1289
}
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1290
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1291
address InterpreterGenerator::generate_empty_entry() {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1292
  if (!UseFastEmptyMethods)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1293
    return NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1294
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1295
  return generate_entry((address) CppInterpreter::empty_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1296
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1297
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1298
address InterpreterGenerator::generate_accessor_entry() {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1299
  if (!UseFastAccessorMethods)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1300
    return NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1301
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1302
  return generate_entry((address) CppInterpreter::accessor_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1303
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1304
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1305
address InterpreterGenerator::generate_Reference_get_entry(void) {
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1306
#ifndef SERIALGC
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1307
  if (UseG1GC) {
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1308
    // We need to generate have a routine that generates code to:
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1309
    //   * load the value in the referent field
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1310
    //   * passes that value to the pre-barrier.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1311
    //
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1312
    // In the case of G1 this will record the value of the
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1313
    // referent in an SATB buffer if marking is active.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1314
    // This will cause concurrent marking to mark the referent
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1315
    // field as live.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1316
    Unimplemented();
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1317
  }
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1318
#endif // SERIALGC
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1319
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1320
  // If G1 is not enabled then attempt to go through the accessor entry point
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1321
  // Reference.get is an accessor
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1322
  return generate_accessor_entry();
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1323
}
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1324
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1325
address InterpreterGenerator::generate_native_entry(bool synchronized) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1326
  assert(synchronized == false, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1327
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1328
  return generate_entry((address) CppInterpreter::native_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1329
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1330
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1331
address InterpreterGenerator::generate_normal_entry(bool synchronized) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1332
  assert(synchronized == false, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1333
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1334
  return generate_entry((address) CppInterpreter::normal_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1335
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1336
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1337
address AbstractInterpreterGenerator::generate_method_entry(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1338
    AbstractInterpreter::MethodKind kind) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1339
  address entry_point = NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1340
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1341
  switch (kind) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1342
  case Interpreter::zerolocals:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1343
  case Interpreter::zerolocals_synchronized:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1344
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1345
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1346
  case Interpreter::native:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1347
    entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1348
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1349
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1350
  case Interpreter::native_synchronized:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1351
    entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1352
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1353
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1354
  case Interpreter::empty:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1355
    entry_point = ((InterpreterGenerator*) this)->generate_empty_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1356
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1357
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1358
  case Interpreter::accessor:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1359
    entry_point = ((InterpreterGenerator*) this)->generate_accessor_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1360
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1361
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1362
  case Interpreter::abstract:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1363
    entry_point = ((InterpreterGenerator*) this)->generate_abstract_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1364
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1365
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1366
  case Interpreter::method_handle:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1367
    entry_point = ((InterpreterGenerator*) this)->generate_method_handle_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1368
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1369
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1370
  case Interpreter::java_lang_math_sin:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1371
  case Interpreter::java_lang_math_cos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1372
  case Interpreter::java_lang_math_tan:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1373
  case Interpreter::java_lang_math_abs:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1374
  case Interpreter::java_lang_math_log:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1375
  case Interpreter::java_lang_math_log10:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1376
  case Interpreter::java_lang_math_sqrt:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1377
    entry_point = ((InterpreterGenerator*) this)->generate_math_entry(kind);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1378
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1379
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1380
  case Interpreter::java_lang_ref_reference_get:
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1381
    entry_point = ((InterpreterGenerator*)this)->generate_Reference_get_entry();
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1382
    break;
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1383
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1384
  default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1385
    ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1386
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1387
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1388
  if (entry_point == NULL)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1389
    entry_point = ((InterpreterGenerator*) this)->generate_normal_entry(false);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1390
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1391
  return entry_point;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1392
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1393
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1394
InterpreterGenerator::InterpreterGenerator(StubQueue* code)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1395
 : CppInterpreterGenerator(code) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1396
   generate_all();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1397
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1398
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1399
// Deoptimization helpers
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1400
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1401
InterpreterFrame *InterpreterFrame::build(int size, TRAPS) {
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1402
  ZeroStack *stack = ((JavaThread *) THREAD)->zero_stack();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1403
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1404
  int size_in_words = size >> LogBytesPerWord;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1405
  assert(size_in_words * wordSize == size, "unaligned");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1406
  assert(size_in_words >= header_words, "too small");
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1407
  stack->overflow_check(size_in_words, CHECK_NULL);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1408
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1409
  stack->push(0); // next_frame, filled in later
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1410
  intptr_t *fp = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1411
  assert(fp - stack->sp() == next_frame_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1412
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1413
  stack->push(INTERPRETER_FRAME);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1414
  assert(fp - stack->sp() == frame_type_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1415
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1416
  interpreterState istate =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1417
    (interpreterState) stack->alloc(sizeof(BytecodeInterpreter));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1418
  assert(fp - stack->sp() == istate_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1419
  istate->set_self_link(NULL); // mark invalid
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1420
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1421
  stack->alloc((size_in_words - header_words) * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1422
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1423
  return (InterpreterFrame *) fp;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1424
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1425
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1426
int AbstractInterpreter::layout_activation(methodOop method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1427
                                           int       tempcount,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1428
                                           int       popframe_extra_args,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1429
                                           int       moncount,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1430
                                           int       callee_param_count,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1431
                                           int       callee_locals,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1432
                                           frame*    caller,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1433
                                           frame*    interpreter_frame,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1434
                                           bool      is_top_frame) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1435
  assert(popframe_extra_args == 0, "what to do?");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1436
  assert(!is_top_frame || (!callee_locals && !callee_param_count),
5885
ee6d45117f3b 6960550: Missing semicolon in Zero
twisti
parents: 5547
diff changeset
  1437
         "top frame should have no caller");
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1438
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1439
  // This code must exactly match what InterpreterFrame::build
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1440
  // does (the full InterpreterFrame::build, that is, not the
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1441
  // one that creates empty frames for the deoptimizer).
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1442
  //
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1443
  // If interpreter_frame is not NULL then it will be filled in.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1444
  // It's size is determined by a previous call to this method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1445
  // so it should be correct.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1446
  //
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1447
  // Note that tempcount is the current size of the expression
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1448
  // stack.  For top most frames we will allocate a full sized
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1449
  // expression stack and not the trimmed version that non-top
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1450
  // frames have.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1451
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1452
  int header_words        = InterpreterFrame::header_words;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1453
  int monitor_words       = moncount * frame::interpreter_frame_monitor_size();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1454
  int stack_words         = is_top_frame ? method->max_stack() : tempcount;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1455
  int callee_extra_locals = callee_locals - callee_param_count;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1456
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1457
  if (interpreter_frame) {
5418
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5335
diff changeset
  1458
    intptr_t *locals        = interpreter_frame->fp() + method->max_locals();
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1459
    interpreterState istate = interpreter_frame->get_interpreterState();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1460
    intptr_t *monitor_base  = (intptr_t*) istate;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1461
    intptr_t *stack_base    = monitor_base - monitor_words;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1462
    intptr_t *stack         = stack_base - tempcount - 1;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1463
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1464
    BytecodeInterpreter::layout_interpreterState(istate,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1465
                                                 caller,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1466
                                                 NULL,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1467
                                                 method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1468
                                                 locals,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1469
                                                 stack,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1470
                                                 stack_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1471
                                                 monitor_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1472
                                                 NULL,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1473
                                                 is_top_frame);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1474
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1475
  return header_words + monitor_words + stack_words + callee_extra_locals;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1476
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1477
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1478
void BytecodeInterpreter::layout_interpreterState(interpreterState istate,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1479
                                                  frame*    caller,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1480
                                                  frame*    current,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1481
                                                  methodOop method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1482
                                                  intptr_t* locals,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1483
                                                  intptr_t* stack,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1484
                                                  intptr_t* stack_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1485
                                                  intptr_t* monitor_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1486
                                                  intptr_t* frame_bottom,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1487
                                                  bool      is_top_frame) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1488
  istate->set_locals(locals);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1489
  istate->set_method(method);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1490
  istate->set_self_link(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1491
  istate->set_prev_link(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1492
  // thread will be set by a hacky repurposing of frame::patch_pc()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1493
  // bcp will be set by vframeArrayElement::unpack_on_stack()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1494
  istate->set_constants(method->constants()->cache());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1495
  istate->set_msg(BytecodeInterpreter::method_resume);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1496
  istate->set_bcp_advance(0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1497
  istate->set_oop_temp(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1498
  istate->set_mdx(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1499
  if (caller->is_interpreted_frame()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1500
    interpreterState prev = caller->get_interpreterState();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1501
    prev->set_callee(method);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1502
    if (*prev->bcp() == Bytecodes::_invokeinterface)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1503
      prev->set_bcp_advance(5);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1504
    else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1505
      prev->set_bcp_advance(3);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1506
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1507
  istate->set_callee(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1508
  istate->set_monitor_base((BasicObjectLock *) monitor_base);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1509
  istate->set_stack_base(stack_base);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1510
  istate->set_stack(stack);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1511
  istate->set_stack_limit(stack_base - method->max_stack() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1512
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1513
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1514
address CppInterpreter::return_entry(TosState state, int length) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1515
  ShouldNotCallThis();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1516
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1517
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1518
address CppInterpreter::deopt_entry(TosState state, int length) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1519
  return NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1520
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1521
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1522
// Helper for (runtime) stack overflow checks
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1523
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1524
int AbstractInterpreter::size_top_interpreter_activation(methodOop method) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1525
  return 0;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1526
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1527
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1528
// Helper for figuring out if frames are interpreter frames
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1529
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1530
bool CppInterpreter::contains(address pc) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1531
#ifdef PRODUCT
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1532
  ShouldNotCallThis();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1533
#else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1534
  return false; // make frame::print_value_on work
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1535
#endif // !PRODUCT
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1536
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1537
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1538
// Result handlers and convertors
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1539
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1540
address CppInterpreterGenerator::generate_result_handler_for(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1541
    BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1542
  assembler()->advance(1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1543
  return ShouldNotCallThisStub();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1544
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1545
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1546
address CppInterpreterGenerator::generate_tosca_to_stack_converter(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1547
    BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1548
  assembler()->advance(1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1549
  return ShouldNotCallThisStub();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1550
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1551
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1552
address CppInterpreterGenerator::generate_stack_to_stack_converter(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1553
    BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1554
  assembler()->advance(1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1555
  return ShouldNotCallThisStub();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1556
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1557
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1558
address CppInterpreterGenerator::generate_stack_to_native_abi_converter(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1559
    BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1560
  assembler()->advance(1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1561
  return ShouldNotCallThisStub();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1562
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1563
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1564
#endif // CC_INTERP