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