src/hotspot/cpu/zero/cppInterpreter_zero.cpp
author coleenp
Fri, 16 Mar 2018 09:12:13 -0400
changeset 49449 ef5d5d343e2a
parent 49390 95f0b54a3024
child 49722 a47d1e21b3f1
permissions -rw-r--r--
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files Summary: interfaceSupport.hpp is an inline file so moved to interfaceSupport.inline.hpp and stopped including it in .hpp files Reviewed-by: stefank, rehn, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
     1
/*
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 47906
diff changeset
     2
 * Copyright (c) 2003, 2018, 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"
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 34169
diff changeset
    30
#include "interpreter/cppInterpreterGenerator.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    31
#include "interpreter/interpreter.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"
49390
95f0b54a3024 8199220: Zero build broken after 8195103, 8191102 and 8189871
enevill
parents: 49192
diff changeset
    34
#include "oops/cpCache.inline.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    35
#include "oops/methodData.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    36
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    37
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    38
#include "prims/jvmtiExport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    39
#include "prims/jvmtiThreadState.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    40
#include "runtime/arguments.hpp"
40655
9f644073d3a0 8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents: 38074
diff changeset
    41
#include "runtime/atomic.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    42
#include "runtime/deoptimization.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    43
#include "runtime/frame.inline.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49390
diff changeset
    44
#include "runtime/interfaceSupport.inline.hpp"
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 47906
diff changeset
    45
#include "runtime/jniHandles.inline.hpp"
24351
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 24018
diff changeset
    46
#include "runtime/orderAccess.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    47
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    48
#include "runtime/stubRoutines.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    49
#include "runtime/synchronizer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    50
#include "runtime/timer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    51
#include "runtime/vframeArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    52
#include "stack_zero.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5885
diff changeset
    53
#include "utilities/debug.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14622
diff changeset
    54
#include "utilities/macros.hpp"
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    55
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    56
#ifdef CC_INTERP
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    57
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    58
#define fixup_after_potential_safepoint()       \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    59
  method = istate->method()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    60
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
    61
#define CALL_VM_NOCHECK_NOFIX(func)             \
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    62
  thread->set_last_Java_frame();                \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    63
  func;                                         \
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
    64
  thread->reset_last_Java_frame();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
    65
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
    66
#define CALL_VM_NOCHECK(func)                   \
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
    67
  CALL_VM_NOCHECK_NOFIX(func)                   \
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    68
  fixup_after_potential_safepoint()
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    69
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    70
int CppInterpreter::normal_entry(Method* method, intptr_t UNUSED, TRAPS) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    71
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    72
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    73
  // Allocate and initialize our frame.
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
    74
  InterpreterFrame *frame = InterpreterFrame::build(method, CHECK_0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    75
  thread->push_zero_frame(frame);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    76
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    77
  // Execute those bytecodes!
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    78
  main_loop(0, THREAD);
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
    79
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
    80
  // No deoptimized frames on the stack
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
    81
  return 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    82
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
    83
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    84
intptr_t narrow(BasicType type, intptr_t result) {
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    85
  // mask integer result to narrower return type.
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    86
  switch (type) {
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    87
    case T_BOOLEAN:
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    88
      return result&1;
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    89
    case T_BYTE:
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    90
      return (intptr_t)(jbyte)result;
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    91
    case T_CHAR:
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    92
      return (intptr_t)(uintptr_t)(jchar)result;
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    93
    case T_SHORT:
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    94
      return (intptr_t)(jshort)result;
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    95
    case T_OBJECT:  // nothing to do fall through
37481
95af21ea8eb0 8146518: Zero interpreter broken with better byte behaviours
coleenp
parents: 37480
diff changeset
    96
    case T_ARRAY:
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    97
    case T_LONG:
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    98
    case T_INT:
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
    99
    case T_FLOAT:
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   100
    case T_DOUBLE:
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   101
    case T_VOID:
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   102
      return result;
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   103
    default  : ShouldNotReachHere();
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   104
  }
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   105
}
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   106
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   107
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   108
void CppInterpreter::main_loop(int recurse, TRAPS) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   109
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   110
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   111
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   112
  // If we are entering from a deopt we may need to call
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   113
  // ourself a few times in order to get to our frame.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   114
  if (recurse)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   115
    main_loop(recurse - 1, THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   116
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   117
  InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   118
  interpreterState istate = frame->interpreter_state();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   119
  Method* method = istate->method();
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   120
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   121
  intptr_t *result = NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   122
  int result_slots = 0;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   123
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   124
  while (true) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   125
    // We can set up the frame anchor with everything we want at
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   126
    // this point as we are thread_in_Java and no safepoints can
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   127
    // occur until we go to vm mode.  We do have to clear flags
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   128
    // on return from vm but that is it.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   129
    thread->set_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   130
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   131
    // Call the interpreter
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   132
    if (JvmtiExport::can_post_interpreter_events())
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   133
      BytecodeInterpreter::runWithChecks(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   134
    else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   135
      BytecodeInterpreter::run(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   136
    fixup_after_potential_safepoint();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   137
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   138
    // Clear the frame anchor
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   139
    thread->reset_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   140
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   141
    // Examine the message from the interpreter to decide what to do
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   142
    if (istate->msg() == BytecodeInterpreter::call_method) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   143
      Method* callee = istate->callee();
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   144
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   145
      // Trim back the stack to put the parameters at the top
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   146
      stack->set_sp(istate->stack() + 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   147
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   148
      // Make the call
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   149
      Interpreter::invoke_method(callee, istate->callee_entry_point(), THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   150
      fixup_after_potential_safepoint();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   151
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   152
      // Convert the result
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   153
      istate->set_stack(stack->sp() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   154
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   155
      // Restore the stack
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   156
      stack->set_sp(istate->stack_limit() + 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   157
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   158
      // Resume the interpreter
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   159
      istate->set_msg(BytecodeInterpreter::method_resume);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   160
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   161
    else if (istate->msg() == BytecodeInterpreter::more_monitors) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   162
      int monitor_words = frame::interpreter_frame_monitor_size();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   163
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   164
      // Allocate the space
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   165
      stack->overflow_check(monitor_words, THREAD);
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   166
      if (HAS_PENDING_EXCEPTION)
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   167
        break;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   168
      stack->alloc(monitor_words * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   169
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   170
      // Move the expression stack contents
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   171
      for (intptr_t *p = istate->stack() + 1; p < istate->stack_base(); p++)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   172
        *(p - monitor_words) = *p;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   173
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   174
      // Move the expression stack pointers
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   175
      istate->set_stack_limit(istate->stack_limit() - monitor_words);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   176
      istate->set_stack(istate->stack() - monitor_words);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   177
      istate->set_stack_base(istate->stack_base() - monitor_words);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   178
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   179
      // Zero the new monitor so the interpreter can find it.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   180
      ((BasicObjectLock *) istate->stack_base())->set_obj(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   181
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   182
      // Resume the interpreter
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   183
      istate->set_msg(BytecodeInterpreter::got_monitors);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   184
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   185
    else if (istate->msg() == BytecodeInterpreter::return_from_method) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   186
      // Copy the result into the caller's frame
37481
95af21ea8eb0 8146518: Zero interpreter broken with better byte behaviours
coleenp
parents: 37480
diff changeset
   187
      result_slots = type2size[method->result_type()];
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   188
      assert(result_slots >= 0 && result_slots <= 2, "what?");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   189
      result = istate->stack() + result_slots;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   190
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   191
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   192
    else if (istate->msg() == BytecodeInterpreter::throwing_exception) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   193
      assert(HAS_PENDING_EXCEPTION, "should do");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   194
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   195
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   196
    else if (istate->msg() == BytecodeInterpreter::do_osr) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   197
      // Unwind the current frame
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   198
      thread->pop_zero_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   199
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   200
      // Remove any extension of the previous frame
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   201
      int extra_locals = method->max_locals() - method->size_of_parameters();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   202
      stack->set_sp(stack->sp() + extra_locals);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   203
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   204
      // Jump into the OSR method
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   205
      Interpreter::invoke_osr(
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   206
        method, istate->osr_entry(), istate->osr_buf(), THREAD);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   207
      return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   208
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   209
    else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   210
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   211
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   212
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   213
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   214
  // Unwind the current frame
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   215
  thread->pop_zero_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   216
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   217
  // Pop our local variables
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   218
  stack->set_sp(stack->sp() + method->max_locals());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   219
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   220
  // Push our result
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   221
  for (int i = 0; i < result_slots; i++) {
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   222
    // Adjust result to smaller
38063
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37486
diff changeset
   223
    union {
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37486
diff changeset
   224
      intptr_t res;
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37486
diff changeset
   225
      jint res_jint;
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37486
diff changeset
   226
    };
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37486
diff changeset
   227
    res = result[-i];
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   228
    if (result_slots == 1) {
38063
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37486
diff changeset
   229
      BasicType t = method->result_type();
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37486
diff changeset
   230
      if (is_subword_type(t)) {
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37486
diff changeset
   231
        res_jint = (jint)narrow(t, res_jint);
93b9ff8b977e 8154210: Zero: Better byte behaviour
aph
parents: 37486
diff changeset
   232
      }
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   233
    }
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   234
    stack->push(res);
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   235
  }
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   236
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   237
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   238
int CppInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   239
  // Make sure method is native and not abstract
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   240
  assert(method->is_native() && !method->is_abstract(), "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   241
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   242
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   243
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   244
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   245
  // Allocate and initialize our frame
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   246
  InterpreterFrame *frame = InterpreterFrame::build(method, CHECK_0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   247
  thread->push_zero_frame(frame);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   248
  interpreterState istate = frame->interpreter_state();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   249
  intptr_t *locals = istate->locals();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   250
4448
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   251
  // Update the invocation counter
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   252
  if ((UseCompiler || CountCompiledCalls) && !method->is_synchronized()) {
17314
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15943
diff changeset
   253
    MethodCounters* mcs = method->method_counters();
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15943
diff changeset
   254
    if (mcs == NULL) {
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15943
diff changeset
   255
      CALL_VM_NOCHECK(mcs = InterpreterRuntime::build_method_counters(thread, method));
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15943
diff changeset
   256
      if (HAS_PENDING_EXCEPTION)
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15943
diff changeset
   257
        goto unwind_and_return;
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15943
diff changeset
   258
    }
28fab19f2ccd 8013067: Zero builds are broken after 8010862.
jiangli
parents: 15943
diff changeset
   259
    InvocationCounter *counter = mcs->invocation_counter();
4448
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   260
    counter->increment();
22836
e7e511228518 8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
goetz
parents: 19336
diff changeset
   261
    if (counter->reached_InvocationLimit(mcs->backedge_counter())) {
4448
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   262
      CALL_VM_NOCHECK(
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   263
        InterpreterRuntime::frequency_counter_overflow(thread, NULL));
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   264
      if (HAS_PENDING_EXCEPTION)
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   265
        goto unwind_and_return;
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   266
    }
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   267
  }
d6ec2737186c 6896043: first round of zero fixes
twisti
parents: 4013
diff changeset
   268
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   269
  // Lock if necessary
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   270
  BasicObjectLock *monitor;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   271
  monitor = NULL;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   272
  if (method->is_synchronized()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   273
    monitor = (BasicObjectLock*) istate->stack_base();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   274
    oop lockee = monitor->obj();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   275
    markOop disp = lockee->mark()->set_unlocked();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   276
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   277
    monitor->lock()->set_displaced_header(disp);
47634
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
   278
    if (Atomic::cmpxchg((markOop)monitor, lockee->mark_addr(), disp) != disp) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   279
      if (thread->is_lock_owned((address) disp->clear_lock_bits())) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   280
        monitor->lock()->set_displaced_header(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   281
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   282
      else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   283
        CALL_VM_NOCHECK(InterpreterRuntime::monitorenter(thread, monitor));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   284
        if (HAS_PENDING_EXCEPTION)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   285
          goto unwind_and_return;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   286
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   287
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   288
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   289
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   290
  // Get the signature handler
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   291
  InterpreterRuntime::SignatureHandler *handler; {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   292
    address handlerAddr = method->signature_handler();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   293
    if (handlerAddr == NULL) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   294
      CALL_VM_NOCHECK(InterpreterRuntime::prepare_native_call(thread, method));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   295
      if (HAS_PENDING_EXCEPTION)
4568
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   296
        goto unlock_unwind_and_return;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   297
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   298
      handlerAddr = method->signature_handler();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   299
      assert(handlerAddr != NULL, "eh?");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   300
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   301
    if (handlerAddr == (address) InterpreterRuntime::slow_signature_handler) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   302
      CALL_VM_NOCHECK(handlerAddr =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   303
        InterpreterRuntime::slow_signature_handler(thread, method, NULL,NULL));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   304
      if (HAS_PENDING_EXCEPTION)
4568
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   305
        goto unlock_unwind_and_return;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   306
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   307
    handler = \
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   308
      InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   309
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   310
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   311
  // Get the native function entry point
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   312
  address function;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   313
  function = method->native_function();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   314
  assert(function != NULL, "should be set if signature handler is");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   315
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   316
  // Build the argument list
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   317
  stack->overflow_check(handler->argument_count() * 2, THREAD);
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   318
  if (HAS_PENDING_EXCEPTION)
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   319
    goto unlock_unwind_and_return;
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   320
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   321
  void **arguments;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   322
  void *mirror; {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   323
    arguments =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   324
      (void **) stack->alloc(handler->argument_count() * sizeof(void **));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   325
    void **dst = arguments;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   326
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   327
    void *env = thread->jni_environment();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   328
    *(dst++) = &env;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   329
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   330
    if (method->is_static()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   331
      istate->set_oop_temp(
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 7397
diff changeset
   332
        method->constants()->pool_holder()->java_mirror());
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   333
      mirror = istate->oop_temp_addr();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   334
      *(dst++) = &mirror;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   335
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   336
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   337
    intptr_t *src = locals;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   338
    for (int i = dst - arguments; i < handler->argument_count(); i++) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   339
      ffi_type *type = handler->argument_type(i);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   340
      if (type == &ffi_type_pointer) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   341
        if (*src) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   342
          stack->push((intptr_t) src);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   343
          *(dst++) = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   344
        }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   345
        else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   346
          *(dst++) = src;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   347
        }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   348
        src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   349
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   350
      else if (type->size == 4) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   351
        *(dst++) = src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   352
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   353
      else if (type->size == 8) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   354
        src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   355
        *(dst++) = src--;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   356
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   357
      else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   358
        ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   359
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   360
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   361
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   362
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   363
  // Set up the Java frame anchor
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   364
  thread->set_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   365
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   366
  // Change the thread state to _thread_in_native
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   367
  ThreadStateTransition::transition_from_java(thread, _thread_in_native);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   368
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   369
  // Make the call
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   370
  intptr_t result[4 - LogBytesPerWord];
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   371
  ffi_call(handler->cif(), (void (*)()) function, result, arguments);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   372
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   373
  // Change the thread state back to _thread_in_Java.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   374
  // ThreadStateTransition::transition_from_native() cannot be used
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   375
  // here because it does not check for asynchronous exceptions.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   376
  // We have to manage the transition ourself.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   377
  thread->set_thread_state(_thread_in_native_trans);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   378
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   379
  // Make sure new state is visible in the GC thread
46604
d409276ee40c 8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents: 44406
diff changeset
   380
  InterfaceSupport::serialize_thread_state(thread);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   381
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   382
  // Handle safepoint operations, pending suspend requests,
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   383
  // and pending asynchronous exceptions.
47906
0ad8a90268a7 8191333: Zero variant broken after 8189941
glaubitz
parents: 47687
diff changeset
   384
  if (SafepointMechanism::poll(thread) ||
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   385
      thread->has_special_condition_for_native_trans()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   386
    JavaThread::check_special_condition_for_native_trans(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   387
    CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops());
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
  // Finally we can change the thread state to _thread_in_Java.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   391
  thread->set_thread_state(_thread_in_Java);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   392
  fixup_after_potential_safepoint();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   393
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   394
  // Clear the frame anchor
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   395
  thread->reset_last_Java_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   396
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   397
  // If the result was an oop then unbox it and store it in
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   398
  // oop_temp where the garbage collector can see it before
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   399
  // we release the handle it might be protected by.
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   400
  if (handler->result_type() == &ffi_type_pointer) {
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   401
    if (result[0] == 0) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   402
      istate->set_oop_temp(NULL);
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   403
    } else {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   404
      jobject handle = reinterpret_cast<jobject>(result[0]);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   405
      istate->set_oop_temp(JNIHandles::resolve(handle));
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
   406
    }
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   407
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   408
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   409
  // Reset handle block
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   410
  thread->active_handles()->clear();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   411
4568
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   412
 unlock_unwind_and_return:
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   413
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   414
  // Unlock if necessary
d18b14983811 6908267: Zero fails to unlock synchronized native methods on exception
never
parents: 4448
diff changeset
   415
  if (monitor) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   416
    BasicLock *lock = monitor->lock();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   417
    markOop header = lock->displaced_header();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   418
    oop rcvr = monitor->obj();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   419
    monitor->set_obj(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   420
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   421
    if (header != NULL) {
47634
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
   422
      markOop old_header = markOopDesc::encode(lock);
6a0c42c40cd1 8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents: 47216
diff changeset
   423
      if (rcvr->cas_set_mark(header, old_header) != old_header) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   424
        monitor->set_obj(rcvr); {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   425
          HandleMark hm(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   426
          CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(thread, monitor));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   427
        }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   428
      }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   429
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   430
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   431
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   432
 unwind_and_return:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   433
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   434
  // Unwind the current activation
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   435
  thread->pop_zero_frame();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   436
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   437
  // Pop our parameters
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   438
  stack->set_sp(stack->sp() + method->size_of_parameters());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   439
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   440
  // Push our result
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   441
  if (!HAS_PENDING_EXCEPTION) {
37481
95af21ea8eb0 8146518: Zero interpreter broken with better byte behaviours
coleenp
parents: 37480
diff changeset
   442
    BasicType type = method->result_type();
4897
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
   443
    stack->set_sp(stack->sp() - type2size[type]);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   444
4897
d5dd3852bf8d 6926048: Improve Zero performance
kvn
parents: 4568
diff changeset
   445
    switch (type) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   446
    case T_VOID:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   447
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   448
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   449
    case T_BOOLEAN:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   450
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   451
      result[0] <<= (BitsPerWord - BitsPerByte);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   452
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   453
      SET_LOCALS_INT(*(jboolean *) result != 0, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   454
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   455
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   456
    case T_CHAR:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   457
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   458
      result[0] <<= (BitsPerWord - BitsPerShort);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   459
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   460
      SET_LOCALS_INT(*(jchar *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   461
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   462
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   463
    case T_BYTE:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   464
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   465
      result[0] <<= (BitsPerWord - BitsPerByte);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   466
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   467
      SET_LOCALS_INT(*(jbyte *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   468
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   469
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   470
    case T_SHORT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   471
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   472
      result[0] <<= (BitsPerWord - BitsPerShort);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   473
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   474
      SET_LOCALS_INT(*(jshort *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   475
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   476
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   477
    case T_INT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   478
#ifndef VM_LITTLE_ENDIAN
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   479
      result[0] <<= (BitsPerWord - BitsPerInt);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   480
#endif
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   481
      SET_LOCALS_INT(*(jint *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   482
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   483
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   484
    case T_LONG:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   485
      SET_LOCALS_LONG(*(jlong *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   486
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   487
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   488
    case T_FLOAT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   489
      SET_LOCALS_FLOAT(*(jfloat *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   490
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   491
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   492
    case T_DOUBLE:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   493
      SET_LOCALS_DOUBLE(*(jdouble *) result, 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   494
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   495
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   496
    case T_OBJECT:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   497
    case T_ARRAY:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   498
      SET_LOCALS_OBJECT(istate->oop_temp(), 0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   499
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   500
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   501
    default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   502
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   503
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   504
  }
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   505
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   506
  // No deoptimized frames on the stack
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   507
  return 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   508
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   509
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   510
int CppInterpreter::accessor_entry(Method* method, intptr_t UNUSED, TRAPS) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   511
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   512
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   513
  intptr_t *locals = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   514
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   515
  // Drop into the slow path if we need a safepoint check
47906
0ad8a90268a7 8191333: Zero variant broken after 8189941
glaubitz
parents: 47687
diff changeset
   516
  if (SafepointMechanism::poll(THREAD)) {
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   517
    return normal_entry(method, 0, THREAD);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   518
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   519
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   520
  // Load the object pointer and drop into the slow path
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   521
  // if we have a NullPointerException
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   522
  oop object = LOCALS_OBJECT(0);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   523
  if (object == NULL) {
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   524
    return normal_entry(method, 0, THREAD);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   525
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   526
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   527
  // Read the field index from the bytecode, which looks like this:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   528
  //  0:  aload_0
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   529
  //  1:  getfield
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   530
  //  2:    index
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   531
  //  3:    index
34169
b0b7187852b7 8140650: Method::is_accessor should cover getters and setters for all types
shade
parents: 33070
diff changeset
   532
  //  4:  ireturn/areturn/freturn/lreturn/dreturn
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   533
  // NB this is not raw bytecode: index is in machine order
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   534
  u1 *code = method->code_base();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   535
  assert(code[0] == Bytecodes::_aload_0 &&
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   536
         code[1] == Bytecodes::_getfield &&
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   537
         (code[4] == Bytecodes::_ireturn ||
34169
b0b7187852b7 8140650: Method::is_accessor should cover getters and setters for all types
shade
parents: 33070
diff changeset
   538
          code[4] == Bytecodes::_freturn ||
b0b7187852b7 8140650: Method::is_accessor should cover getters and setters for all types
shade
parents: 33070
diff changeset
   539
          code[4] == Bytecodes::_lreturn ||
b0b7187852b7 8140650: Method::is_accessor should cover getters and setters for all types
shade
parents: 33070
diff changeset
   540
          code[4] == Bytecodes::_dreturn ||
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   541
          code[4] == Bytecodes::_areturn), "should do");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   542
  u2 index = Bytes::get_native_u2(&code[2]);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   543
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   544
  // Get the entry from the constant pool cache, and drop into
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   545
  // 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
   546
  ConstantPoolCache* cache = method->constants()->cache();
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   547
  ConstantPoolCacheEntry* entry = cache->entry_at(index);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   548
  if (!entry->is_resolved(Bytecodes::_getfield)) {
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   549
    return normal_entry(method, 0, THREAD);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   550
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   551
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   552
  // Get the result and push it onto the stack
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   553
  switch (entry->flag_state()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   554
  case ltos:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   555
  case dtos:
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   556
    stack->overflow_check(1, CHECK_0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   557
    stack->alloc(wordSize);
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
  if (entry->is_volatile()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   561
    switch (entry->flag_state()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   562
    case ctos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   563
      SET_LOCALS_INT(object->char_field_acquire(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   564
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   565
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   566
    case btos:
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   567
    case ztos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   568
      SET_LOCALS_INT(object->byte_field_acquire(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   569
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   570
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   571
    case stos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   572
      SET_LOCALS_INT(object->short_field_acquire(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   573
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   574
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   575
    case itos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   576
      SET_LOCALS_INT(object->int_field_acquire(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   577
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   578
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   579
    case ltos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   580
      SET_LOCALS_LONG(object->long_field_acquire(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   581
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   582
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   583
    case ftos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   584
      SET_LOCALS_FLOAT(object->float_field_acquire(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   585
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   586
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   587
    case dtos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   588
      SET_LOCALS_DOUBLE(object->double_field_acquire(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   589
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   590
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   591
    case atos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   592
      SET_LOCALS_OBJECT(object->obj_field_acquire(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   593
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   594
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   595
    default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   596
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   597
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   598
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   599
  else {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   600
    switch (entry->flag_state()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   601
    case ctos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   602
      SET_LOCALS_INT(object->char_field(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   603
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   604
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   605
    case btos:
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 36181
diff changeset
   606
    case ztos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   607
      SET_LOCALS_INT(object->byte_field(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   608
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   609
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   610
    case stos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   611
      SET_LOCALS_INT(object->short_field(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   612
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   613
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   614
    case itos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   615
      SET_LOCALS_INT(object->int_field(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   616
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   617
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   618
    case ltos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   619
      SET_LOCALS_LONG(object->long_field(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   620
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   621
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   622
    case ftos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   623
      SET_LOCALS_FLOAT(object->float_field(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   624
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   625
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   626
    case dtos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   627
      SET_LOCALS_DOUBLE(object->double_field(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   628
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   629
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   630
    case atos:
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   631
      SET_LOCALS_OBJECT(object->obj_field(entry->f2_as_index()), 0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   632
      break;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   633
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   634
    default:
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   635
      ShouldNotReachHere();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   636
    }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   637
  }
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   638
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   639
  // No deoptimized frames on the stack
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   640
  return 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   641
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   642
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   643
int CppInterpreter::empty_entry(Method* method, intptr_t UNUSED, TRAPS) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   644
  JavaThread *thread = (JavaThread *) THREAD;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   645
  ZeroStack *stack = thread->zero_stack();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   646
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   647
  // Drop into the slow path if we need a safepoint check
47906
0ad8a90268a7 8191333: Zero variant broken after 8189941
glaubitz
parents: 47687
diff changeset
   648
  if (SafepointMechanism::poll(THREAD)) {
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   649
    return normal_entry(method, 0, THREAD);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   650
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   651
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   652
  // Pop our parameters
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   653
  stack->set_sp(stack->sp() + method->size_of_parameters());
5427
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   654
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   655
  // No deoptimized frames on the stack
08c6b2b940f7 6951784: Zero deoptimizer changes
twisti
parents: 5418
diff changeset
   656
  return 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   657
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   658
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   659
// The new slots will be inserted before slot insert_before.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   660
// Slots < insert_before will have the same slot number after the insert.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   661
// Slots >= insert_before will become old_slot + num_slots.
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   662
void CppInterpreter::insert_vmslots(int insert_before, int num_slots, TRAPS) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   663
  JavaThread *thread = (JavaThread *) THREAD;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   664
  ZeroStack *stack = thread->zero_stack();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   665
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   666
  // Allocate the space
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   667
  stack->overflow_check(num_slots, CHECK);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   668
  stack->alloc(num_slots * wordSize);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   669
  intptr_t *vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   670
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   671
  // Shuffle everything up
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   672
  for (int i = 0; i < insert_before; i++)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   673
    SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i + num_slots), i);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   674
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   675
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   676
void CppInterpreter::remove_vmslots(int first_slot, int num_slots, TRAPS) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   677
  JavaThread *thread = (JavaThread *) THREAD;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   678
  ZeroStack *stack = thread->zero_stack();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   679
  intptr_t *vmslots = stack->sp();
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   680
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   681
  // Move everything down
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   682
  for (int i = first_slot - 1; i >= 0; i--)
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   683
    SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i + num_slots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   684
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   685
  // Deallocate the space
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   686
  stack->set_sp(stack->sp() + num_slots);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   687
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   688
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   689
BasicType CppInterpreter::result_type_of_handle(oop method_handle) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   690
  oop method_type = java_lang_invoke_MethodHandle::type(method_handle);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   691
  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
   692
  return java_lang_Class::as_BasicType(return_type, (Klass* *) NULL);
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   693
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   694
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   695
intptr_t* CppInterpreter::calculate_unwind_sp(ZeroStack* stack,
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   696
                                              oop method_handle) {
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   697
  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
   698
  int argument_slots = java_lang_invoke_MethodType::ptype_slot_count(method_type);
9136
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   699
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   700
  return stack->sp() + argument_slots;
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   701
}
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   702
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   703
IRT_ENTRY(void, CppInterpreter::throw_exception(JavaThread* thread,
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   704
                                                Symbol*     name,
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   705
                                                char*       message))
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   706
  THROW_MSG(name, message);
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   707
IRT_END
94ebba447157 7035870: JSR 292: Zero support
twisti
parents: 8725
diff changeset
   708
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   709
InterpreterFrame *InterpreterFrame::build(Method* const method, TRAPS) {
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   710
  JavaThread *thread = (JavaThread *) THREAD;
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   711
  ZeroStack *stack = thread->zero_stack();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   712
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   713
  // Calculate the size of the frame we'll build, including
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   714
  // any adjustments to the caller's frame that we'll make.
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   715
  int extra_locals  = 0;
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   716
  int monitor_words = 0;
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   717
  int stack_words   = 0;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   718
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   719
  if (!method->is_native()) {
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   720
    extra_locals = method->max_locals() - method->size_of_parameters();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   721
    stack_words  = method->max_stack();
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   722
  }
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   723
  if (method->is_synchronized()) {
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   724
    monitor_words = frame::interpreter_frame_monitor_size();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   725
  }
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   726
  stack->overflow_check(
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   727
    extra_locals + header_words + monitor_words + stack_words, CHECK_NULL);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   728
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   729
  // Adjust the caller's stack frame to accomodate any additional
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   730
  // local variables we have contiguously with our parameters.
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   731
  for (int i = 0; i < extra_locals; i++)
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   732
    stack->push(0);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   733
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   734
  intptr_t *locals;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   735
  if (method->is_native())
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   736
    locals = stack->sp() + (method->size_of_parameters() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   737
  else
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   738
    locals = stack->sp() + (method->max_locals() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   739
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   740
  stack->push(0); // next_frame, filled in later
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   741
  intptr_t *fp = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   742
  assert(fp - stack->sp() == next_frame_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   743
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   744
  stack->push(INTERPRETER_FRAME);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   745
  assert(fp - stack->sp() == frame_type_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   746
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   747
  interpreterState istate =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   748
    (interpreterState) stack->alloc(sizeof(BytecodeInterpreter));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   749
  assert(fp - stack->sp() == istate_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   750
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   751
  istate->set_locals(locals);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   752
  istate->set_method(method);
38074
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 38063
diff changeset
   753
  istate->set_mirror(method->method_holder()->java_mirror());
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   754
  istate->set_self_link(istate);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   755
  istate->set_prev_link(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   756
  istate->set_thread(thread);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   757
  istate->set_bcp(method->is_native() ? NULL : method->code_base());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   758
  istate->set_constants(method->constants()->cache());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   759
  istate->set_msg(BytecodeInterpreter::method_entry);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   760
  istate->set_oop_temp(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   761
  istate->set_mdx(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   762
  istate->set_callee(NULL);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   763
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   764
  istate->set_monitor_base((BasicObjectLock *) stack->sp());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   765
  if (method->is_synchronized()) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   766
    BasicObjectLock *monitor =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   767
      (BasicObjectLock *) stack->alloc(monitor_words * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   768
    oop object;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   769
    if (method->is_static())
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 7397
diff changeset
   770
      object = method->constants()->pool_holder()->java_mirror();
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   771
    else
26142
038e0f01b4a9 8055231: ZERO variant build is broken
coleenp
parents: 25950
diff changeset
   772
      object = (oop) (void*)locals[0];
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   773
    monitor->set_obj(object);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   774
  }
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   775
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   776
  istate->set_stack_base(stack->sp());
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   777
  istate->set_stack(stack->sp() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   778
  if (stack_words)
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   779
    stack->alloc(stack_words * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   780
  istate->set_stack_limit(stack->sp() - 1);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   781
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   782
  return (InterpreterFrame *) fp;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   783
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   784
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   785
InterpreterFrame *InterpreterFrame::build(int size, TRAPS) {
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   786
  ZeroStack *stack = ((JavaThread *) THREAD)->zero_stack();
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   787
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   788
  int size_in_words = size >> LogBytesPerWord;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   789
  assert(size_in_words * wordSize == size, "unaligned");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   790
  assert(size_in_words >= header_words, "too small");
5335
4319cb12ddfe 6941224: Improved stack overflow handling for Zero
twisti
parents: 5229
diff changeset
   791
  stack->overflow_check(size_in_words, CHECK_NULL);
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   792
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   793
  stack->push(0); // next_frame, filled in later
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   794
  intptr_t *fp = stack->sp();
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   795
  assert(fp - stack->sp() == next_frame_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   796
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   797
  stack->push(INTERPRETER_FRAME);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   798
  assert(fp - stack->sp() == frame_type_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   799
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   800
  interpreterState istate =
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   801
    (interpreterState) stack->alloc(sizeof(BytecodeInterpreter));
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   802
  assert(fp - stack->sp() == istate_off, "should be");
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   803
  istate->set_self_link(NULL); // mark invalid
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   804
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   805
  stack->alloc((size_in_words - header_words) * wordSize);
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   806
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   807
  return (InterpreterFrame *) fp;
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   808
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   809
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 19336
diff changeset
   810
address CppInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) {
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   811
  ShouldNotCallThis();
19336
ddceb0657500 8022956: Clang: enable return type warnings on BSD
twisti
parents: 17314
diff changeset
   812
  return NULL;
4013
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   813
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   814
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   815
address CppInterpreter::deopt_entry(TosState state, int length) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   816
  return NULL;
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
// Helper for figuring out if frames are interpreter frames
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   820
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   821
bool CppInterpreter::contains(address pc) {
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   822
  return false; // make frame::print_value_on work
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   823
}
b154310845de 6890308: integrate zero assembler hotspot changes
never
parents:
diff changeset
   824
#endif // CC_INTERP