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