hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
author twisti
Tue, 24 Jul 2012 10:51:00 -0700
changeset 13391 30245956af37
parent 12726 0a3b759f8109
child 13728 882756847a04
permissions -rw-r--r--
7023639: JSR 292 method handle invocation needs a fast path for compiled code 6984705: JSR 292 method handle creation should not go through JNI Summary: remove assembly code for JDK 7 chained method handles Reviewed-by: jrose, twisti, kvn, mhaupt Contributed-by: John Rose <john.r.rose@oracle.com>, Christian Thalinger <christian.thalinger@oracle.com>, Michael Haupt <michael.haupt@oracle.com>
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
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12726
diff changeset
   649
  int num_vmslots = argument_slots - 1;
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   650
  oop method_handle = VMSLOTS_OBJECT(num_vmslots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   651
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   652
  // InvokeGeneric requires some extra shuffling
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   653
  oop mhtype = java_lang_invoke_MethodHandle::type(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   654
  bool is_exact = mhtype == method_type;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   655
  if (!is_exact) {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12726
diff changeset
   656
    if (true || // FIXME
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12726
diff changeset
   657
        method->intrinsic_id() == vmIntrinsics::_invokeExact) {
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   658
      CALL_VM_NOCHECK_NOFIX(
10004
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 9636
diff changeset
   659
        SharedRuntime::throw_WrongMethodTypeException(
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   660
          thread, method_type, mhtype));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   661
      // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   662
      assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   663
      stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   664
      return 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   665
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   666
    assert(method->intrinsic_id() == vmIntrinsics::_invokeGeneric, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   667
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   668
    // Load up an adapter from the calling type
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   669
    // NB the x86 code for this (in methodHandles_x86.cpp, search for
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   670
    // "genericInvoker") is really really odd.  I'm hoping it's trying
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   671
    // to accomodate odd VM/class library combinations I can ignore.
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12726
diff changeset
   672
    oop adapter = NULL; //FIXME: load the adapter from the CP cache
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12726
diff changeset
   673
    IF (adapter == NULL) {
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   674
      CALL_VM_NOCHECK_NOFIX(
10004
190e88f7edd1 7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents: 9636
diff changeset
   675
        SharedRuntime::throw_WrongMethodTypeException(
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   676
          thread, method_type, mhtype));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   677
      // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   678
      assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   679
      stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   680
      return 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   681
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   682
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   683
    // Adapters are shared among form-families of method-type.  The
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   684
    // type being called is passed as a trusted first argument so that
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   685
    // the adapter knows the actual types of its arguments and return
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   686
    // values.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   687
    insert_vmslots(num_vmslots + 1, 1, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   688
    if (HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   689
      // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   690
      stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   691
      return 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   692
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   693
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   694
    vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   695
    num_vmslots++;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   696
    SET_VMSLOTS_OBJECT(method_type, num_vmslots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   697
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   698
    method_handle = adapter;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   699
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   700
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   701
  // Start processing
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   702
  process_method_handle(method_handle, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   703
  if (HAS_PENDING_EXCEPTION)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   704
    result_slots = 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   705
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   706
  // If this is an invokeExact then the eventual callee will not
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   707
  // have unwound the method handle argument so we have to do it.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   708
  // If a result is being returned the it will be above the method
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   709
  // handle argument we're unwinding.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   710
  if (is_exact) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   711
    intptr_t result[2];
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   712
    for (int i = 0; i < result_slots; i++)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   713
      result[i] = stack->pop();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   714
    stack->pop();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   715
    for (int i = result_slots - 1; i >= 0; i--)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   716
      stack->push(result[i]);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   717
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   718
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   719
  // Check
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   720
  assert(stack->sp() == unwind_sp - result_slots, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   721
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   722
  // No deoptimized frames on the stack
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   723
  return 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   724
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   725
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   726
void CppInterpreter::process_method_handle(oop method_handle, TRAPS) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   727
  JavaThread *thread = (JavaThread *) THREAD;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   728
  ZeroStack *stack = thread->zero_stack();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   729
  intptr_t *vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   730
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   731
  bool direct_to_method = false;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   732
  BasicType src_rtype = T_ILLEGAL;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   733
  BasicType dst_rtype = T_ILLEGAL;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   734
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   735
  MethodHandleEntry *entry =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   736
    java_lang_invoke_MethodHandle::vmentry(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   737
  MethodHandles::EntryKind entry_kind =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   738
    (MethodHandles::EntryKind) (((intptr_t) entry) & 0xffffffff);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   739
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   740
  methodOop method = NULL;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   741
  switch (entry_kind) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   742
  case MethodHandles::_invokestatic_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   743
    direct_to_method = true;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   744
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   745
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   746
  case MethodHandles::_invokespecial_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   747
  case MethodHandles::_invokevirtual_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   748
  case MethodHandles::_invokeinterface_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   749
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   750
      oop receiver =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   751
        VMSLOTS_OBJECT(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   752
          java_lang_invoke_MethodHandle::vmslots(method_handle) - 1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   753
      if (receiver == NULL) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   754
          stack->set_sp(calculate_unwind_sp(stack, method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   755
          CALL_VM_NOCHECK_NOFIX(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   756
            throw_exception(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   757
              thread, vmSymbols::java_lang_NullPointerException()));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   758
          // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   759
          assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   760
          return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   761
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   762
      if (entry_kind != MethodHandles::_invokespecial_mh) {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12726
diff changeset
   763
        intptr_t index = java_lang_invoke_DirectMethodHandle::vmindex(method_handle);
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   764
        instanceKlass* rcvrKlass =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   765
          (instanceKlass *) receiver->klass()->klass_part();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   766
        if (entry_kind == MethodHandles::_invokevirtual_mh) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   767
          method = (methodOop) rcvrKlass->start_of_vtable()[index];
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   768
        }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   769
        else {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   770
          oop iclass = java_lang_invoke_MethodHandle::vmtarget(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   771
          itableOffsetEntry* ki =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   772
            (itableOffsetEntry *) rcvrKlass->start_of_itable();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   773
          int i, length = rcvrKlass->itable_length();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   774
          for (i = 0; i < length; i++, ki++ ) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   775
            if (ki->interface_klass() == iclass)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   776
              break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   777
          }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   778
          if (i == length) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   779
            stack->set_sp(calculate_unwind_sp(stack, method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   780
            CALL_VM_NOCHECK_NOFIX(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   781
              throw_exception(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   782
                thread, vmSymbols::java_lang_IncompatibleClassChangeError()));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   783
            // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   784
            assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   785
            return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   786
          }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   787
          itableMethodEntry* im = ki->first_method_entry(receiver->klass());
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   788
          method = im[index].method();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   789
          if (method == NULL) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   790
            stack->set_sp(calculate_unwind_sp(stack, method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   791
            CALL_VM_NOCHECK_NOFIX(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   792
              throw_exception(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   793
                thread, vmSymbols::java_lang_AbstractMethodError()));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   794
            // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   795
            assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   796
            return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   797
          }
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
    direct_to_method = true;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   802
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   803
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   804
  case MethodHandles::_bound_ref_direct_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   805
  case MethodHandles::_bound_int_direct_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   806
  case MethodHandles::_bound_long_direct_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   807
    direct_to_method = true;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   808
    // fall through
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   809
  case MethodHandles::_bound_ref_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   810
  case MethodHandles::_bound_int_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   811
  case MethodHandles::_bound_long_mh:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   812
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   813
      BasicType arg_type  = T_ILLEGAL;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   814
      int       arg_mask  = -1;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   815
      int       arg_slots = -1;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   816
      MethodHandles::get_ek_bound_mh_info(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   817
        entry_kind, arg_type, arg_mask, arg_slots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   818
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   819
        java_lang_invoke_BoundMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   820
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   821
      // Create the new slot(s)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   822
      intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   823
      insert_vmslots(arg_slot, arg_slots, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   824
      if (HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   825
        // all oops trashed
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   826
        stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   827
        return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   828
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   829
      vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   830
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   831
      // Store bound argument into new stack slot
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   832
      oop arg = java_lang_invoke_BoundMethodHandle::argument(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   833
      if (arg_type == T_OBJECT) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   834
        assert(arg_slots == 1, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   835
        SET_VMSLOTS_OBJECT(arg, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   836
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   837
      else {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   838
        jvalue arg_value;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   839
        arg_type = java_lang_boxing_object::get_value(arg, &arg_value);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   840
        switch (arg_type) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   841
        case T_BOOLEAN:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   842
          SET_VMSLOTS_INT(arg_value.z, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   843
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   844
        case T_CHAR:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   845
          SET_VMSLOTS_INT(arg_value.c, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   846
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   847
        case T_BYTE:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   848
          SET_VMSLOTS_INT(arg_value.b, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   849
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   850
        case T_SHORT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   851
          SET_VMSLOTS_INT(arg_value.s, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   852
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   853
        case T_INT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   854
          SET_VMSLOTS_INT(arg_value.i, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   855
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   856
        case T_FLOAT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   857
          SET_VMSLOTS_FLOAT(arg_value.f, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   858
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   859
        case T_LONG:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   860
          SET_VMSLOTS_LONG(arg_value.j, arg_slot + 1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   861
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   862
        case T_DOUBLE:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   863
          SET_VMSLOTS_DOUBLE(arg_value.d, arg_slot + 1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   864
          break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   865
        default:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   866
          tty->print_cr("unhandled type %s", type2name(arg_type));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   867
          ShouldNotReachHere();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   868
        }
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
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   872
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   873
  case MethodHandles::_adapter_retype_only:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   874
  case MethodHandles::_adapter_retype_raw:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   875
    src_rtype = result_type_of_handle(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   876
      java_lang_invoke_MethodHandle::vmtarget(method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   877
    dst_rtype = result_type_of_handle(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   878
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   879
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   880
  case MethodHandles::_adapter_check_cast:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   881
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   882
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   883
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   884
      oop arg = VMSLOTS_OBJECT(arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   885
      if (arg != NULL) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   886
        klassOop objKlassOop = arg->klass();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   887
        klassOop klassOf = java_lang_Class::as_klassOop(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   888
          java_lang_invoke_AdapterMethodHandle::argument(method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   889
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   890
        if (objKlassOop != klassOf &&
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   891
            !objKlassOop->klass_part()->is_subtype_of(klassOf)) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   892
          ResourceMark rm(THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   893
          const char* objName = Klass::cast(objKlassOop)->external_name();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   894
          const char* klassName = Klass::cast(klassOf)->external_name();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   895
          char* message = SharedRuntime::generate_class_cast_message(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   896
            objName, klassName);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   897
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   898
          stack->set_sp(calculate_unwind_sp(stack, method_handle));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   899
          CALL_VM_NOCHECK_NOFIX(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   900
            throw_exception(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   901
              thread, vmSymbols::java_lang_ClassCastException(), message));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   902
          // NB all oops trashed!
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   903
          assert(HAS_PENDING_EXCEPTION, "should do");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   904
          return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   905
        }
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
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   909
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   910
  case MethodHandles::_adapter_dup_args:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   911
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   912
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   913
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   914
      int conv =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   915
        java_lang_invoke_AdapterMethodHandle::conversion(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   916
      int num_slots = -MethodHandles::adapter_conversion_stack_move(conv);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   917
      assert(num_slots > 0, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   918
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   919
      // Create the new slot(s)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   920
      intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   921
      stack->overflow_check(num_slots, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   922
      if (HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   923
        // all oops trashed
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   924
        stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   925
        return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   926
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   927
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   928
      // Duplicate the arguments
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   929
      for (int i = num_slots - 1; i >= 0; i--)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   930
        stack->push(*VMSLOTS_SLOT(arg_slot + i));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   931
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   932
      vmslots = stack->sp(); // unused, but let the compiler figure that out
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   933
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   934
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   935
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   936
  case MethodHandles::_adapter_drop_args:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   937
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   938
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   939
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   940
      int conv =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   941
        java_lang_invoke_AdapterMethodHandle::conversion(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   942
      int num_slots = MethodHandles::adapter_conversion_stack_move(conv);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   943
      assert(num_slots > 0, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   944
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   945
      remove_vmslots(arg_slot, num_slots, THREAD); // doesn't trap
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   946
      vmslots = stack->sp(); // unused, but let the compiler figure that out
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   947
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   948
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   949
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   950
  case MethodHandles::_adapter_opt_swap_1:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   951
  case MethodHandles::_adapter_opt_swap_2:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   952
  case MethodHandles::_adapter_opt_rot_1_up:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   953
  case MethodHandles::_adapter_opt_rot_1_down:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   954
  case MethodHandles::_adapter_opt_rot_2_up:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   955
  case MethodHandles::_adapter_opt_rot_2_down:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   956
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   957
      int arg1 =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   958
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   959
      int conv =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   960
        java_lang_invoke_AdapterMethodHandle::conversion(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   961
      int arg2 = MethodHandles::adapter_conversion_vminfo(conv);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   962
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   963
      int swap_bytes = 0, rotate = 0;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   964
      MethodHandles::get_ek_adapter_opt_swap_rot_info(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   965
        entry_kind, swap_bytes, rotate);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   966
      int swap_slots = swap_bytes >> LogBytesPerWord;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   967
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   968
      intptr_t tmp;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   969
      switch (rotate) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   970
      case 0: // swap
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   971
        for (int i = 0; i < swap_slots; i++) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   972
          tmp = *VMSLOTS_SLOT(arg1 + i);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   973
          SET_VMSLOTS_SLOT(VMSLOTS_SLOT(arg2 + i), arg1 + i);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   974
          SET_VMSLOTS_SLOT(&tmp, arg2 + i);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   975
        }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   976
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   977
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   978
      case 1: // up
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   979
        assert(arg1 - swap_slots > arg2, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   980
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   981
        tmp = *VMSLOTS_SLOT(arg1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   982
        for (int i = arg1 - swap_slots; i >= arg2; i--)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   983
          SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i + swap_slots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   984
        SET_VMSLOTS_SLOT(&tmp, arg2);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   985
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   986
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   987
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   988
      case -1: // down
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   989
        assert(arg2 - swap_slots > arg1, "should be");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   990
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   991
        tmp = *VMSLOTS_SLOT(arg1);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   992
        for (int i = arg1 + swap_slots; i <= arg2; i++)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   993
          SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i - swap_slots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   994
        SET_VMSLOTS_SLOT(&tmp, arg2);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   995
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   996
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   997
      default:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   998
        ShouldNotReachHere();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   999
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1000
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1001
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1002
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1003
  case MethodHandles::_adapter_opt_i2l:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1004
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1005
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1006
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1007
      int arg = VMSLOTS_INT(arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1008
      intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1009
      insert_vmslots(arg_slot, 1, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1010
      if (HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1011
        // all oops trashed
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1012
        stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1013
        return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1014
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1015
      vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1016
      arg_slot++;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1017
      SET_VMSLOTS_LONG(arg, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1018
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1019
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1020
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1021
  case MethodHandles::_adapter_opt_unboxi:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1022
  case MethodHandles::_adapter_opt_unboxl:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1023
    {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1024
      int arg_slot =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1025
        java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1026
      oop arg = VMSLOTS_OBJECT(arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1027
      jvalue arg_value;
12726
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1028
      if (arg == NULL) {
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1029
        // queue a nullpointer exception for the caller
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1030
        stack->set_sp(calculate_unwind_sp(stack, method_handle));
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1031
        CALL_VM_NOCHECK_NOFIX(
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1032
          throw_exception(
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1033
            thread, vmSymbols::java_lang_NullPointerException()));
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1034
        // NB all oops trashed!
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1035
        assert(HAS_PENDING_EXCEPTION, "should do");
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1036
        return;
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1037
      }
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1038
      BasicType arg_type = java_lang_boxing_object::get_value(arg, &arg_value);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1039
      if (arg_type == T_LONG || arg_type == T_DOUBLE) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1040
        intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1041
        insert_vmslots(arg_slot, 1, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1042
        if (HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1043
          // all oops trashed
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1044
          stack->set_sp(unwind_sp);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1045
          return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1046
        }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1047
        vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1048
        arg_slot++;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1049
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1050
      switch (arg_type) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1051
      case T_BOOLEAN:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1052
        SET_VMSLOTS_INT(arg_value.z, 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_CHAR:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1055
        SET_VMSLOTS_INT(arg_value.c, 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_BYTE:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1058
        SET_VMSLOTS_INT(arg_value.b, 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_SHORT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1061
        SET_VMSLOTS_INT(arg_value.s, 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_INT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1064
        SET_VMSLOTS_INT(arg_value.i, 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
      case T_FLOAT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1067
        SET_VMSLOTS_FLOAT(arg_value.f, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1068
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1069
      case T_LONG:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1070
        SET_VMSLOTS_LONG(arg_value.j, arg_slot);
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
      case T_DOUBLE:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1073
        SET_VMSLOTS_DOUBLE(arg_value.d, arg_slot);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1074
        break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1075
      default:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1076
        tty->print_cr("unhandled type %s", type2name(arg_type));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1077
        ShouldNotReachHere();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1078
      }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1079
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1080
    break;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1081
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1082
  default:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1083
    tty->print_cr("unhandled entry_kind %s",
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1084
                  MethodHandles::entry_name(entry_kind));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1085
    ShouldNotReachHere();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1086
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1087
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1088
  // Continue along the chain
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1089
  if (direct_to_method) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1090
    if (method == NULL) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1091
      method =
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1092
        (methodOop) java_lang_invoke_MethodHandle::vmtarget(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1093
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1094
    address entry_point = method->from_interpreted_entry();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1095
    Interpreter::invoke_method(method, entry_point, THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1096
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1097
  else {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1098
    process_method_handle(
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1099
      java_lang_invoke_MethodHandle::vmtarget(method_handle), THREAD);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1100
  }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1101
  // NB all oops now trashed
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1102
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1103
  // Adapt the result type, if necessary
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1104
  if (src_rtype != dst_rtype && !HAS_PENDING_EXCEPTION) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1105
    switch (dst_rtype) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1106
    case T_VOID:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1107
      for (int i = 0; i < type2size[src_rtype]; i++)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1108
        stack->pop();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1109
      return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1110
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1111
    case T_INT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1112
      switch (src_rtype) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1113
      case T_VOID:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1114
        stack->overflow_check(1, CHECK);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1115
        stack->push(0);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1116
        return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1117
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1118
      case T_BOOLEAN:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1119
      case T_CHAR:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1120
      case T_BYTE:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1121
      case T_SHORT:
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1122
        return;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1123
      }
12726
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1124
      // INT results sometimes need narrowing
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1125
    case T_BOOLEAN:
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1126
    case T_CHAR:
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1127
    case T_BYTE:
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1128
    case T_SHORT:
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1129
      switch (src_rtype) {
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1130
      case T_INT:
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1131
        return;
0a3b759f8109 7167406: (Zero) Fix for InvokeDynamic needed
dholmes
parents: 10004
diff changeset
  1132
      }
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1133
    }
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1134
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1135
    tty->print_cr("unhandled conversion:");
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1136
    tty->print_cr("src_rtype = %s", type2name(src_rtype));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1137
    tty->print_cr("dst_rtype = %s", type2name(dst_rtype));
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1138
    ShouldNotReachHere();
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
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1142
// The new slots will be inserted before slot insert_before.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1143
// Slots < insert_before will have the same slot number after the insert.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1144
// Slots >= insert_before will become old_slot + num_slots.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1145
void CppInterpreter::insert_vmslots(int insert_before, int num_slots, TRAPS) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1146
  JavaThread *thread = (JavaThread *) THREAD;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1147
  ZeroStack *stack = thread->zero_stack();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1148
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1149
  // Allocate the space
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1150
  stack->overflow_check(num_slots, CHECK);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1151
  stack->alloc(num_slots * wordSize);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1152
  intptr_t *vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1153
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1154
  // Shuffle everything up
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1155
  for (int i = 0; i < insert_before; i++)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1156
    SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i + num_slots), i);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1157
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1158
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1159
void CppInterpreter::remove_vmslots(int first_slot, int num_slots, TRAPS) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1160
  JavaThread *thread = (JavaThread *) THREAD;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1161
  ZeroStack *stack = thread->zero_stack();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1162
  intptr_t *vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1163
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1164
  // Move everything down
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1165
  for (int i = first_slot - 1; i >= 0; i--)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1166
    SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i + num_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
  // Deallocate the space
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1169
  stack->set_sp(stack->sp() + num_slots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1170
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1171
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1172
BasicType CppInterpreter::result_type_of_handle(oop method_handle) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1173
  oop method_type = java_lang_invoke_MethodHandle::type(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1174
  oop return_type = java_lang_invoke_MethodType::rtype(method_type);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1175
  return java_lang_Class::as_BasicType(return_type, (klassOop *) NULL);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1176
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1177
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1178
intptr_t* CppInterpreter::calculate_unwind_sp(ZeroStack* stack,
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1179
                                              oop method_handle) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1180
  oop method_type = java_lang_invoke_MethodHandle::type(method_handle);
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12726
diff changeset
  1181
  int argument_slots = java_lang_invoke_MethodType::ptype_slot_count(method_type);
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1182
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1183
  return stack->sp() + argument_slots;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1184
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1185
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1186
IRT_ENTRY(void, CppInterpreter::throw_exception(JavaThread* thread,
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1187
                                                Symbol*     name,
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1188
                                                char*       message))
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1189
  THROW_MSG(name, message);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1190
IRT_END
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
  1191
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1192
InterpreterFrame *InterpreterFrame::build(const methodOop method, TRAPS) {
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1193
  JavaThread *thread = (JavaThread *) THREAD;
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1194
  ZeroStack *stack = thread->zero_stack();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1195
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1196
  // Calculate the size of the frame we'll build, including
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1197
  // any adjustments to the caller's frame that we'll make.
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1198
  int extra_locals  = 0;
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1199
  int monitor_words = 0;
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1200
  int stack_words   = 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1201
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1202
  if (!method->is_native()) {
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1203
    extra_locals = method->max_locals() - method->size_of_parameters();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1204
    stack_words  = method->max_stack();
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1205
  }
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1206
  if (method->is_synchronized()) {
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1207
    monitor_words = frame::interpreter_frame_monitor_size();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1208
  }
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1209
  stack->overflow_check(
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1210
    extra_locals + header_words + monitor_words + stack_words, CHECK_NULL);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1211
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1212
  // Adjust the caller's stack frame to accomodate any additional
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1213
  // local variables we have contiguously with our parameters.
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1214
  for (int i = 0; i < extra_locals; i++)
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1215
    stack->push(0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1216
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1217
  intptr_t *locals;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1218
  if (method->is_native())
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1219
    locals = stack->sp() + (method->size_of_parameters() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1220
  else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1221
    locals = stack->sp() + (method->max_locals() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1222
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1223
  stack->push(0); // next_frame, filled in later
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1224
  intptr_t *fp = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1225
  assert(fp - stack->sp() == next_frame_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1226
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1227
  stack->push(INTERPRETER_FRAME);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1228
  assert(fp - stack->sp() == frame_type_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1229
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1230
  interpreterState istate =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1231
    (interpreterState) stack->alloc(sizeof(BytecodeInterpreter));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1232
  assert(fp - stack->sp() == istate_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1233
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1234
  istate->set_locals(locals);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1235
  istate->set_method(method);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1236
  istate->set_self_link(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1237
  istate->set_prev_link(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1238
  istate->set_thread(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1239
  istate->set_bcp(method->is_native() ? NULL : method->code_base());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1240
  istate->set_constants(method->constants()->cache());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1241
  istate->set_msg(BytecodeInterpreter::method_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1242
  istate->set_oop_temp(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1243
  istate->set_mdx(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1244
  istate->set_callee(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1245
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1246
  istate->set_monitor_base((BasicObjectLock *) stack->sp());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1247
  if (method->is_synchronized()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1248
    BasicObjectLock *monitor =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1249
      (BasicObjectLock *) stack->alloc(monitor_words * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1250
    oop object;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1251
    if (method->is_static())
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 7397
diff changeset
  1252
      object = method->constants()->pool_holder()->java_mirror();
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1253
    else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1254
      object = (oop) locals[0];
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1255
    monitor->set_obj(object);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1256
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1257
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1258
  istate->set_stack_base(stack->sp());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1259
  istate->set_stack(stack->sp() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1260
  if (stack_words)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1261
    stack->alloc(stack_words * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1262
  istate->set_stack_limit(stack->sp() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1263
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1264
  return (InterpreterFrame *) fp;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1265
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1266
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1267
int AbstractInterpreter::BasicType_as_index(BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1268
  int i = 0;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1269
  switch (type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1270
    case T_BOOLEAN: i = 0; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1271
    case T_CHAR   : i = 1; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1272
    case T_BYTE   : i = 2; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1273
    case T_SHORT  : i = 3; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1274
    case T_INT    : i = 4; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1275
    case T_LONG   : i = 5; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1276
    case T_VOID   : i = 6; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1277
    case T_FLOAT  : i = 7; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1278
    case T_DOUBLE : i = 8; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1279
    case T_OBJECT : i = 9; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1280
    case T_ARRAY  : i = 9; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1281
    default       : ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1282
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1283
  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1284
         "index out of bounds");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1285
  return i;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1286
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1287
4897
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1288
BasicType CppInterpreter::result_type_of(methodOop method) {
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1289
  BasicType t;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1290
  switch (method->result_index()) {
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1291
    case 0 : t = T_BOOLEAN; break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1292
    case 1 : t = T_CHAR;    break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1293
    case 2 : t = T_BYTE;    break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1294
    case 3 : t = T_SHORT;   break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1295
    case 4 : t = T_INT;     break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1296
    case 5 : t = T_LONG;    break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1297
    case 6 : t = T_VOID;    break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1298
    case 7 : t = T_FLOAT;   break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1299
    case 8 : t = T_DOUBLE;  break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1300
    case 9 : t = T_OBJECT;  break;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1301
    default: ShouldNotReachHere();
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1302
  }
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1303
  assert(AbstractInterpreter::BasicType_as_index(t) == method->result_index(),
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1304
         "out of step with AbstractInterpreter::BasicType_as_index");
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1305
  return t;
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1306
}
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
  1307
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1308
address InterpreterGenerator::generate_empty_entry() {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1309
  if (!UseFastEmptyMethods)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1310
    return NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1311
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1312
  return generate_entry((address) CppInterpreter::empty_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1313
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1314
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1315
address InterpreterGenerator::generate_accessor_entry() {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1316
  if (!UseFastAccessorMethods)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1317
    return NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1318
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1319
  return generate_entry((address) CppInterpreter::accessor_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1320
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1321
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1322
address InterpreterGenerator::generate_Reference_get_entry(void) {
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1323
#ifndef SERIALGC
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1324
  if (UseG1GC) {
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1325
    // 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
  1326
    //   * load the value in the referent field
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1327
    //   * passes that value to the pre-barrier.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1328
    //
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1329
    // 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
  1330
    // 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
  1331
    // 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
  1332
    // field as live.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1333
    Unimplemented();
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1334
  }
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1335
#endif // SERIALGC
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1336
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1337
  // 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
  1338
  // Reference.get is an accessor
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1339
  return generate_accessor_entry();
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1340
}
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1341
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1342
address InterpreterGenerator::generate_native_entry(bool synchronized) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1343
  assert(synchronized == false, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1344
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1345
  return generate_entry((address) CppInterpreter::native_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1346
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1347
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1348
address InterpreterGenerator::generate_normal_entry(bool synchronized) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1349
  assert(synchronized == false, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1350
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1351
  return generate_entry((address) CppInterpreter::normal_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1352
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1353
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1354
address AbstractInterpreterGenerator::generate_method_entry(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1355
    AbstractInterpreter::MethodKind kind) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1356
  address entry_point = NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1357
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1358
  switch (kind) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1359
  case Interpreter::zerolocals:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1360
  case Interpreter::zerolocals_synchronized:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1361
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1362
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1363
  case Interpreter::native:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1364
    entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1365
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1366
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1367
  case Interpreter::native_synchronized:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1368
    entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1369
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1370
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1371
  case Interpreter::empty:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1372
    entry_point = ((InterpreterGenerator*) this)->generate_empty_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1373
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1374
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1375
  case Interpreter::accessor:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1376
    entry_point = ((InterpreterGenerator*) this)->generate_accessor_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1377
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1378
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1379
  case Interpreter::abstract:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1380
    entry_point = ((InterpreterGenerator*) this)->generate_abstract_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1381
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1382
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1383
  case Interpreter::method_handle:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1384
    entry_point = ((InterpreterGenerator*) this)->generate_method_handle_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1385
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1386
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1387
  case Interpreter::java_lang_math_sin:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1388
  case Interpreter::java_lang_math_cos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1389
  case Interpreter::java_lang_math_tan:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1390
  case Interpreter::java_lang_math_abs:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1391
  case Interpreter::java_lang_math_log:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1392
  case Interpreter::java_lang_math_log10:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1393
  case Interpreter::java_lang_math_sqrt:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1394
    entry_point = ((InterpreterGenerator*) this)->generate_math_entry(kind);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1395
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1396
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1397
  case Interpreter::java_lang_ref_reference_get:
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1398
    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
  1399
    break;
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8725
diff changeset
  1400
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1401
  default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1402
    ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1403
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1404
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1405
  if (entry_point == NULL)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1406
    entry_point = ((InterpreterGenerator*) this)->generate_normal_entry(false);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1407
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1408
  return entry_point;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1409
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1410
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1411
InterpreterGenerator::InterpreterGenerator(StubQueue* code)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1412
 : CppInterpreterGenerator(code) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1413
   generate_all();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1414
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1415
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1416
// Deoptimization helpers
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1417
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1418
InterpreterFrame *InterpreterFrame::build(int size, TRAPS) {
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1419
  ZeroStack *stack = ((JavaThread *) THREAD)->zero_stack();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1420
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1421
  int size_in_words = size >> LogBytesPerWord;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1422
  assert(size_in_words * wordSize == size, "unaligned");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1423
  assert(size_in_words >= header_words, "too small");
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
  1424
  stack->overflow_check(size_in_words, CHECK_NULL);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1425
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1426
  stack->push(0); // next_frame, filled in later
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1427
  intptr_t *fp = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1428
  assert(fp - stack->sp() == next_frame_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1429
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1430
  stack->push(INTERPRETER_FRAME);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1431
  assert(fp - stack->sp() == frame_type_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1432
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1433
  interpreterState istate =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1434
    (interpreterState) stack->alloc(sizeof(BytecodeInterpreter));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1435
  assert(fp - stack->sp() == istate_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1436
  istate->set_self_link(NULL); // mark invalid
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1437
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1438
  stack->alloc((size_in_words - header_words) * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1439
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1440
  return (InterpreterFrame *) fp;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1441
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1442
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1443
int AbstractInterpreter::layout_activation(methodOop method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1444
                                           int       tempcount,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1445
                                           int       popframe_extra_args,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1446
                                           int       moncount,
9636
363ca5579aff 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 9187
diff changeset
  1447
                                           int       caller_actual_parameters,
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1448
                                           int       callee_param_count,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1449
                                           int       callee_locals,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1450
                                           frame*    caller,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1451
                                           frame*    interpreter_frame,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1452
                                           bool      is_top_frame) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1453
  assert(popframe_extra_args == 0, "what to do?");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1454
  assert(!is_top_frame || (!callee_locals && !callee_param_count),
5885
ee6d45117f3b 6960550: Missing semicolon in Zero
twisti
parents: 5547
diff changeset
  1455
         "top frame should have no caller");
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1456
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1457
  // This code must exactly match what InterpreterFrame::build
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1458
  // does (the full InterpreterFrame::build, that is, not the
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1459
  // one that creates empty frames for the deoptimizer).
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1460
  //
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1461
  // If interpreter_frame is not NULL then it will be filled in.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1462
  // It's size is determined by a previous call to this method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1463
  // so it should be correct.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1464
  //
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1465
  // Note that tempcount is the current size of the expression
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1466
  // stack.  For top most frames we will allocate a full sized
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1467
  // expression stack and not the trimmed version that non-top
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1468
  // frames have.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1469
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1470
  int header_words        = InterpreterFrame::header_words;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1471
  int monitor_words       = moncount * frame::interpreter_frame_monitor_size();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1472
  int stack_words         = is_top_frame ? method->max_stack() : tempcount;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1473
  int callee_extra_locals = callee_locals - callee_param_count;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1474
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1475
  if (interpreter_frame) {
5418
c4955cb6ed33 6939182: Zero JNI handles fix
twisti
parents: 5335
diff changeset
  1476
    intptr_t *locals        = interpreter_frame->fp() + method->max_locals();
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1477
    interpreterState istate = interpreter_frame->get_interpreterState();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1478
    intptr_t *monitor_base  = (intptr_t*) istate;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1479
    intptr_t *stack_base    = monitor_base - monitor_words;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1480
    intptr_t *stack         = stack_base - tempcount - 1;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1481
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1482
    BytecodeInterpreter::layout_interpreterState(istate,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1483
                                                 caller,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1484
                                                 NULL,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1485
                                                 method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1486
                                                 locals,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1487
                                                 stack,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1488
                                                 stack_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1489
                                                 monitor_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1490
                                                 NULL,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1491
                                                 is_top_frame);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1492
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1493
  return header_words + monitor_words + stack_words + callee_extra_locals;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1494
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1495
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1496
void BytecodeInterpreter::layout_interpreterState(interpreterState istate,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1497
                                                  frame*    caller,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1498
                                                  frame*    current,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1499
                                                  methodOop method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1500
                                                  intptr_t* locals,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1501
                                                  intptr_t* stack,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1502
                                                  intptr_t* stack_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1503
                                                  intptr_t* monitor_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1504
                                                  intptr_t* frame_bottom,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1505
                                                  bool      is_top_frame) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1506
  istate->set_locals(locals);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1507
  istate->set_method(method);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1508
  istate->set_self_link(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1509
  istate->set_prev_link(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1510
  // thread will be set by a hacky repurposing of frame::patch_pc()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1511
  // bcp will be set by vframeArrayElement::unpack_on_stack()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1512
  istate->set_constants(method->constants()->cache());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1513
  istate->set_msg(BytecodeInterpreter::method_resume);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1514
  istate->set_bcp_advance(0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1515
  istate->set_oop_temp(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1516
  istate->set_mdx(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1517
  if (caller->is_interpreted_frame()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1518
    interpreterState prev = caller->get_interpreterState();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1519
    prev->set_callee(method);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1520
    if (*prev->bcp() == Bytecodes::_invokeinterface)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1521
      prev->set_bcp_advance(5);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1522
    else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1523
      prev->set_bcp_advance(3);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1524
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1525
  istate->set_callee(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1526
  istate->set_monitor_base((BasicObjectLock *) monitor_base);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1527
  istate->set_stack_base(stack_base);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1528
  istate->set_stack(stack);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1529
  istate->set_stack_limit(stack_base - method->max_stack() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1530
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1531
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1532
address CppInterpreter::return_entry(TosState state, int length) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1533
  ShouldNotCallThis();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1534
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1535
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1536
address CppInterpreter::deopt_entry(TosState state, int length) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1537
  return NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1538
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1539
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1540
// Helper for (runtime) stack overflow checks
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1541
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1542
int AbstractInterpreter::size_top_interpreter_activation(methodOop method) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1543
  return 0;
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
// Helper for figuring out if frames are interpreter frames
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1547
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1548
bool CppInterpreter::contains(address pc) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1549
#ifdef PRODUCT
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1550
  ShouldNotCallThis();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1551
#else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1552
  return false; // make frame::print_value_on work
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1553
#endif // !PRODUCT
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1554
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1555
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1556
// Result handlers and convertors
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_result_handler_for(
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
address CppInterpreterGenerator::generate_tosca_to_stack_converter(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1565
    BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1566
  assembler()->advance(1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1567
  return ShouldNotCallThisStub();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1568
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1569
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1570
address CppInterpreterGenerator::generate_stack_to_stack_converter(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1571
    BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1572
  assembler()->advance(1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1573
  return ShouldNotCallThisStub();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1574
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1575
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1576
address CppInterpreterGenerator::generate_stack_to_native_abi_converter(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1577
    BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1578
  assembler()->advance(1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1579
  return ShouldNotCallThisStub();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1580
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1581
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
  1582
#endif // CC_INTERP