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