hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
author never
Tue, 13 Oct 2009 12:04:21 -0700
changeset 4013 b154310845de
child 4448 d6ec2737186c
permissions -rw-r--r--
6890308: integrate zero assembler hotspot changes Reviewed-by: never Contributed-by: gbenson@redhat.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
     1
/*
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
     2
 * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
     3
 * Copyright 2007, 2008, 2009 Red Hat, Inc.
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
 *
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    20
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    21
 * CA 95054 USA or visit www.sun.com if you need additional information or
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    22
 * have any questions.
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
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    26
#include "incls/_precompiled.incl"
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    27
#include "incls/_cppInterpreter_zero.cpp.incl"
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    28
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    29
#ifdef CC_INTERP
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    30
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    31
#define fixup_after_potential_safepoint()       \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    32
  method = istate->method()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    33
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    34
#define CALL_VM_NOCHECK(func)                   \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    35
  thread->set_last_Java_frame();                \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    36
  func;                                         \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    37
  thread->reset_last_Java_frame();              \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    38
  fixup_after_potential_safepoint()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    39
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    40
void CppInterpreter::normal_entry(methodOop method, intptr_t UNUSED, TRAPS) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    41
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    42
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    43
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    44
  // Adjust the caller's stack frame to accomodate any additional
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    45
  // local variables we have contiguously with our parameters.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    46
  int extra_locals = method->max_locals() - method->size_of_parameters();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    47
  if (extra_locals > 0) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    48
    if (extra_locals > stack->available_words()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    49
      Unimplemented();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    50
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    51
    for (int i = 0; i < extra_locals; i++)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    52
      stack->push(0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    53
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    54
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    55
  // Allocate and initialize our frame.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    56
  InterpreterFrame *frame = InterpreterFrame::build(stack, method, thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    57
  thread->push_zero_frame(frame);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    58
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    59
  // Execute those bytecodes!
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    60
  main_loop(0, THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    61
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    62
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    63
void CppInterpreter::main_loop(int recurse, TRAPS) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    64
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    65
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    66
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    67
  // If we are entering from a deopt we may need to call
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    68
  // ourself a few times in order to get to our frame.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    69
  if (recurse)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    70
    main_loop(recurse - 1, THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    71
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    72
  InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    73
  interpreterState istate = frame->interpreter_state();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    74
  methodOop method = istate->method();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    75
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    76
  intptr_t *result = NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    77
  int result_slots = 0;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    78
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    79
  // Check we're not about to run out of stack
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    80
  if (stack_overflow_imminent(thread)) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    81
    CALL_VM_NOCHECK(InterpreterRuntime::throw_StackOverflowError(thread));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    82
    goto unwind_and_return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    83
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    84
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    85
  while (true) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    86
    // We can set up the frame anchor with everything we want at
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    87
    // this point as we are thread_in_Java and no safepoints can
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    88
    // occur until we go to vm mode.  We do have to clear flags
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    89
    // on return from vm but that is it.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    90
    thread->set_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    91
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    92
    // Call the interpreter
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    93
    if (JvmtiExport::can_post_interpreter_events())
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    94
      BytecodeInterpreter::runWithChecks(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    95
    else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    96
      BytecodeInterpreter::run(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    97
    fixup_after_potential_safepoint();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    98
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    99
    // Clear the frame anchor
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   100
    thread->reset_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   101
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   102
    // Examine the message from the interpreter to decide what to do
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   103
    if (istate->msg() == BytecodeInterpreter::call_method) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   104
      methodOop callee = istate->callee();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   105
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   106
      // Trim back the stack to put the parameters at the top
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   107
      stack->set_sp(istate->stack() + 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   108
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   109
      // Make the call
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   110
      Interpreter::invoke_method(callee, istate->callee_entry_point(), THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   111
      fixup_after_potential_safepoint();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   112
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   113
      // Convert the result
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   114
      istate->set_stack(stack->sp() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   115
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   116
      // Restore the stack
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   117
      stack->set_sp(istate->stack_limit() + 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   118
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   119
      // Resume the interpreter
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   120
      istate->set_msg(BytecodeInterpreter::method_resume);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   121
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   122
    else if (istate->msg() == BytecodeInterpreter::more_monitors) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   123
      int monitor_words = frame::interpreter_frame_monitor_size();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   124
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   125
      // Allocate the space
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   126
      if (monitor_words > stack->available_words()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   127
        Unimplemented();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   128
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   129
      stack->alloc(monitor_words * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   130
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   131
      // Move the expression stack contents
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   132
      for (intptr_t *p = istate->stack() + 1; p < istate->stack_base(); p++)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   133
        *(p - monitor_words) = *p;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   134
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   135
      // Move the expression stack pointers
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   136
      istate->set_stack_limit(istate->stack_limit() - monitor_words);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   137
      istate->set_stack(istate->stack() - monitor_words);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   138
      istate->set_stack_base(istate->stack_base() - monitor_words);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   139
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   140
      // Zero the new monitor so the interpreter can find it.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   141
      ((BasicObjectLock *) istate->stack_base())->set_obj(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   142
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   143
      // Resume the interpreter
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   144
      istate->set_msg(BytecodeInterpreter::got_monitors);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   145
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   146
    else if (istate->msg() == BytecodeInterpreter::return_from_method) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   147
      // Copy the result into the caller's frame
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   148
      result_slots = type2size[method->result_type()];
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   149
      assert(result_slots >= 0 && result_slots <= 2, "what?");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   150
      result = istate->stack() + result_slots;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   151
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   152
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   153
    else if (istate->msg() == BytecodeInterpreter::throwing_exception) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   154
      assert(HAS_PENDING_EXCEPTION, "should do");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   155
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   156
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   157
    else if (istate->msg() == BytecodeInterpreter::do_osr) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   158
      // Unwind the current frame
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   159
      thread->pop_zero_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   160
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   161
      // Remove any extension of the previous frame
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   162
      int extra_locals = method->max_locals() - method->size_of_parameters();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   163
      stack->set_sp(stack->sp() + extra_locals);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   164
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   165
      // Jump into the OSR method
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   166
      Interpreter::invoke_osr(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   167
        method, istate->osr_entry(), istate->osr_buf(), THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   168
      return;
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 {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   171
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   172
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   173
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   174
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   175
 unwind_and_return:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   176
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   177
  // Unwind the current frame
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   178
  thread->pop_zero_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   179
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   180
  // Pop our local variables
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   181
  stack->set_sp(stack->sp() + method->max_locals());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   182
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   183
  // Push our result
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   184
  for (int i = 0; i < result_slots; i++)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   185
    stack->push(result[-i]);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   186
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   187
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   188
void CppInterpreter::native_entry(methodOop method, intptr_t UNUSED, TRAPS) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   189
  // Make sure method is native and not abstract
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   190
  assert(method->is_native() && !method->is_abstract(), "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   191
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   192
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   193
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   194
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   195
  // Allocate and initialize our frame
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   196
  InterpreterFrame *frame = InterpreterFrame::build(stack, method, thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   197
  thread->push_zero_frame(frame);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   198
  interpreterState istate = frame->interpreter_state();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   199
  intptr_t *locals = istate->locals();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   200
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   201
  // Check we're not about to run out of stack
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   202
  if (stack_overflow_imminent(thread)) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   203
    CALL_VM_NOCHECK(InterpreterRuntime::throw_StackOverflowError(thread));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   204
    goto unwind_and_return;
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
  // Lock if necessary
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   208
  BasicObjectLock *monitor;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   209
  monitor = NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   210
  if (method->is_synchronized()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   211
    monitor = (BasicObjectLock*) istate->stack_base();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   212
    oop lockee = monitor->obj();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   213
    markOop disp = lockee->mark()->set_unlocked();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   214
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   215
    monitor->lock()->set_displaced_header(disp);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   216
    if (Atomic::cmpxchg_ptr(monitor, lockee->mark_addr(), disp) != disp) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   217
      if (thread->is_lock_owned((address) disp->clear_lock_bits())) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   218
        monitor->lock()->set_displaced_header(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   219
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   220
      else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   221
        CALL_VM_NOCHECK(InterpreterRuntime::monitorenter(thread, monitor));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   222
        if (HAS_PENDING_EXCEPTION)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   223
          goto unwind_and_return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   224
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   225
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   226
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   227
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   228
  // Get the signature handler
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   229
  InterpreterRuntime::SignatureHandler *handler; {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   230
    address handlerAddr = method->signature_handler();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   231
    if (handlerAddr == NULL) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   232
      CALL_VM_NOCHECK(InterpreterRuntime::prepare_native_call(thread, method));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   233
      if (HAS_PENDING_EXCEPTION)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   234
        goto unwind_and_return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   235
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   236
      handlerAddr = method->signature_handler();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   237
      assert(handlerAddr != NULL, "eh?");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   238
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   239
    if (handlerAddr == (address) InterpreterRuntime::slow_signature_handler) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   240
      CALL_VM_NOCHECK(handlerAddr =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   241
        InterpreterRuntime::slow_signature_handler(thread, method, NULL,NULL));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   242
      if (HAS_PENDING_EXCEPTION)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   243
        goto unwind_and_return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   244
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   245
    handler = \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   246
      InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   247
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   248
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   249
  // Get the native function entry point
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   250
  address function;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   251
  function = method->native_function();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   252
  assert(function != NULL, "should be set if signature handler is");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   253
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   254
  // Build the argument list
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   255
  if (handler->argument_count() * 2 > stack->available_words()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   256
    Unimplemented();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   257
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   258
  void **arguments;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   259
  void *mirror; {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   260
    arguments =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   261
      (void **) stack->alloc(handler->argument_count() * sizeof(void **));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   262
    void **dst = arguments;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   263
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   264
    void *env = thread->jni_environment();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   265
    *(dst++) = &env;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   266
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   267
    if (method->is_static()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   268
      istate->set_oop_temp(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   269
        method->constants()->pool_holder()->klass_part()->java_mirror());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   270
      mirror = istate->oop_temp_addr();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   271
      *(dst++) = &mirror;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   272
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   273
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   274
    intptr_t *src = locals;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   275
    for (int i = dst - arguments; i < handler->argument_count(); i++) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   276
      ffi_type *type = handler->argument_type(i);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   277
      if (type == &ffi_type_pointer) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   278
        if (*src) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   279
          stack->push((intptr_t) src);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   280
          *(dst++) = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   281
        }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   282
        else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   283
          *(dst++) = src;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   284
        }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   285
        src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   286
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   287
      else if (type->size == 4) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   288
        *(dst++) = src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   289
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   290
      else if (type->size == 8) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   291
        src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   292
        *(dst++) = src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   293
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   294
      else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   295
        ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   296
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   297
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   298
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   299
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   300
  // Set up the Java frame anchor
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   301
  thread->set_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   302
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   303
  // Change the thread state to _thread_in_native
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   304
  ThreadStateTransition::transition_from_java(thread, _thread_in_native);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   305
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   306
  // Make the call
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   307
  intptr_t result[4 - LogBytesPerWord];
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   308
  ffi_call(handler->cif(), (void (*)()) function, result, arguments);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   309
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   310
  // Change the thread state back to _thread_in_Java.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   311
  // ThreadStateTransition::transition_from_native() cannot be used
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   312
  // here because it does not check for asynchronous exceptions.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   313
  // We have to manage the transition ourself.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   314
  thread->set_thread_state(_thread_in_native_trans);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   315
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   316
  // Make sure new state is visible in the GC thread
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   317
  if (os::is_MP()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   318
    if (UseMembar) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   319
      OrderAccess::fence();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   320
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   321
    else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   322
      InterfaceSupport::serialize_memory(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   323
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   324
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   325
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   326
  // Handle safepoint operations, pending suspend requests,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   327
  // and pending asynchronous exceptions.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   328
  if (SafepointSynchronize::do_call_back() ||
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   329
      thread->has_special_condition_for_native_trans()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   330
    JavaThread::check_special_condition_for_native_trans(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   331
    CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   332
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   333
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   334
  // Finally we can change the thread state to _thread_in_Java.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   335
  thread->set_thread_state(_thread_in_Java);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   336
  fixup_after_potential_safepoint();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   337
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   338
  // Clear the frame anchor
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   339
  thread->reset_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   340
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   341
  // If the result was an oop then unbox it and store it in
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   342
  // oop_temp where the garbage collector can see it before
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   343
  // we release the handle it might be protected by.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   344
  if (handler->result_type() == &ffi_type_pointer) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   345
    if (result[0])
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   346
      istate->set_oop_temp(*(oop *) result[0]);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   347
    else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   348
      istate->set_oop_temp(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   349
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   350
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   351
  // Reset handle block
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   352
  thread->active_handles()->clear();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   353
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   354
  // Unlock if necessary.  It seems totally wrong that this
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   355
  // is skipped in the event of an exception but apparently
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   356
  // the template interpreter does this so we do too.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   357
  if (monitor && !HAS_PENDING_EXCEPTION) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   358
    BasicLock *lock = monitor->lock();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   359
    markOop header = lock->displaced_header();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   360
    oop rcvr = monitor->obj();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   361
    monitor->set_obj(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   362
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   363
    if (header != NULL) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   364
      if (Atomic::cmpxchg_ptr(header, rcvr->mark_addr(), lock) != lock) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   365
        monitor->set_obj(rcvr); {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   366
          HandleMark hm(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   367
          CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(thread, monitor));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   368
        }
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
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   372
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   373
 unwind_and_return:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   374
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   375
  // Unwind the current activation
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   376
  thread->pop_zero_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
  // Pop our parameters
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   379
  stack->set_sp(stack->sp() + method->size_of_parameters());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   380
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   381
  // Push our result
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   382
  if (!HAS_PENDING_EXCEPTION) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   383
    stack->set_sp(stack->sp() - type2size[method->result_type()]);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   384
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   385
    switch (method->result_type()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   386
    case T_VOID:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   387
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   388
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   389
    case T_BOOLEAN:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   390
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   391
      result[0] <<= (BitsPerWord - BitsPerByte);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   392
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   393
      SET_LOCALS_INT(*(jboolean *) result != 0, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   394
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   395
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   396
    case T_CHAR:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   397
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   398
      result[0] <<= (BitsPerWord - BitsPerShort);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   399
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   400
      SET_LOCALS_INT(*(jchar *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   401
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   402
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   403
    case T_BYTE:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   404
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   405
      result[0] <<= (BitsPerWord - BitsPerByte);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   406
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   407
      SET_LOCALS_INT(*(jbyte *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   408
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   409
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   410
    case T_SHORT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   411
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   412
      result[0] <<= (BitsPerWord - BitsPerShort);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   413
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   414
      SET_LOCALS_INT(*(jshort *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   415
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   416
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   417
    case T_INT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   418
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   419
      result[0] <<= (BitsPerWord - BitsPerInt);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   420
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   421
      SET_LOCALS_INT(*(jint *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   422
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   423
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   424
    case T_LONG:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   425
      SET_LOCALS_LONG(*(jlong *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   426
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   427
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   428
    case T_FLOAT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   429
      SET_LOCALS_FLOAT(*(jfloat *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   430
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   431
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   432
    case T_DOUBLE:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   433
      SET_LOCALS_DOUBLE(*(jdouble *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   434
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   435
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   436
    case T_OBJECT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   437
    case T_ARRAY:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   438
      SET_LOCALS_OBJECT(istate->oop_temp(), 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
    default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   442
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   443
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   444
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   445
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   446
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   447
void CppInterpreter::accessor_entry(methodOop method, intptr_t UNUSED, TRAPS) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   448
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   449
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   450
  intptr_t *locals = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   451
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   452
  // Drop into the slow path if we need a safepoint check
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   453
  if (SafepointSynchronize::do_call_back()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   454
    normal_entry(method, 0, THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   455
    return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   456
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   457
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   458
  // Load the object pointer and drop into the slow path
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   459
  // if we have a NullPointerException
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   460
  oop object = LOCALS_OBJECT(0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   461
  if (object == NULL) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   462
    normal_entry(method, 0, THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   463
    return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   464
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   465
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   466
  // Read the field index from the bytecode, which looks like this:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   467
  //  0:  aload_0
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   468
  //  1:  getfield
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   469
  //  2:    index
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   470
  //  3:    index
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   471
  //  4:  ireturn/areturn
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   472
  // NB this is not raw bytecode: index is in machine order
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   473
  u1 *code = method->code_base();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   474
  assert(code[0] == Bytecodes::_aload_0 &&
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   475
         code[1] == Bytecodes::_getfield &&
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   476
         (code[4] == Bytecodes::_ireturn ||
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   477
          code[4] == Bytecodes::_areturn), "should do");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   478
  u2 index = Bytes::get_native_u2(&code[2]);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   479
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   480
  // Get the entry from the constant pool cache, and drop into
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   481
  // the slow path if it has not been resolved
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   482
  constantPoolCacheOop cache = method->constants()->cache();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   483
  ConstantPoolCacheEntry* entry = cache->entry_at(index);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   484
  if (!entry->is_resolved(Bytecodes::_getfield)) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   485
    normal_entry(method, 0, THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   486
    return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   487
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   488
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   489
  // Get the result and push it onto the stack
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   490
  switch (entry->flag_state()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   491
  case ltos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   492
  case dtos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   493
    if (stack->available_words() < 1) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   494
      Unimplemented();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   495
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   496
    stack->alloc(wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   497
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   498
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   499
  if (entry->is_volatile()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   500
    switch (entry->flag_state()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   501
    case ctos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   502
      SET_LOCALS_INT(object->char_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   503
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   504
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   505
    case btos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   506
      SET_LOCALS_INT(object->byte_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   507
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   508
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   509
    case stos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   510
      SET_LOCALS_INT(object->short_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   511
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   512
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   513
    case itos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   514
      SET_LOCALS_INT(object->int_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   515
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   516
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   517
    case ltos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   518
      SET_LOCALS_LONG(object->long_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   519
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   520
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   521
    case ftos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   522
      SET_LOCALS_FLOAT(object->float_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   523
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   524
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   525
    case dtos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   526
      SET_LOCALS_DOUBLE(object->double_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   527
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   528
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   529
    case atos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   530
      SET_LOCALS_OBJECT(object->obj_field_acquire(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   531
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   532
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   533
    default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   534
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   535
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   536
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   537
  else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   538
    switch (entry->flag_state()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   539
    case ctos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   540
      SET_LOCALS_INT(object->char_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   541
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   542
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   543
    case btos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   544
      SET_LOCALS_INT(object->byte_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   545
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   546
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   547
    case stos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   548
      SET_LOCALS_INT(object->short_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   549
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   550
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   551
    case itos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   552
      SET_LOCALS_INT(object->int_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   553
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   554
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   555
    case ltos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   556
      SET_LOCALS_LONG(object->long_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   557
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   558
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   559
    case ftos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   560
      SET_LOCALS_FLOAT(object->float_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   561
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   562
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   563
    case dtos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   564
      SET_LOCALS_DOUBLE(object->double_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   565
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   566
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   567
    case atos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   568
      SET_LOCALS_OBJECT(object->obj_field(entry->f2()), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   569
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   570
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   571
    default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   572
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   573
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   574
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   575
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   576
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   577
void CppInterpreter::empty_entry(methodOop method, intptr_t UNUSED, TRAPS) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   578
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   579
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   580
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   581
  // Drop into the slow path if we need a safepoint check
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   582
  if (SafepointSynchronize::do_call_back()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   583
    normal_entry(method, 0, THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   584
    return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   585
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   586
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   587
  // Pop our parameters
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   588
  stack->set_sp(stack->sp() + method->size_of_parameters());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   589
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   590
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   591
bool CppInterpreter::stack_overflow_imminent(JavaThread *thread) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   592
  // How is the ABI stack?
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   593
  address stack_top = thread->stack_base() - thread->stack_size();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   594
  int free_stack = os::current_stack_pointer() - stack_top;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   595
  if (free_stack < StackShadowPages * os::vm_page_size()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   596
    return true;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   597
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   598
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   599
  // How is the Zero stack?
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   600
  // Throwing a StackOverflowError involves a VM call, which means
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   601
  // we need a frame on the stack.  We should be checking here to
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   602
  // ensure that methods we call have enough room to install the
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   603
  // largest possible frame, but that's more than twice the size
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   604
  // of the entire Zero stack we get by default, so we just check
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   605
  // we have *some* space instead...
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   606
  free_stack = thread->zero_stack()->available_words() * wordSize;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   607
  if (free_stack < StackShadowPages * os::vm_page_size()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   608
    return true;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   609
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   610
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   611
  return false;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   612
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   613
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   614
InterpreterFrame *InterpreterFrame::build(ZeroStack*       stack,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   615
                                          const methodOop  method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   616
                                          JavaThread*      thread) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   617
  int monitor_words =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   618
    method->is_synchronized() ? frame::interpreter_frame_monitor_size() : 0;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   619
  int stack_words = method->is_native() ? 0 : method->max_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   620
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   621
  if (header_words + monitor_words + stack_words > stack->available_words()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   622
    Unimplemented();
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
  intptr_t *locals;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   626
  if (method->is_native())
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   627
    locals = stack->sp() + (method->size_of_parameters() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   628
  else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   629
    locals = stack->sp() + (method->max_locals() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   630
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   631
  stack->push(0); // next_frame, filled in later
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   632
  intptr_t *fp = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   633
  assert(fp - stack->sp() == next_frame_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   634
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   635
  stack->push(INTERPRETER_FRAME);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   636
  assert(fp - stack->sp() == frame_type_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   637
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   638
  interpreterState istate =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   639
    (interpreterState) stack->alloc(sizeof(BytecodeInterpreter));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   640
  assert(fp - stack->sp() == istate_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   641
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   642
  istate->set_locals(locals);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   643
  istate->set_method(method);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   644
  istate->set_self_link(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   645
  istate->set_prev_link(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   646
  istate->set_thread(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   647
  istate->set_bcp(method->is_native() ? NULL : method->code_base());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   648
  istate->set_constants(method->constants()->cache());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   649
  istate->set_msg(BytecodeInterpreter::method_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   650
  istate->set_oop_temp(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   651
  istate->set_mdx(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   652
  istate->set_callee(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   653
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   654
  istate->set_monitor_base((BasicObjectLock *) stack->sp());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   655
  if (method->is_synchronized()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   656
    BasicObjectLock *monitor =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   657
      (BasicObjectLock *) stack->alloc(monitor_words * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   658
    oop object;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   659
    if (method->is_static())
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   660
      object = method->constants()->pool_holder()->klass_part()->java_mirror();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   661
    else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   662
      object = (oop) locals[0];
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   663
    monitor->set_obj(object);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   664
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   665
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   666
  istate->set_stack_base(stack->sp());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   667
  istate->set_stack(stack->sp() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   668
  if (stack_words)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   669
    stack->alloc(stack_words * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   670
  istate->set_stack_limit(stack->sp() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   671
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   672
  return (InterpreterFrame *) fp;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   673
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   674
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   675
int AbstractInterpreter::BasicType_as_index(BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   676
  int i = 0;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   677
  switch (type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   678
    case T_BOOLEAN: i = 0; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   679
    case T_CHAR   : i = 1; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   680
    case T_BYTE   : i = 2; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   681
    case T_SHORT  : i = 3; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   682
    case T_INT    : i = 4; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   683
    case T_LONG   : i = 5; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   684
    case T_VOID   : i = 6; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   685
    case T_FLOAT  : i = 7; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   686
    case T_DOUBLE : i = 8; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   687
    case T_OBJECT : i = 9; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   688
    case T_ARRAY  : i = 9; break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   689
    default       : ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   690
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   691
  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   692
         "index out of bounds");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   693
  return i;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   694
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   695
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   696
address InterpreterGenerator::generate_empty_entry() {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   697
  if (!UseFastEmptyMethods)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   698
    return NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   699
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   700
  return generate_entry((address) CppInterpreter::empty_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   701
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   702
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   703
address InterpreterGenerator::generate_accessor_entry() {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   704
  if (!UseFastAccessorMethods)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   705
    return NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   706
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   707
  return generate_entry((address) CppInterpreter::accessor_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   708
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   709
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   710
address InterpreterGenerator::generate_native_entry(bool synchronized) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   711
  assert(synchronized == false, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   712
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   713
  return generate_entry((address) CppInterpreter::native_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   714
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   715
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   716
address InterpreterGenerator::generate_normal_entry(bool synchronized) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   717
  assert(synchronized == false, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   718
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   719
  return generate_entry((address) CppInterpreter::normal_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   720
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   721
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   722
address AbstractInterpreterGenerator::generate_method_entry(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   723
    AbstractInterpreter::MethodKind kind) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   724
  address entry_point = NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   725
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   726
  switch (kind) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   727
  case Interpreter::zerolocals:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   728
  case Interpreter::zerolocals_synchronized:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   729
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   730
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   731
  case Interpreter::native:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   732
    entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   733
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   734
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   735
  case Interpreter::native_synchronized:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   736
    entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   737
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   738
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   739
  case Interpreter::empty:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   740
    entry_point = ((InterpreterGenerator*) this)->generate_empty_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   741
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   742
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   743
  case Interpreter::accessor:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   744
    entry_point = ((InterpreterGenerator*) this)->generate_accessor_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   745
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   746
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   747
  case Interpreter::abstract:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   748
    entry_point = ((InterpreterGenerator*) this)->generate_abstract_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   749
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   750
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   751
  case Interpreter::method_handle:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   752
    entry_point = ((InterpreterGenerator*) this)->generate_method_handle_entry();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   753
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   754
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   755
  case Interpreter::java_lang_math_sin:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   756
  case Interpreter::java_lang_math_cos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   757
  case Interpreter::java_lang_math_tan:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   758
  case Interpreter::java_lang_math_abs:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   759
  case Interpreter::java_lang_math_log:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   760
  case Interpreter::java_lang_math_log10:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   761
  case Interpreter::java_lang_math_sqrt:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   762
    entry_point = ((InterpreterGenerator*) this)->generate_math_entry(kind);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   763
    break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   764
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   765
  default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   766
    ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   767
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   768
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   769
  if (entry_point == NULL)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   770
    entry_point = ((InterpreterGenerator*) this)->generate_normal_entry(false);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   771
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   772
  return entry_point;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   773
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   774
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   775
InterpreterGenerator::InterpreterGenerator(StubQueue* code)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   776
 : CppInterpreterGenerator(code) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   777
   generate_all();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   778
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   779
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   780
// Deoptimization helpers
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   781
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   782
InterpreterFrame *InterpreterFrame::build(ZeroStack* stack, int size) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   783
  int size_in_words = size >> LogBytesPerWord;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   784
  assert(size_in_words * wordSize == size, "unaligned");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   785
  assert(size_in_words >= header_words, "too small");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   786
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   787
  if (size_in_words > stack->available_words()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   788
    Unimplemented();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   789
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   790
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   791
  stack->push(0); // next_frame, filled in later
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   792
  intptr_t *fp = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   793
  assert(fp - stack->sp() == next_frame_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   794
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   795
  stack->push(INTERPRETER_FRAME);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   796
  assert(fp - stack->sp() == frame_type_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   797
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   798
  interpreterState istate =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   799
    (interpreterState) stack->alloc(sizeof(BytecodeInterpreter));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   800
  assert(fp - stack->sp() == istate_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   801
  istate->set_self_link(NULL); // mark invalid
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   802
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   803
  stack->alloc((size_in_words - header_words) * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   804
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   805
  return (InterpreterFrame *) fp;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   806
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   807
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   808
int AbstractInterpreter::layout_activation(methodOop method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   809
                                           int       tempcount,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   810
                                           int       popframe_extra_args,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   811
                                           int       moncount,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   812
                                           int       callee_param_count,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   813
                                           int       callee_locals,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   814
                                           frame*    caller,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   815
                                           frame*    interpreter_frame,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   816
                                           bool      is_top_frame) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   817
  assert(popframe_extra_args == 0, "what to do?");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   818
  assert(!is_top_frame || (!callee_locals && !callee_param_count),
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   819
         "top frame should have no caller")
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   820
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   821
  // This code must exactly match what InterpreterFrame::build
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   822
  // does (the full InterpreterFrame::build, that is, not the
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   823
  // one that creates empty frames for the deoptimizer).
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   824
  //
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   825
  // If interpreter_frame is not NULL then it will be filled in.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   826
  // It's size is determined by a previous call to this method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   827
  // so it should be correct.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   828
  //
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   829
  // Note that tempcount is the current size of the expression
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   830
  // stack.  For top most frames we will allocate a full sized
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   831
  // expression stack and not the trimmed version that non-top
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   832
  // frames have.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   833
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   834
  int header_words        = InterpreterFrame::header_words;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   835
  int monitor_words       = moncount * frame::interpreter_frame_monitor_size();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   836
  int stack_words         = is_top_frame ? method->max_stack() : tempcount;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   837
  int callee_extra_locals = callee_locals - callee_param_count;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   838
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   839
  if (interpreter_frame) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   840
    intptr_t *locals        = interpreter_frame->sp() + method->max_locals();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   841
    interpreterState istate = interpreter_frame->get_interpreterState();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   842
    intptr_t *monitor_base  = (intptr_t*) istate;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   843
    intptr_t *stack_base    = monitor_base - monitor_words;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   844
    intptr_t *stack         = stack_base - tempcount - 1;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   845
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   846
    BytecodeInterpreter::layout_interpreterState(istate,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   847
                                                 caller,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   848
                                                 NULL,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   849
                                                 method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   850
                                                 locals,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   851
                                                 stack,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   852
                                                 stack_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   853
                                                 monitor_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   854
                                                 NULL,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   855
                                                 is_top_frame);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   856
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   857
  return header_words + monitor_words + stack_words + callee_extra_locals;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   858
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   859
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   860
void BytecodeInterpreter::layout_interpreterState(interpreterState istate,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   861
                                                  frame*    caller,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   862
                                                  frame*    current,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   863
                                                  methodOop method,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   864
                                                  intptr_t* locals,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   865
                                                  intptr_t* stack,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   866
                                                  intptr_t* stack_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   867
                                                  intptr_t* monitor_base,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   868
                                                  intptr_t* frame_bottom,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   869
                                                  bool      is_top_frame) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   870
  istate->set_locals(locals);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   871
  istate->set_method(method);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   872
  istate->set_self_link(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   873
  istate->set_prev_link(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   874
  // thread will be set by a hacky repurposing of frame::patch_pc()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   875
  // bcp will be set by vframeArrayElement::unpack_on_stack()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   876
  istate->set_constants(method->constants()->cache());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   877
  istate->set_msg(BytecodeInterpreter::method_resume);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   878
  istate->set_bcp_advance(0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   879
  istate->set_oop_temp(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   880
  istate->set_mdx(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   881
  if (caller->is_interpreted_frame()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   882
    interpreterState prev = caller->get_interpreterState();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   883
    prev->set_callee(method);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   884
    if (*prev->bcp() == Bytecodes::_invokeinterface)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   885
      prev->set_bcp_advance(5);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   886
    else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   887
      prev->set_bcp_advance(3);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   888
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   889
  istate->set_callee(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   890
  istate->set_monitor_base((BasicObjectLock *) monitor_base);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   891
  istate->set_stack_base(stack_base);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   892
  istate->set_stack(stack);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   893
  istate->set_stack_limit(stack_base - method->max_stack() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   894
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   895
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   896
address CppInterpreter::return_entry(TosState state, int length) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   897
  ShouldNotCallThis();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   898
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   899
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   900
address CppInterpreter::deopt_entry(TosState state, int length) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   901
  return NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   902
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   903
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   904
// Helper for (runtime) stack overflow checks
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   905
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   906
int AbstractInterpreter::size_top_interpreter_activation(methodOop method) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   907
  return 0;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   908
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   909
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   910
// Helper for figuring out if frames are interpreter frames
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   911
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   912
bool CppInterpreter::contains(address pc) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   913
#ifdef PRODUCT
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   914
  ShouldNotCallThis();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   915
#else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   916
  return false; // make frame::print_value_on work
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   917
#endif // !PRODUCT
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   918
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   919
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   920
// Result handlers and convertors
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   921
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   922
address CppInterpreterGenerator::generate_result_handler_for(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   923
    BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   924
  assembler()->advance(1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   925
  return ShouldNotCallThisStub();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   926
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   927
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   928
address CppInterpreterGenerator::generate_tosca_to_stack_converter(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   929
    BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   930
  assembler()->advance(1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   931
  return ShouldNotCallThisStub();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   932
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   933
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   934
address CppInterpreterGenerator::generate_stack_to_stack_converter(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   935
    BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   936
  assembler()->advance(1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   937
  return ShouldNotCallThisStub();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   938
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   939
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   940
address CppInterpreterGenerator::generate_stack_to_native_abi_converter(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   941
    BasicType type) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   942
  assembler()->advance(1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   943
  return ShouldNotCallThisStub();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   944
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   945
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   946
#endif // CC_INTERP