hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp
author goetz
Mon, 07 Dec 2015 15:42:47 +0100
changeset 35112 b3c4347bb751
parent 33160 c59f1676d27e
permissions -rw-r--r--
8144466: ppc64: fix argument passing through opto stubs. Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
25950
b5c40ed1d349 8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents: 24018
diff changeset
     2
 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2534
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2534
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2534
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 13743
diff changeset
    26
#include "asm/macroAssembler.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "interpreter/bytecodeHistogram.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "interpreter/cppInterpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "interpreter/interpreterGenerator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "interpreter/interpreterRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "oops/arrayOop.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    33
#include "oops/methodData.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    34
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "prims/jvmtiExport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "prims/jvmtiThreadState.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#include "runtime/arguments.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
#include "runtime/deoptimization.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    40
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    41
#include "runtime/interfaceSupport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    42
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    43
#include "runtime/stubRoutines.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    44
#include "runtime/synchronizer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    45
#include "runtime/timer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    46
#include "runtime/vframeArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    47
#include "utilities/debug.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14745
diff changeset
    48
#include "utilities/macros.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    49
#ifdef SHARK
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    50
#include "shark/shark_globals.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    51
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
#ifdef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// Routine exists to make tracebacks look decent in debugger
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// while we are recursed in the frame manager/c++ interpreter.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
// We could use an address in the frame manager but having
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
// frames look natural in the debugger is a plus.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
extern "C" void RecursiveInterpreterActivation(interpreterState istate )
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
#define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
#define STATE(field_name) (Address(state, byte_offset_of(BytecodeInterpreter, field_name)))
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    69
// default registers for state and sender_sp
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    70
// state and sender_sp are the same on 32bit because we have no choice.
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    71
// state could be rsi on 64bit but it is an arg reg and not callee save
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    72
// so r13 is better choice.
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    73
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    74
const Register state = NOT_LP64(rsi) LP64_ONLY(r13);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    75
const Register sender_sp_on_entry = NOT_LP64(rsi) LP64_ONLY(r13);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    76
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
// NEEDED for JVMTI?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
// address AbstractInterpreter::_remove_activation_preserving_args_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
static address unctrap_frame_manager_entry  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
static address deopt_frame_manager_return_atos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
static address deopt_frame_manager_return_btos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
static address deopt_frame_manager_return_itos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
static address deopt_frame_manager_return_ltos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
static address deopt_frame_manager_return_ftos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
static address deopt_frame_manager_return_dtos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
static address deopt_frame_manager_return_vtos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
int AbstractInterpreter::BasicType_as_index(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  int i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    case T_BOOLEAN: i = 0; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    case T_CHAR   : i = 1; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    case T_BYTE   : i = 2; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    case T_SHORT  : i = 3; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    case T_INT    : i = 4; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    case T_VOID   : i = 5; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    case T_FLOAT  : i = 8; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    case T_LONG   : i = 9; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    case T_DOUBLE : i = 6; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    case T_OBJECT : // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    case T_ARRAY  : i = 7; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    default       : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  return i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
// Is this pc anywhere within code owned by the interpreter?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
// This only works for pc that might possibly be exposed to frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
// walkers. It clearly misses all of the actual c++ interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
// implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
bool CppInterpreter::contains(address pc)            {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    return (_code->contains(pc) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
            pc == CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
address CppInterpreterGenerator::generate_result_handler_for(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    case T_BOOLEAN: __ c2bool(rax);            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    case T_CHAR   : __ andl(rax, 0xFFFF);      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    case T_BYTE   : __ sign_extend_byte (rax); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    case T_SHORT  : __ sign_extend_short(rax); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    case T_VOID   : // fall thru
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    case T_LONG   : // fall thru
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    case T_INT    : /* nothing to do */        break;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   130
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    case T_DOUBLE :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    case T_FLOAT  :
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   133
      {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   134
        const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   135
        __ pop(t);                            // remove return address first
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
        // Must return a result for interpreter or compiler. In SSE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
        // mode, results are returned in xmm0 and the FPU stack must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
        // be empty.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
        if (type == T_FLOAT && UseSSE >= 1) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   140
#ifndef _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
          // Load ST0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
          __ fld_d(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
          // Store as float and empty fpu stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
          __ fstp_s(Address(rsp, 0));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   145
#endif // !_LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
          // and reload
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
          __ movflt(xmm0, Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
        } else if (type == T_DOUBLE && UseSSE >= 2 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
          __ movdbl(xmm0, Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
          // restore ST0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
          __ fld_d(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
        // and pop the temp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   155
        __ addptr(rsp, 2 * wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   156
        __ push(t);                            // restore return address
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    case T_OBJECT :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
      // retrieve result from frame
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   161
      __ movptr(rax, STATE(_oop_temp));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
      // and verify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
      __ verify_oop(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    default       : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  __ ret(0);                                   // return from result handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
// tosca based result to c++ interpreter stack based result.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
// Result goes to top of native stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
#undef EXTEND  // SHOULD NOT BE NEEDED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
address CppInterpreterGenerator::generate_tosca_to_stack_converter(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  // A result is in the tosca (abi result) from either a native method call or compiled
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // code. Place this result on the java expression stack so C++ interpreter can use it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   181
  __ pop(t);                            // remove return address first
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    case T_VOID:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
       break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
#ifdef EXTEND
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
      __ c2bool(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
#endif
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   189
      __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    case T_CHAR   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
#ifdef EXTEND
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
      __ andl(rax, 0xFFFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
#endif
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   195
      __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    case T_BYTE   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
#ifdef EXTEND
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      __ sign_extend_byte (rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
#endif
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   201
      __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    case T_SHORT  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
#ifdef EXTEND
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
      __ sign_extend_short(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
#endif
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   207
      __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    case T_LONG    :
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   210
      __ push(rdx);                             // pushes useless junk on 64bit
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   211
      __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    case T_INT    :
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   214
      __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    case T_FLOAT  :
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   217
      // Result is in ST(0)/xmm0
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   218
      __ subptr(rsp, wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
      if ( UseSSE < 1) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   220
        __ fstp_s(Address(rsp, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
        __ movflt(Address(rsp, 0), xmm0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    case T_DOUBLE  :
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   226
      __ subptr(rsp, 2*wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
      if ( UseSSE < 2 ) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   228
        __ fstp_d(Address(rsp, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
        __ movdbl(Address(rsp, 0), xmm0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    case T_OBJECT :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
      __ verify_oop(rax);                      // verify it
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   235
      __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    default       : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  __ jmp(t);                                   // return from result handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
address CppInterpreterGenerator::generate_stack_to_stack_converter(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // A result is in the java expression stack of the interpreted method that has just
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // returned. Place this result on the java expression stack of the caller.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  //
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   247
  // The current interpreter activation in rsi/r13 is for the method just returning its
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  // result. So we know that the result of this method is on the top of the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  // execution stack (which is pre-pushed) and will be return to the top of the caller
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  // stack. The top of the callers stack is the bottom of the locals of the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // activation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  // Because of the way activation are managed by the frame manager the value of rsp is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  // below both the stack top of the current activation and naturally the stack top
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  // of the calling activation. This enable this routine to leave the return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  // to the frame manager on the stack and do a vanilla return.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  //
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   257
  // On entry: rsi/r13 - interpreter state of activation returning a (potential) result
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   258
  // On Return: rsi/r13 - unchanged
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  //            rax - new stack top for caller activation (i.e. activation in _prev_link)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  // Can destroy rdx, rcx.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    case T_VOID:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   268
      __ movptr(rax, STATE(_locals));                                   // pop parameters get new stack value
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   269
      __ addptr(rax, wordSize);                                         // account for prepush before we return
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    case T_FLOAT  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    case T_CHAR   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    case T_BYTE   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    case T_SHORT  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    case T_INT    :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
      // 1 word result
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   278
      __ movptr(rdx, STATE(_stack));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   279
      __ movptr(rax, STATE(_locals));                                   // address for result
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
      __ movl(rdx, Address(rdx, wordSize));                             // get result
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   281
      __ movptr(Address(rax, 0), rdx);                                  // and store it
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    case T_LONG    :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
    case T_DOUBLE  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
      // return top two words on current expression stack to caller's expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
      // The caller's expression stack is adjacent to the current frame manager's intepretState
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
      // except we allocated one extra word for this intepretState so we won't overwrite it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
      // when we return a two word result.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   290
      __ movptr(rax, STATE(_locals));                                   // address for result
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   291
      __ movptr(rcx, STATE(_stack));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   292
      __ subptr(rax, wordSize);                                         // need addition word besides locals[0]
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   293
      __ movptr(rdx, Address(rcx, 2*wordSize));                         // get result word (junk in 64bit)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   294
      __ movptr(Address(rax, wordSize), rdx);                           // and store it
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   295
      __ movptr(rdx, Address(rcx, wordSize));                           // get result word
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   296
      __ movptr(Address(rax, 0), rdx);                                  // and store it
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    case T_OBJECT :
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   299
      __ movptr(rdx, STATE(_stack));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   300
      __ movptr(rax, STATE(_locals));                                   // address for result
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   301
      __ movptr(rdx, Address(rdx, wordSize));                           // get result
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
      __ verify_oop(rdx);                                               // verify it
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   303
      __ movptr(Address(rax, 0), rdx);                                  // and store it
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    default       : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
address CppInterpreterGenerator::generate_stack_to_native_abi_converter(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  // A result is in the java expression stack of the interpreted method that has just
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  // returned. Place this result in the native abi that the caller expects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  // Similar to generate_stack_to_stack_converter above. Called at a similar time from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  // frame manager execept in this situation the caller is native code (c1/c2/call_stub)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  // and so rather than return result onto caller's java expression stack we return the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  // result in the expected location based on the native abi.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   319
  // On entry: rsi/r13 - interpreter state of activation returning a (potential) result
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   320
  // On Return: rsi/r13 - unchanged
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  // Other registers changed [rax/rdx/ST(0) as needed for the result returned]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    case T_VOID:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
       break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    case T_CHAR   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    case T_BYTE   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    case T_SHORT  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    case T_INT    :
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   332
      __ movptr(rdx, STATE(_stack));                                    // get top of stack
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
      __ movl(rax, Address(rdx, wordSize));                             // get result word 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    case T_LONG    :
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   336
      __ movptr(rdx, STATE(_stack));                                    // get top of stack
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   337
      __ movptr(rax, Address(rdx, wordSize));                           // get result low word
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   338
      NOT_LP64(__ movl(rdx, Address(rdx, 2*wordSize));)                 // get result high word
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    case T_FLOAT  :
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   341
      __ movptr(rdx, STATE(_stack));                                    // get top of stack
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
      if ( UseSSE >= 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
        __ movflt(xmm0, Address(rdx, wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
        __ fld_s(Address(rdx, wordSize));                               // pushd float result
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    case T_DOUBLE  :
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   349
      __ movptr(rdx, STATE(_stack));                                    // get top of stack
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
      if ( UseSSE > 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
        __ movdbl(xmm0, Address(rdx, wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
        __ fld_d(Address(rdx, wordSize));                               // push double result
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    case T_OBJECT :
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   357
      __ movptr(rdx, STATE(_stack));                                    // get top of stack
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   358
      __ movptr(rax, Address(rdx, wordSize));                           // get result word 1
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
      __ verify_oop(rax);                                               // verify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
    default       : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 17875
diff changeset
   367
address CppInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  // make it look good in the debugger
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  return CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
address CppInterpreter::deopt_entry(TosState state, int length) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  address ret = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  if (length != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    switch (state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      case atos: ret = deopt_frame_manager_return_atos; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
      case btos: ret = deopt_frame_manager_return_btos; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
      case ctos:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
      case stos:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
      case itos: ret = deopt_frame_manager_return_itos; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
      case ltos: ret = deopt_frame_manager_return_ltos; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
      case ftos: ret = deopt_frame_manager_return_ftos; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
      case dtos: ret = deopt_frame_manager_return_dtos; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
      case vtos: ret = deopt_frame_manager_return_vtos; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
    ret = unctrap_frame_manager_entry;  // re-execute the bytecode ( e.g. uncommon trap)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  assert(ret != NULL, "Not initialized");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  return ret;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
// C++ Interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
void CppInterpreterGenerator::generate_compute_interpreter_state(const Register state,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
                                                                 const Register locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
                                                                 const Register sender_sp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
                                                                 bool native) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  // On entry the "locals" argument points to locals[0] (or where it would be in case no locals in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  // a static method). "state" contains any previous frame manager state which we must save a link
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  // to in the newly generated state object. On return "state" is a pointer to the newly allocated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  // state object. We must allocate and initialize a new interpretState object and the method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  // expression stack. Because the returned result (if any) of the method will be placed on the caller's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  // expression stack and this will overlap with locals[0] (and locals[1] if double/long) we must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  // be sure to leave space on the caller's stack so that this result will not overwrite values when
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  // locals[0] and locals[1] do not exist (and in fact are return address and saved rbp). So when
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  // we are non-native we in essence ensure that locals[0-1] exist. We play an extra trick in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  // non-product builds and initialize this last local with the previous interpreterState as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  // this makes things look real nice in the debugger.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  // State on entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  // Assumes locals == &locals[0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  // Assumes state == any previous frame manager state (assuming call path from c++ interpreter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  // Assumes rax = return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  // rcx == senders_sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  // rbx == method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  // Modifies rcx, rdx, rax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  // Returns:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  // state == address of new interpreterState
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  // rsp == bottom of method's expression stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   422
  const Address const_offset      (rbx, Method::const_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  // On entry sp is the sender's sp. This includes the space for the arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  // that the sender pushed. If the sender pushed no args (a static) and the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  // caller returns a long then we need two words on the sender's stack which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  // are not present (although when we return a restore full size stack the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  // space will be present). If we didn't allocate two words here then when
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  // we "push" the result of the caller's stack we would overwrite the return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  // address and the saved rbp. Not good. So simply allocate 2 words now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  // just to be safe. This is the "static long no_params() method" issue.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  // See Lo.java for a testcase.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  // We don't need this for native calls because they return result in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  // register and the stack is expanded in the caller before we store
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  // the results on the stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  if (!native) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
#ifdef PRODUCT
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   440
    __ subptr(rsp, 2*wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
#else /* PRODUCT */
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   442
    __ push((int32_t)NULL_WORD);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   443
    __ push(state);                         // make it look like a real argument
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
#endif /* PRODUCT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  // Now that we are assure of space for stack result, setup typical linkage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   449
  __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  __ enter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   452
  __ mov(rax, state);                                  // save current state
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   453
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   454
  __ lea(rsp, Address(rsp, -(int)sizeof(BytecodeInterpreter)));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   455
  __ mov(state, rsp);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   456
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   457
  // rsi/r13 == state/locals rax == prevstate
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  // initialize the "shadow" frame so that use since C++ interpreter not directly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  // recursive. Simpler to recurse but we can't trim expression stack as we call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  // new methods.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   462
  __ movptr(STATE(_locals), locals);                    // state->_locals = locals()
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   463
  __ movptr(STATE(_self_link), state);                  // point to self
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   464
  __ movptr(STATE(_prev_link), rax);                    // state->_link = state on entry (NULL or previous state)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   465
  __ movptr(STATE(_sender_sp), sender_sp);              // state->_sender_sp = sender_sp
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   466
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   467
  __ movptr(STATE(_thread), r15_thread);                // state->_bcp = codes()
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   468
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  __ get_thread(rax);                                   // get vm's javathread*
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   470
  __ movptr(STATE(_thread), rax);                       // state->_bcp = codes()
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   471
#endif // _LP64
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   472
  __ movptr(rdx, Address(rbx, Method::const_offset())); // get constantMethodOop
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   473
  __ lea(rdx, Address(rdx, ConstMethod::codes_offset())); // get code base
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  if (native) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   475
    __ movptr(STATE(_bcp), (int32_t)NULL_WORD);         // state->_bcp = NULL
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  } else {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   477
    __ movptr(STATE(_bcp), rdx);                        // state->_bcp = codes()
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   479
  __ xorptr(rdx, rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   480
  __ movptr(STATE(_oop_temp), rdx);                     // state->_oop_temp = NULL (only really needed for native)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   481
  __ movptr(STATE(_mdx), rdx);                          // state->_mdx = NULL
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   482
  __ movptr(rdx, Address(rbx, Method::const_offset()));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   483
  __ movptr(rdx, Address(rdx, ConstMethod::constants_offset()));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   484
  __ movptr(rdx, Address(rdx, ConstantPool::cache_offset_in_bytes()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   485
  __ movptr(STATE(_constants), rdx);                    // state->_constants = constants()
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   486
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   487
  __ movptr(STATE(_method), rbx);                       // state->_method = method()
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   488
  __ movl(STATE(_msg), (int32_t) BytecodeInterpreter::method_entry);   // state->_msg = initial method entry
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   489
  __ movptr(STATE(_result._to_call._callee), (int32_t) NULL_WORD); // state->_result._to_call._callee_callee = NULL
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   490
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   491
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   492
  __ movptr(STATE(_monitor_base), rsp);                 // set monitor block bottom (grows down) this would point to entry [0]
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
                                                        // entries run from -1..x where &monitor[x] ==
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
    // Must not attempt to lock method until we enter interpreter as gc won't be able to find the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
    // initial frame. However we allocate a free monitor so we don't have to shuffle the expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    // immediately.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
    // synchronize method
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   501
    const Address access_flags      (rbx, Method::access_flags_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
    const int entry_size            = frame::interpreter_frame_monitor_size() * wordSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
    Label not_synced;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
    __ movl(rax, access_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
    __ testl(rax, JVM_ACC_SYNCHRONIZED);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
    __ jcc(Assembler::zero, not_synced);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
    // Allocate initial monitor and pre initialize it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
    // get synchronization object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    Label done;
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 9636
diff changeset
   513
    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
    __ movl(rax, access_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    __ testl(rax, JVM_ACC_STATIC);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   516
    __ movptr(rax, Address(locals, 0));                   // get receiver (assume this is frequent case)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    __ jcc(Assembler::zero, done);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   518
    __ movptr(rax, Address(rbx, Method::const_offset()));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   519
    __ movptr(rax, Address(rax, ConstMethod::constants_offset()));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   520
    __ movptr(rax, Address(rax, ConstantPool::pool_holder_offset_in_bytes()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   521
    __ movptr(rax, Address(rax, mirror_offset));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
    __ bind(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    // add space for monitor & lock
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   524
    __ subptr(rsp, entry_size);                                           // add space for a monitor entry
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   525
    __ movptr(Address(rsp, BasicObjectLock::obj_offset_in_bytes()), rax); // store object
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
    __ bind(not_synced);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   529
  __ movptr(STATE(_stack_base), rsp);                                     // set expression stack base ( == &monitors[-count])
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  if (native) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   531
    __ movptr(STATE(_stack), rsp);                                        // set current expression stack tos
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   532
    __ movptr(STATE(_stack_limit), rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  } else {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   534
    __ subptr(rsp, wordSize);                                             // pre-push stack
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   535
    __ movptr(STATE(_stack), rsp);                                        // set current expression stack tos
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
    // compute full expression stack limit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13743
diff changeset
   539
    __ movptr(rdx, Address(rbx, Method::const_offset()));
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13743
diff changeset
   540
    __ load_unsigned_short(rdx, Address(rdx, ConstMethod::max_stack_offset())); // get size of expression stack in words
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   541
    __ negptr(rdx);                                                       // so we can subtract in next step
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    // Allocate expression stack
17875
9d4aa49a1d76 8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents: 17000
diff changeset
   543
    __ lea(rsp, Address(rsp, rdx, Address::times_ptr, -Method::extra_stack_words()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   544
    __ movptr(STATE(_stack_limit), rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   547
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   548
  // Make sure stack is properly aligned and sized for the abi
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   549
  __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1896
diff changeset
   550
  __ andptr(rsp, -16); // must be 16 byte boundary (see amd64 ABI)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   551
#endif // _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   552
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   553
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   554
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
// Helpers for commoning out cases in the various type of method entries.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
// increment invocation count & check for overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
// Note: checking for negative value instead of overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
//       so we have a 'sticky' overflow test
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
// rbx,: method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
// rcx: invocation counter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) {
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   569
  Label done;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   570
  const Address invocation_counter(rax,
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   571
                MethodCounters::invocation_counter_offset() +
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   572
                InvocationCounter::counter_offset());
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   573
  const Address backedge_counter  (rax,
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   574
                MethodCounters::backedge_counter_offset() +
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   575
                InvocationCounter::counter_offset());
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   576
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   577
  __ get_method_counters(rbx, rax, done);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   578
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   579
  if (ProfileInterpreter) {
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   580
    __ incrementl(Address(rax,
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   581
            MethodCounters::interpreter_invocation_counter_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  // Update standard invocation counters
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   584
  __ movl(rcx, invocation_counter);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  __ increment(rcx, InvocationCounter::count_increment);
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   586
  __ movl(invocation_counter, rcx);             // save invocation count
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   587
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   588
  __ movl(rax, backedge_counter);               // load backedge counter
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  __ andl(rax, InvocationCounter::count_mask_value);  // mask out the status bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  __ addl(rcx, rax);                            // add both counters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  // profile_method is non-null only for interpreted method so
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  // profile_method != NULL == !native_call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
  // BytecodeInterpreter only calls for native so code is elided.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  __ cmp32(rcx,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
           ExternalAddress((address)&InvocationCounter::InterpreterInvocationLimit));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  __ jcc(Assembler::aboveEqual, *overflow);
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16624
diff changeset
   600
  __ bind(done);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
void InterpreterGenerator::generate_counter_overflow(Label* do_continue) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  // C++ interpreter on entry
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   606
  // rsi/r13 - new interpreter state pointer
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
  // rbp - interpreter frame pointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  // rbx - method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  // On return (i.e. jump to entry_point) [ back to invocation of interpreter ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  // rbx, - method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  // rcx - rcvr (assuming there is one)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  // top of stack return address of interpreter caller
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  // rsp - sender_sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  // C++ interpreter only
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   617
  // rsi/r13 - previous interpreter state pointer
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  // InterpreterRuntime::frequency_counter_overflow takes one argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  // indicating if the counter overflow occurs at a backwards branch (non-NULL bcp).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  // The call returns the address of the verified entry point for the method or NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  // if the compilation did not complete (either went background or bailed out).
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   623
  __ movptr(rax, (int32_t)false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  // for c++ interpreter can rsi really be munged?
1896
cce23a9ff495 6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents: 1217
diff changeset
   627
  __ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter)));                               // restore state
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   628
  __ movptr(rbx, Address(state, byte_offset_of(BytecodeInterpreter, _method)));            // restore method
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   629
  __ movptr(rdi, Address(state, byte_offset_of(BytecodeInterpreter, _locals)));            // get locals pointer
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   630
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
  __ jmp(*do_continue, relocInfo::none);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
void InterpreterGenerator::generate_stack_overflow_check(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
  // see if we've got enough room on the stack for locals plus overhead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
  // the expression stack grows down incrementally, so the normal guard
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
  // page mechanism will work for that.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
  // Registers live on entry:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
  // Asm interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  // rdx: number of additional locals this frame needs (what we must check)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   644
  // rbx,: Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  // C++ Interpreter
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   647
  // rsi/r13: previous interpreter frame state object
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  // rdi: &locals[0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  // rcx: # of locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  // rdx: number of additional locals this frame needs (what we must check)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   651
  // rbx: Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
  // destroyed on exit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  // rax,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
  // NOTE:  since the additional locals are also always pushed (wasn't obvious in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
  // generate_method_entry) so the guard should work for them too.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  const int entry_size    = frame::interpreter_frame_monitor_size() * wordSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
  // total overhead size: entry_size + (saved rbp, thru expr stack bottom).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
  // be sure to change this if you add/subtract anything to/from the overhead area
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
  const int overhead_size = (int)sizeof(BytecodeInterpreter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
  const int page_size = os::vm_page_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
  Label after_frame_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
  // compute rsp as if this were going to be the last frame on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
  // the stack before the red zone
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  Label after_frame_check_pop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
  // save rsi == caller's bytecode ptr (c++ previous interp. state)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
  // QQQ problem here?? rsi overload????
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   677
  __ push(state);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   678
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   679
  const Register thread = LP64_ONLY(r15_thread) NOT_LP64(rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   680
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   681
  NOT_LP64(__ get_thread(thread));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
  const Address stack_base(thread, Thread::stack_base_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
  const Address stack_size(thread, Thread::stack_size_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
  // locals + overhead, in bytes
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13743
diff changeset
   687
  // Always give one monitor to allow us to start interp if sync method.
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13743
diff changeset
   688
  // Any additional monitors need a check when moving the expression stack
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13743
diff changeset
   689
  const int one_monitor = frame::interpreter_frame_monitor_size() * wordSize;
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13743
diff changeset
   690
  __ movptr(rax, Address(rbx, Method::const_offset()));
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13743
diff changeset
   691
  __ load_unsigned_short(rax, Address(rax, ConstMethod::max_stack_offset())); // get size of expression stack in words
17875
9d4aa49a1d76 8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents: 17000
diff changeset
   692
  __ lea(rax, Address(noreg, rax, Interpreter::stackElementScale(), one_monitor+Method::extra_stack_words()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   693
  __ lea(rax, Address(rax, rdx, Interpreter::stackElementScale(), overhead_size));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  Label stack_base_okay, stack_size_okay;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
  // verify that thread stack base is non-zero
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   698
  __ cmpptr(stack_base, (int32_t)0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  __ jcc(Assembler::notEqual, stack_base_okay);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
  __ stop("stack base is zero");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
  __ bind(stack_base_okay);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
  // verify that thread stack size is non-zero
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   703
  __ cmpptr(stack_size, (int32_t)0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  __ jcc(Assembler::notEqual, stack_size_okay);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
  __ stop("stack size is zero");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
  __ bind(stack_size_okay);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
  // Add stack base to locals and subtract stack size
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   710
  __ addptr(rax, stack_base);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   711
  __ subptr(rax, stack_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
  // We should have a magic number here for the size of the c++ interpreter frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
  // We can't actually tell this ahead of time. The debug version size is around 3k
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  // product is 1k and fastdebug is 4k
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  const int slop = 6 * K;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  // Use the maximum number of pages we might bang.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  const int max_pages = StackShadowPages > (StackRedPages+StackYellowPages) ? StackShadowPages :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
                                                                              (StackRedPages+StackYellowPages);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
  // Only need this if we are stack banging which is temporary while
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
  // we're debugging.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   723
  __ addptr(rax, slop + 2*max_pages * page_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
  // check against the current stack bottom
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   726
  __ cmpptr(rsp, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
  __ jcc(Assembler::above, after_frame_check_pop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   729
  __ pop(state);  //  get c++ prev state.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
     // throw exception return address becomes throwing pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_StackOverflowError));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
  // all done with frame size check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
  __ bind(after_frame_check_pop);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   736
  __ pop(state);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
  __ bind(after_frame_check);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
// Find preallocated  monitor and lock method (C++ interpreter)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   742
// rbx - Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
//
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33070
diff changeset
   744
void CppInterpreterGenerator::lock_method() {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   745
  // assumes state == rsi/r13 == pointer to current interpreterState
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   746
  // minimally destroys rax, rdx|c_rarg1, rdi
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  // synchronize method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  const int entry_size            = frame::interpreter_frame_monitor_size() * wordSize;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   750
  const Address access_flags      (rbx, Method::access_flags_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   752
  const Register monitor  = NOT_LP64(rdx) LP64_ONLY(c_rarg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   753
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
  // find initial monitor i.e. monitors[-1]
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   755
  __ movptr(monitor, STATE(_monitor_base));                                   // get monitor bottom limit
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   756
  __ subptr(monitor, entry_size);                                             // point to initial monitor
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
    __ movl(rax, access_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
    __ testl(rax, JVM_ACC_SYNCHRONIZED);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
    __ jcc(Assembler::notZero, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
    __ stop("method doesn't need synchronization");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
  // get synchronization object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
  { Label done;
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 9636
diff changeset
   769
    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
    __ movl(rax, access_flags);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   771
    __ movptr(rdi, STATE(_locals));                                     // prepare to get receiver (assume common case)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
    __ testl(rax, JVM_ACC_STATIC);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   773
    __ movptr(rax, Address(rdi, 0));                                    // get receiver (assume this is frequent case)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
    __ jcc(Assembler::zero, done);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   775
    __ movptr(rax, Address(rbx, Method::const_offset()));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   776
    __ movptr(rax, Address(rax, ConstMethod::constants_offset()));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   777
    __ movptr(rax, Address(rax, ConstantPool::pool_holder_offset_in_bytes()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   778
    __ movptr(rax, Address(rax, mirror_offset));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
    __ bind(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
  { Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   783
    __ cmpptr(rax, Address(monitor, BasicObjectLock::obj_offset_in_bytes()));   // correct object?
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
    __ jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
    __ stop("wrong synchronization lobject");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
#endif // ASSERT
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   789
  // can destroy rax, rdx|c_rarg1, rcx, and (via call_VM) rdi!
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   790
  __ lock_object(monitor);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   793
address InterpreterGenerator::generate_Reference_get_entry(void) {
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14745
diff changeset
   794
#if INCLUDE_ALL_GCS
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   795
  if (UseG1GC) {
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   796
    // We need to generate have a routine that generates code to:
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   797
    //   * load the value in the referent field
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   798
    //   * passes that value to the pre-barrier.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   799
    //
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   800
    // In the case of G1 this will record the value of the
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   801
    // referent in an SATB buffer if marking is active.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   802
    // This will cause concurrent marking to mark the referent
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   803
    // field as live.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   804
    Unimplemented();
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   805
  }
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14745
diff changeset
   806
#endif // INCLUDE_ALL_GCS
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   807
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   808
  // If G1 is not enabled then attempt to go through the accessor entry point
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   809
  // Reference.get is an accessor
33070
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 25950
diff changeset
   810
  return NULL;
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   811
}
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8315
diff changeset
   812
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
// C++ Interpreter stub for calling a native method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
// This sets up a somewhat different looking stack for calling the native method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
// than the typical interpreter frame setup but still has the pointer to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
// an interpreter state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
address InterpreterGenerator::generate_native_entry(bool synchronized) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
  // determine code generation flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
  bool inc_counter  = UseCompiler || CountCompiledCalls;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   824
  // rbx: Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
  // rcx: receiver (unused)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   826
  // rsi/r13: previous interpreter state (if called from C++ interpreter) must preserve
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   827
  //      in any case. If called via c1/c2/call_stub rsi/r13 is junk (to use) but harmless
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
  //      to save/restore.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   831
  const Address access_flags      (rbx, Method::access_flags_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   833
  // rsi/r13 == state/locals rdi == prevstate
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
  const Register locals = rdi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
  // get parameter size (always needed)
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   837
  {
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   838
    const Address constMethod       (rbx, Method::const_offset());
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   839
    const Address size_of_parameters(rcx, ConstMethod::size_of_parameters_offset());
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   840
    __ movptr(rcx, constMethod);
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   841
    __ load_unsigned_short(rcx, size_of_parameters);
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   842
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   844
  // rbx: Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
  // rcx: size of parameters
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   846
  __ pop(rax);                                       // get return address
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
  // for natives the size of locals is zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  // compute beginning of parameters /locals
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14633
diff changeset
   850
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   851
  __ lea(locals, Address(rsp, rcx, Address::times_ptr, -wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
  // initialize fixed part of activation frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
  // Assumes rax = return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
  // allocate and initialize new interpreterState and method expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
  // IN(locals) ->  locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
  // IN(state) -> previous frame manager state (NULL from stub/c1/c2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
  // destroys rax, rcx, rdx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
  // OUT (state) -> new interpreterState
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
  // OUT(rsp) -> bottom of methods expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
  // save sender_sp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   865
  __ mov(rcx, sender_sp_on_entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
  // start with NULL previous state
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   867
  __ movptr(state, (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
  generate_compute_interpreter_state(state, locals, rcx, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
  { Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   872
    __ movptr(rax, STATE(_stack_base));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   873
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   874
    // duplicate the alignment rsp got after setting stack_base
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   875
    __ subptr(rax, frame::arg_reg_save_area_bytes); // windows
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1896
diff changeset
   876
    __ andptr(rax, -16); // must be 16 byte boundary (see amd64 ABI)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   877
#endif // _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   878
    __ cmpptr(rax, rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
    __ jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
    __ stop("broken stack frame setup in interpreter");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   885
  const Register unlock_thread = LP64_ONLY(r15_thread) NOT_LP64(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   886
  NOT_LP64(__ movptr(unlock_thread, STATE(_thread));) // get thread
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
  // Since at this point in the method invocation the exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  // would try to exit the monitor of synchronized methods which hasn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
  // been entered yet, we set the thread local variable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
  // _do_not_unlock_if_synchronized to true. The remove_activation will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
  // check this flag.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   893
  const Address do_not_unlock_if_synchronized(unlock_thread,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
        in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  __ movbool(do_not_unlock_if_synchronized, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
  // make sure method is native & not abstract
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
  __ movl(rax, access_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
    __ testl(rax, JVM_ACC_NATIVE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
    __ jcc(Assembler::notZero, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
    __ stop("tried to execute non-native method as native");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
  { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
    __ testl(rax, JVM_ACC_ABSTRACT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
    __ jcc(Assembler::zero, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
    __ stop("tried to execute abstract method in interpreter");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
  // increment invocation count & check for overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
  Label invocation_counter_overflow;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
  if (inc_counter) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
    generate_counter_incr(&invocation_counter_overflow, NULL, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
  Label continue_after_compile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
  __ bind(continue_after_compile);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
  bang_stack_shadow_pages(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
  // reset the _do_not_unlock_if_synchronized flag
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   929
  NOT_LP64(__ movl(rax, STATE(_thread));)                       // get thread
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
  __ movbool(do_not_unlock_if_synchronized, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
  // check for synchronized native methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
  // Note: This must happen *after* invocation counter check, since
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
  //       when overflow happens, the method should not be locked.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
  if (synchronized) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
    // potentially kills rax, rcx, rdx, rdi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
    lock_method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
    // no synchronization necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
      { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
        __ movl(rax, access_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
        __ testl(rax, JVM_ACC_SYNCHRONIZED);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
        __ jcc(Assembler::zero, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
        __ stop("method needs synchronization");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
        __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
  // start execution
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
  // jvmti support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
  __ notify_method_entry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
  // work registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
  const Register method = rbx;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   960
  const Register thread = LP64_ONLY(r15_thread) NOT_LP64(rdi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   961
  const Register t      = InterpreterRuntime::SignatureHandlerGenerator::temp();    // rcx|rscratch1
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   962
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   963
 // allocate space for parameters
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   964
  __ movptr(method, STATE(_method));
13743
154102966e74 7196681: NPG: Some JSR 292 tests crash in Windows exception handler
coleenp
parents: 13728
diff changeset
   965
  __ verify_method_ptr(method);
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   966
  {
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   967
    const Address constMethod       (method, Method::const_offset());
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   968
    const Address size_of_parameters(t, ConstMethod::size_of_parameters_offset());
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   969
    __ movptr(t, constMethod);
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   970
    __ load_unsigned_short(t, size_of_parameters);
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   971
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
  __ shll(t, 2);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   973
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   974
  __ subptr(rsp, t);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   975
  __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1896
diff changeset
   976
  __ andptr(rsp, -16); // must be 16 byte boundary (see amd64 ABI)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   977
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   978
  __ addptr(t, 2*wordSize);     // allocate two more slots for JNIEnv and possible mirror
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   979
  __ subptr(rsp, t);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   980
  __ andptr(rsp, -(StackAlignmentInBytes)); // gcc needs 16 byte aligned stacks to do XMM intrinsics
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   981
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
  // get signature handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
    Label pending_exception_present;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
  { Label L;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   987
    __ movptr(t, Address(method, Method::signature_handler_offset()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   988
    __ testptr(t, t);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
    __ jcc(Assembler::notZero, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), method, false);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   991
    __ movptr(method, STATE(_method));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   992
    __ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
    __ jcc(Assembler::notEqual, pending_exception_present);
13743
154102966e74 7196681: NPG: Some JSR 292 tests crash in Windows exception handler
coleenp
parents: 13728
diff changeset
   994
    __ verify_method_ptr(method);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   995
    __ movptr(t, Address(method, Method::signature_handler_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
    Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1001
    __ push(t);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
    __ get_thread(t);                                   // get vm's javathread*
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1003
    __ cmpptr(t, STATE(_thread));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
    __ jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
    __ int3();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
    __ bind(L);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1007
    __ pop(t);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
#endif //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1011
  const Register from_ptr = InterpreterRuntime::SignatureHandlerGenerator::from();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
  // call signature handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
  assert(InterpreterRuntime::SignatureHandlerGenerator::to  () == rsp, "adjust this code");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1014
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
  // The generated handlers do not touch RBX (the method oop).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
  // However, large signatures cannot be cached and are generated
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
  // each time here.  The slow-path generator will blow RBX
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
  // sometime, so we must reload it after the call.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1019
  __ movptr(from_ptr, STATE(_locals));  // get the from pointer
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
  __ call(t);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1021
  __ movptr(method, STATE(_method));
13743
154102966e74 7196681: NPG: Some JSR 292 tests crash in Windows exception handler
coleenp
parents: 13728
diff changeset
  1022
  __ verify_method_ptr(method);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
  // result handler is in rax
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
  // set result handler
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1026
  __ movptr(STATE(_result_handler), rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1027
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1028
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1029
  // get native function entry point
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1030
  { Label L;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1031
    __ movptr(rax, Address(method, Method::native_function_offset()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1032
    __ testptr(rax, rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1033
    __ jcc(Assembler::notZero, L);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1034
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), method);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1035
    __ movptr(method, STATE(_method));
13743
154102966e74 7196681: NPG: Some JSR 292 tests crash in Windows exception handler
coleenp
parents: 13728
diff changeset
  1036
    __ verify_method_ptr(method);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1037
    __ movptr(rax, Address(method, Method::native_function_offset()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1038
    __ bind(L);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1039
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
  // pass mirror handle if static call
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
  { Label L;
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 9636
diff changeset
  1043
    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1044
    __ movl(t, Address(method, Method::access_flags_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
    __ testl(t, JVM_ACC_STATIC);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
    __ jcc(Assembler::zero, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
    // get mirror
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1048
    __ movptr(t, Address(method, Method:: const_offset()));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1049
    __ movptr(t, Address(t, ConstMethod::constants_offset()));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1050
    __ movptr(t, Address(t, ConstantPool::pool_holder_offset_in_bytes()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1051
    __ movptr(t, Address(t, mirror_offset));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
    // copy mirror into activation object
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1053
    __ movptr(STATE(_oop_temp), t);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
    // pass handle to mirror
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1055
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1056
    __ lea(c_rarg1, STATE(_oop_temp));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1057
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1058
    __ lea(t, STATE(_oop_temp));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1059
    __ movptr(Address(rsp, wordSize), t);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1060
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
    Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1066
    __ push(t);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
    __ get_thread(t);                                   // get vm's javathread*
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1068
    __ cmpptr(t, STATE(_thread));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
    __ jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
    __ int3();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
    __ bind(L);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1072
    __ pop(t);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
#endif //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
  // pass JNIEnv
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1077
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1078
  __ lea(c_rarg0, Address(thread, JavaThread::jni_environment_offset()));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1079
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1080
  __ movptr(thread, STATE(_thread));          // get thread
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1081
  __ lea(t, Address(thread, JavaThread::jni_environment_offset()));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1082
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1083
  __ movptr(Address(rsp, 0), t);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1084
#endif // _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1085
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
    Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1089
    __ push(t);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
    __ get_thread(t);                                   // get vm's javathread*
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1091
    __ cmpptr(t, STATE(_thread));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
    __ jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
    __ int3();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
    __ bind(L);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1095
    __ pop(t);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
#endif //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
  { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
    __ movl(t, Address(thread, JavaThread::thread_state_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
    __ cmpl(t, _thread_in_Java);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
    __ jcc(Assembler::equal, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
    __ stop("Wrong thread state in native stub");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
  // Change state to native (we save the return address in the thread, since it might not
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
  // be pushed on the stack when we do a a stack traversal). It is enough that the pc()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
  // points into the right code segment. It does not have to be the correct return pc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
  __ set_last_Java_frame(thread, noreg, rbp, __ pc());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
  __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
  __ call(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
  // result potentially in rdx:rax or ST0
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1120
  __ movptr(method, STATE(_method));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1121
  NOT_LP64(__ movptr(thread, STATE(_thread));)                  // get thread
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
  // The potential result is in ST(0) & rdx:rax
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
  // With C++ interpreter we leave any possible result in ST(0) until we are in result handler and then
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
  // we do the appropriate stuff for returning the result. rdx:rax must always be saved because just about
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
  // anything we do here will destroy it, st(0) is only saved if we re-enter the vm where it would
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
  // be destroyed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
  // It is safe to do these pushes because state is _thread_in_native and return address will be found
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
  // via _last_native_pc and not via _last_jave_sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1131
    // Must save the value of ST(0)/xmm0 since it could be destroyed before we get to result handler
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
    { Label Lpush, Lskip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
      ExternalAddress float_handler(AbstractInterpreter::result_handler(T_FLOAT));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
      ExternalAddress double_handler(AbstractInterpreter::result_handler(T_DOUBLE));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
      __ cmpptr(STATE(_result_handler), float_handler.addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
      __ jcc(Assembler::equal, Lpush);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
      __ cmpptr(STATE(_result_handler), double_handler.addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
      __ jcc(Assembler::notEqual, Lskip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
      __ bind(Lpush);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1140
      __ subptr(rsp, 2*wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1141
      if ( UseSSE < 2 ) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1142
        __ fstp_d(Address(rsp, 0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1143
      } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1144
        __ movdbl(Address(rsp, 0), xmm0);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1145
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
      __ bind(Lskip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1149
  // save rax:rdx for potential use by result handler.
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1150
  __ push(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1151
#ifndef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1152
  __ push(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1153
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
16624
9dbd4b210bf9 8011102: Clear AVX registers after return from JNI call
kvn
parents: 15943
diff changeset
  1155
  // Verify or restore cpu control state after JNI call
9dbd4b210bf9 8011102: Clear AVX registers after return from JNI call
kvn
parents: 15943
diff changeset
  1156
  __ restore_cpu_control_state_after_jni();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
  // change thread state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
  __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native_trans);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
  if(os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
    // Write serialization page so VM thread can do a pseudo remote membar.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
    // We use the current thread pointer to calculate a thread specific
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
    // offset to write to within the page. This minimizes bus traffic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
    // due to cache line collision.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
    __ serialize_memory(thread, rcx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
  // check for safepoint operation in progress and/or pending suspend requests
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
  { Label Continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
    __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
             SafepointSynchronize::_not_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
    // threads running native code and they are expected to self-suspend
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
    // when leaving the _thread_in_native state. We need to check for
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
    // pending suspend requests here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
    __ jcc(Assembler::notEqual, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
    __ cmpl(Address(thread, JavaThread::suspend_flags_offset()), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
    __ jcc(Assembler::equal, Continue);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
    // Don't use call_VM as it will see a possible pending exception and forward it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
    // and never return here preventing us from clearing _last_native_pc down below.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
    // Also can't use call_VM_leaf either as it will check to see if rsi & rdi are
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1186
    // preserved and correspond to the bcp/locals pointers.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
    //
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1188
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1189
    ((MacroAssembler*)_masm)->call_VM_leaf(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans),
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1190
                          thread);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
    __ increment(rsp, wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1193
    __ movptr(method, STATE(_method));
13743
154102966e74 7196681: NPG: Some JSR 292 tests crash in Windows exception handler
coleenp
parents: 13728
diff changeset
  1194
    __ verify_method_ptr(method);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1195
    __ movptr(thread, STATE(_thread));                       // get thread
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
    __ bind(Continue);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
  // change thread state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
  __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_Java);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
  __ reset_last_Java_frame(thread, true, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
  // reset handle block
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1206
  __ movptr(t, Address(thread, JavaThread::active_handles_offset()));
23844
0c29a324ae14 8039146: Fix 64-bit store to int JNIHandleBlock::_top
goetz
parents: 23203
diff changeset
  1207
  __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
  // If result was an oop then unbox and save it in the frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
  { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
    Label no_oop, store_result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
      ExternalAddress oop_handler(AbstractInterpreter::result_handler(T_OBJECT));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
    __ cmpptr(STATE(_result_handler), oop_handler.addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
    __ jcc(Assembler::notEqual, no_oop);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1215
#ifndef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1216
    __ pop(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1217
#endif // _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1218
    __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1219
    __ testptr(rax, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
    __ jcc(Assembler::zero, store_result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
    // unbox
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1222
    __ movptr(rax, Address(rax, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
    __ bind(store_result);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1224
    __ movptr(STATE(_oop_temp), rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
    // keep stack depth as expected by pushing oop which will eventually be discarded
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1226
    __ push(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1227
#ifndef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1228
    __ push(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1229
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
    __ bind(no_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
     Label no_reguard;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
     __ cmpl(Address(thread, JavaThread::stack_guard_state_offset()), JavaThread::stack_guard_yellow_disabled);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
     __ jcc(Assembler::notEqual, no_reguard);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1238
     __ pusha();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
     __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages)));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1240
     __ popa();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
     __ bind(no_reguard);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
  // QQQ Seems like for native methods we simply return and the caller will see the pending
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
  // exception and do the right thing. Certainly the interpreter will, don't know about
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
  // compiled methods.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
  // Seems that the answer to above is no this is wrong. The old code would see the exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
  // and forward it before doing the unlocking and notifying jvmdi that method has exited.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
  // This seems wrong need to investigate the spec.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
  // handle exceptions (exception handling will handle unlocking!)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
  { Label L;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1255
    __ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
    __ jcc(Assembler::zero, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
    __ bind(pending_exception_present);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
    // There are potential results on the stack (rax/rdx, ST(0)) we ignore these and simply
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
    // return and let caller deal with exception. This skips the unlocking here which
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
    // seems wrong but seems to be what asm interpreter did. Can't find this in the spec.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
    // Note: must preverve method in rbx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
    // remove activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1267
    __ movptr(t, STATE(_sender_sp));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
    __ leave();                                  // remove frame anchor
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1269
    __ pop(rdi);                                 // get return address
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1270
    __ movptr(state, STATE(_prev_link));         // get previous state for return
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1271
    __ mov(rsp, t);                              // set sp to sender sp
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1272
    __ push(rdi);                                // push throwing pc
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
    // The skips unlocking!! This seems to be what asm interpreter does but seems
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
    // very wrong. Not clear if this violates the spec.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
    __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
  // do unlocking if necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
  { Label L;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1281
    __ movl(t, Address(method, Method::access_flags_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
    __ testl(t, JVM_ACC_SYNCHRONIZED);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
    __ jcc(Assembler::zero, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
    // the code below should be shared with interpreter macro assembler implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
    { Label unlock;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1286
    const Register monitor = NOT_LP64(rdx) LP64_ONLY(c_rarg1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
      // BasicObjectLock will be first in list, since this is a synchronized method. However, need
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
      // to check that the object has not been unlocked by an explicit monitorexit bytecode.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1289
      __ movptr(monitor, STATE(_monitor_base));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1290
      __ subptr(monitor, frame::interpreter_frame_monitor_size() * wordSize);  // address of initial monitor
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1291
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1292
      __ movptr(t, Address(monitor, BasicObjectLock::obj_offset_in_bytes()));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1293
      __ testptr(t, t);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
      __ jcc(Assembler::notZero, unlock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
      // Entry already unlocked, need to throw exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
      __ MacroAssembler::call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
      __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1300
      __ bind(unlock);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1301
      __ unlock_object(monitor);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
      // unlock can blow rbx so restore it for path that needs it below
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1303
      __ movptr(method, STATE(_method));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
  // jvmti support
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
  // Note: This must happen _after_ handling/throwing any exceptions since
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
  //       the exception handler code notifies the runtime of method exits
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
  //       too. If this happens before, method entry/exit notifications are
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
  //       not properly paired (was bug - gri 11/22/99).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
  __ notify_method_exit(vtos, InterpreterMacroAssembler::NotifyJVMTI);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
  // restore potential result in rdx:rax, call result handler to restore potential result in ST0 & handle result
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1316
#ifndef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1317
  __ pop(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1318
#endif // _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1319
  __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1320
  __ movptr(t, STATE(_result_handler));       // get result handler
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
  __ call(t);                                 // call result handler to convert to tosca form
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
  // remove activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1325
  __ movptr(t, STATE(_sender_sp));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
  __ leave();                                  // remove frame anchor
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1328
  __ pop(rdi);                                 // get return address
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1329
  __ movptr(state, STATE(_prev_link));         // get previous state for return (if c++ interpreter was caller)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1330
  __ mov(rsp, t);                              // set sp to sender sp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
  __ jmp(rdi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
  // invocation counter overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
  if (inc_counter) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
    // Handle overflow of counter and compile method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
    __ bind(invocation_counter_overflow);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
    generate_counter_overflow(&continue_after_compile);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
// Generate entries that will put a result type index into rcx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
void CppInterpreterGenerator::generate_deopt_handling() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
  Label return_from_deopt_common;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
  // Generate entries that will put a result type index into rcx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
  deopt_frame_manager_return_atos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
  // rax is live here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
  __ movl(rcx, AbstractInterpreter::BasicType_as_index(T_OBJECT));    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
  __ jmp(return_from_deopt_common);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
  deopt_frame_manager_return_btos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
  // rax is live here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
  __ movl(rcx, AbstractInterpreter::BasicType_as_index(T_BOOLEAN));    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
  __ jmp(return_from_deopt_common);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
  deopt_frame_manager_return_itos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
  // rax is live here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
  __ movl(rcx, AbstractInterpreter::BasicType_as_index(T_INT));    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
  __ jmp(return_from_deopt_common);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
  deopt_frame_manager_return_ltos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
  // rax,rdx are live here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
  __ movl(rcx, AbstractInterpreter::BasicType_as_index(T_LONG));    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
  __ jmp(return_from_deopt_common);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
  deopt_frame_manager_return_ftos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
  // st(0) is live here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
  __ movl(rcx, AbstractInterpreter::BasicType_as_index(T_FLOAT));    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
  __ jmp(return_from_deopt_common);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
  deopt_frame_manager_return_dtos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
  // st(0) is live here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
  __ movl(rcx, AbstractInterpreter::BasicType_as_index(T_DOUBLE));    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
  __ jmp(return_from_deopt_common);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
  deopt_frame_manager_return_vtos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
  __ movl(rcx, AbstractInterpreter::BasicType_as_index(T_VOID));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
  // Deopt return common
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
  // an index is present in rcx that lets us move any possible result being
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
  // return to the interpreter's stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
  // Because we have a full sized interpreter frame on the youngest
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
  // activation the stack is pushed too deep to share the tosca to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
  // stack converters directly. We shrink the stack to the desired
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
  // amount and then push result and then re-extend the stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
  // We could have the code in size_activation layout a short
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
  // frame for the top activation but that would look different
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
  // than say sparc (which needs a full size activation because
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
  // the windows are in the way. Really it could be short? QQQ
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
  __ bind(return_from_deopt_common);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1412
  __ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
  // setup rsp so we can push the "result" as needed.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1415
  __ movptr(rsp, STATE(_stack));                                   // trim stack (is prepushed)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1416
  __ addptr(rsp, wordSize);                                        // undo prepush
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
  ExternalAddress tosca_to_stack((address)CppInterpreter::_tosca_to_stack);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1419
  // Address index(noreg, rcx, Address::times_ptr);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1420
  __ movptr(rcx, ArrayAddress(tosca_to_stack, Address(noreg, rcx, Address::times_ptr)));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1421
  // __ movl(rcx, Address(noreg, rcx, Address::times_ptr, int(AbstractInterpreter::_tosca_to_stack)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
  __ call(rcx);                                                   // call result converter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
  __ movl(STATE(_msg), (int)BytecodeInterpreter::deopt_resume);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1425
  __ lea(rsp, Address(rsp, -wordSize));                            // prepush stack (result if any already present)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1426
  __ movptr(STATE(_stack), rsp);                                   // inform interpreter of new stack depth (parameters removed,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
                                                                   // result if any on stack already )
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1428
  __ movptr(rsp, STATE(_stack_limit));                             // restore expression stack to full depth
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
// Generate the code to handle a more_monitors message from the c++ interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
void CppInterpreterGenerator::generate_more_monitors() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1434
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
  Label entry, loop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
  const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1437
  // 1. compute new pointers                     // rsp: old expression stack top
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1438
  __ movptr(rdx, STATE(_stack_base));            // rdx: old expression stack bottom
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1439
  __ subptr(rsp, entry_size);                    // move expression stack top limit
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1440
  __ subptr(STATE(_stack), entry_size);          // update interpreter stack top
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1441
  __ subptr(STATE(_stack_limit), entry_size);    // inform interpreter
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1442
  __ subptr(rdx, entry_size);                    // move expression stack bottom
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1443
  __ movptr(STATE(_stack_base), rdx);            // inform interpreter
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1444
  __ movptr(rcx, STATE(_stack));                 // set start value for copy loop
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
  __ jmp(entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
  // 2. move expression stack contents
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
  __ bind(loop);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1448
  __ movptr(rbx, Address(rcx, entry_size));      // load expression stack word from old location
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1449
  __ movptr(Address(rcx, 0), rbx);               // and store it at new location
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1450
  __ addptr(rcx, wordSize);                      // advance to next word
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
  __ bind(entry);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1452
  __ cmpptr(rcx, rdx);                           // check if bottom reached
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1453
  __ jcc(Assembler::notEqual, loop);             // if not at bottom then copy next word
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
  // now zero the slot so we can find it.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1455
  __ movptr(Address(rdx, BasicObjectLock::obj_offset_in_bytes()), (int32_t) NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
  __ movl(STATE(_msg), (int)BytecodeInterpreter::got_monitors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
// Initial entry to C++ interpreter from the call_stub.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
// This entry point is called the frame manager since it handles the generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
// of interpreter activation frames via requests directly from the vm (via call_stub)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
// and via requests from the interpreter. The requests from the call_stub happen
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
// directly thru the entry point. Requests from the interpreter happen via returning
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
// from the interpreter and examining the message the interpreter has returned to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
// the frame manager. The frame manager can take the following requests:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
// NO_REQUEST - error, should never happen.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
// MORE_MONITORS - need a new monitor. Shuffle the expression stack on down and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
//                 allocate a new monitor.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
// CALL_METHOD - setup a new activation to call a new method. Very similar to what
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
//               happens during entry during the entry via the call stub.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
// RETURN_FROM_METHOD - remove an activation. Return to interpreter or call stub.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
// Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
//
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1477
// rbx: Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
// rcx: receiver - unused (retrieved from stack as needed)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1479
// rsi/r13: previous frame manager state (NULL from the call_stub/c1/c2)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
// Stack layout at entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
// [ return address     ] <--- rsp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
// [ parameter n        ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
//   ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
// [ parameter 1        ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
// [ expression stack   ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
// We are free to blow any registers we like because the call_stub which brought us here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
// initially has preserved the callee save registers already.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
static address interpreter_frame_manager = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
address InterpreterGenerator::generate_normal_entry(bool synchronized) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1500
  // rbx: Method*
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1501
  // rsi/r13: sender sp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
  // Because we redispatch "recursive" interpreter entries thru this same entry point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
  // the "input" register usage is a little strange and not what you expect coming
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
  // from the call_stub. From the call stub rsi/rdi (current/previous) interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
  // state are NULL but on "recursive" dispatches they are what you'd expect.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
  // rsi: current interpreter state (C++ interpreter) must preserve (null from call_stub/c1/c2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
  // A single frame manager is plenty as we don't specialize for synchronized. We could and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
  // the code is pretty much ready. Would need to change the test below and for good measure
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
  // modify generate_interpreter_state to only do the (pre) sync stuff stuff for synchronized
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
  // routines. Not clear this is worth it yet.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
  if (interpreter_frame_manager) return interpreter_frame_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
  Label dispatch_entry_2;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1520
  __ movptr(rcx, sender_sp_on_entry);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1521
  __ movptr(state, (int32_t)NULL_WORD);                              // no current activation
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
  __ jmp(dispatch_entry_2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
  const Register locals  = rdi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
  Label re_dispatch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
  __ bind(re_dispatch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
  // save sender sp (doesn't include return address
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1532
  __ lea(rcx, Address(rsp, wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
  __ bind(dispatch_entry_2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
  // save sender sp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1537
  __ push(rcx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14633
diff changeset
  1539
  const Address constMethod       (rbx, Method::const_offset());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1540
  const Address access_flags      (rbx, Method::access_flags_offset());
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14633
diff changeset
  1541
  const Address size_of_parameters(rdx, ConstMethod::size_of_parameters_offset());
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14633
diff changeset
  1542
  const Address size_of_locals    (rdx, ConstMethod::size_of_locals_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1543
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1544
  // const Address monitor_block_top (rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
  // const Address monitor_block_bot (rbp, frame::interpreter_frame_initial_sp_offset        * wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1546
  // const Address monitor(rbp, frame::interpreter_frame_initial_sp_offset * wordSize - (int)sizeof(BasicObjectLock));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
  // get parameter size (always needed)
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14633
diff changeset
  1549
  __ movptr(rdx, constMethod);
2148
09c7f703773b 6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents: 2131
diff changeset
  1550
  __ load_unsigned_short(rcx, size_of_parameters);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1551
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1552
  // rbx: Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
  // rcx: size of parameters
2148
09c7f703773b 6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents: 2131
diff changeset
  1554
  __ load_unsigned_short(rdx, size_of_locals);                     // get size of locals in words
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1555
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1556
  __ subptr(rdx, rcx);                                             // rdx = no. of additional locals
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1558
  // see if we've got enough room on the stack for locals plus overhead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1559
  generate_stack_overflow_check();                                 // C++
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1560
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1561
  // c++ interpreter does not use stack banging or any implicit exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1562
  // leave for now to verify that check is proper.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1563
  bang_stack_shadow_pages(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1564
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1565
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1566
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
  // compute beginning of parameters (rdi)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1568
  __ lea(locals, Address(rsp, rcx, Address::times_ptr, wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1569
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1570
  // save sender's sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1571
  // __ movl(rcx, rsp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1572
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1573
  // get sender's sp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1574
  __ pop(rcx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1575
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1576
  // get return address
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1577
  __ pop(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1578
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1579
  // rdx - # of additional locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
  // allocate space for locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
  // explicitly initialize locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
    Label exit, loop;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1584
    __ testl(rdx, rdx);                               // (32bit ok)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
    __ jcc(Assembler::lessEqual, exit);               // do nothing if rdx <= 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
    __ bind(loop);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1587
    __ push((int32_t)NULL_WORD);                      // initialize local variables
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
    __ decrement(rdx);                                // until everything initialized
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
    __ jcc(Assembler::greater, loop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
    __ bind(exit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1592
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1593
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1594
  // Assumes rax = return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
  // allocate and initialize new interpreterState and method expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1597
  // IN(locals) ->  locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1598
  // IN(state) -> any current interpreter activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1599
  // destroys rax, rcx, rdx, rdi
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1600
  // OUT (state) -> new interpreterState
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
  // OUT(rsp) -> bottom of methods expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1603
  generate_compute_interpreter_state(state, locals, rcx, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
  // Call interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
  Label call_interpreter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
  __ bind(call_interpreter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
  // c++ interpreter does not use stack banging or any implicit exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
  // leave for now to verify that check is proper.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
  bang_stack_shadow_pages(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
  // Call interpreter enter here if message is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
  // set and we know stack size is valid
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
  Label call_interpreter_2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
  __ bind(call_interpreter_2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
  {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1623
    const Register thread  = NOT_LP64(rcx) LP64_ONLY(r15_thread);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1624
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1625
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1626
    __ mov(c_rarg0, state);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1627
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1628
    __ push(state);                                                 // push arg to interpreter
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1629
    __ movptr(thread, STATE(_thread));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1630
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
    // We can setup the frame anchor with everything we want at this point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
    // as we are thread_in_Java and no safepoints can occur until we go to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1634
    // vm mode. We do have to clear flags on return from vm but that is it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
    //
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1636
    __ movptr(Address(thread, JavaThread::last_Java_fp_offset()), rbp);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1637
    __ movptr(Address(thread, JavaThread::last_Java_sp_offset()), rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1638
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1639
    // Call the interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
    RuntimeAddress normal(CAST_FROM_FN_PTR(address, BytecodeInterpreter::run));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
    RuntimeAddress checking(CAST_FROM_FN_PTR(address, BytecodeInterpreter::runWithChecks));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1643
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1644
    __ call(JvmtiExport::can_post_interpreter_events() ? checking : normal);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1645
    NOT_LP64(__ pop(rax);)                                          // discard parameter to run
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1646
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1647
    // state is preserved since it is callee saved
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1648
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
    // reset_last_Java_frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1652
    NOT_LP64(__ movl(thread, STATE(_thread));)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1653
    __ reset_last_Java_frame(thread, true, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1656
  // examine msg from interpreter to determine next action
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1658
  __ movl(rdx, STATE(_msg));                                       // Get new message
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1660
  Label call_method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1661
  Label return_from_interpreted_method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
  Label throw_exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1663
  Label bad_msg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
  Label do_OSR;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1665
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1666
  __ cmpl(rdx, (int32_t)BytecodeInterpreter::call_method);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1667
  __ jcc(Assembler::equal, call_method);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1668
  __ cmpl(rdx, (int32_t)BytecodeInterpreter::return_from_method);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1669
  __ jcc(Assembler::equal, return_from_interpreted_method);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1670
  __ cmpl(rdx, (int32_t)BytecodeInterpreter::do_osr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
  __ jcc(Assembler::equal, do_OSR);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1672
  __ cmpl(rdx, (int32_t)BytecodeInterpreter::throwing_exception);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1673
  __ jcc(Assembler::equal, throw_exception);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1674
  __ cmpl(rdx, (int32_t)BytecodeInterpreter::more_monitors);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1675
  __ jcc(Assembler::notEqual, bad_msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1676
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1677
  // Allocate more monitor space, shuffle expression stack....
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1678
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1679
  generate_more_monitors();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1680
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
  __ jmp(call_interpreter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1682
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1683
  // uncommon trap needs to jump to here to enter the interpreter (re-execute current bytecode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
  unctrap_frame_manager_entry  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
  // Load the registers we need.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1687
  __ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter)));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1688
  __ movptr(rsp, STATE(_stack_limit));                             // restore expression stack to full depth
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1689
  __ jmp(call_interpreter_2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1690
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1691
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1693
  //=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
  // Returning from a compiled method into a deopted method. The bytecode at the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1695
  // bcp has completed. The result of the bytecode is in the native abi (the tosca
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1696
  // for the template based interpreter). Any stack space that was used by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1697
  // bytecode that has completed has been removed (e.g. parameters for an invoke)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
  // so all that we have to do is place any pending result on the expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
  // and resume execution on the next bytecode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1700
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1701
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1702
  generate_deopt_handling();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
  __ jmp(call_interpreter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
  // Current frame has caught an exception we need to dispatch to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
  // handler. We can get here because a native interpreter frame caught
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
  // an exception in which case there is no handler and we must rethrow
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1709
  // If it is a vanilla interpreted frame the we simply drop into the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
  // interpreter and let it do the lookup.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
  Interpreter::_rethrow_exception_entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
  // rax: exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1714
  // rdx: return address/pc that threw exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
  Label return_with_exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
  Label unwind_and_forward;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1718
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1719
  // restore state pointer.
1896
cce23a9ff495 6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents: 1217
diff changeset
  1720
  __ lea(state, Address(rbp,  -(int)sizeof(BytecodeInterpreter)));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1721
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1722
  __ movptr(rbx, STATE(_method));                       // get method
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1723
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1724
  __ movptr(Address(r15_thread, Thread::pending_exception_offset()), rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1725
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1726
  __ movl(rcx, STATE(_thread));                       // get thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1728
  // Store exception with interpreter will expect it
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1729
  __ movptr(Address(rcx, Thread::pending_exception_offset()), rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1730
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1731
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
  // is current frame vanilla or native?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1733
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1734
  __ movl(rdx, access_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
  __ testl(rdx, JVM_ACC_NATIVE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
  __ jcc(Assembler::zero, return_with_exception);     // vanilla interpreted frame, handle directly
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1737
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1738
  // We drop thru to unwind a native interpreted frame with a pending exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
  // We jump here for the initial interpreter frame with exception pending
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
  // We unwind the current acivation and forward it to our caller.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
  __ bind(unwind_and_forward);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1743
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1744
  // unwind rbp, return stack to unextended value and re-push return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1746
  __ movptr(rcx, STATE(_sender_sp));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
  __ leave();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1748
  __ pop(rdx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1749
  __ mov(rsp, rcx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1750
  __ push(rdx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
  __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1752
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
  // Return point from a call which returns a result in the native abi
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
  // (c1/c2/jni-native). This result must be processed onto the java
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
  // expression stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
  // A pending exception may be present in which case there is no result present
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
  Label resume_interpreter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
  Label do_float;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1761
  Label do_double;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
  Label done_conv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
  // The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
  if (UseSSE < 2) {
1896
cce23a9ff495 6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents: 1217
diff changeset
  1766
    __ lea(state, Address(rbp,  -(int)sizeof(BytecodeInterpreter)));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1767
    __ movptr(rbx, STATE(_result._to_call._callee));                   // get method just executed
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1768
    __ movl(rcx, Address(rbx, Method::result_index_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
    __ cmpl(rcx, AbstractInterpreter::BasicType_as_index(T_FLOAT));    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
    __ jcc(Assembler::equal, do_float);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
    __ cmpl(rcx, AbstractInterpreter::BasicType_as_index(T_DOUBLE));    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
    __ jcc(Assembler::equal, do_double);
1896
cce23a9ff495 6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents: 1217
diff changeset
  1773
#if !defined(_LP64) || defined(COMPILER1) || !defined(COMPILER2)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1774
    __ empty_FPU_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1775
#endif // COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1776
    __ jmp(done_conv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1777
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1778
    __ bind(do_float);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1779
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1780
    for (int i = 1; i < 8; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
      __ ffree(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
#endif // COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
    __ jmp(done_conv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
    __ bind(do_double);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
    for (int i = 1; i < 8; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
      __ ffree(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
#endif // COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
    __ jmp(done_conv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1792
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
    __ MacroAssembler::verify_FPU(0, "generate_return_entry_for compiled");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
    __ jmp(done_conv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1795
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1796
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
  // Return point to interpreter from compiled/native method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
  InternalAddress return_from_native_method(__ pc());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1799
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1800
  __ bind(done_conv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1801
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1802
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1803
  // Result if any is in tosca. The java expression stack is in the state that the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1804
  // calling convention left it (i.e. params may or may not be present)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1805
  // Copy the result from tosca and place it on java expression stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1806
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1807
  // Restore rsi/r13 as compiled code may not preserve it
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1808
1896
cce23a9ff495 6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents: 1217
diff changeset
  1809
  __ lea(state, Address(rbp,  -(int)sizeof(BytecodeInterpreter)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1810
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1811
  // restore stack to what we had when we left (in case i2c extended it)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1813
  __ movptr(rsp, STATE(_stack));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1814
  __ lea(rsp, Address(rsp, wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
  // If there is a pending exception then we don't really have a result to process
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1818
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1819
  __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1820
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1821
  __ movptr(rcx, STATE(_thread));                       // get thread
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1822
  __ cmpptr(Address(rcx, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
1896
cce23a9ff495 6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents: 1217
diff changeset
  1823
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1824
  __ jcc(Assembler::notZero, return_with_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1825
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1826
  // get method just executed
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1827
  __ movptr(rbx, STATE(_result._to_call._callee));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1828
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1829
  // callee left args on top of expression stack, remove them
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14633
diff changeset
  1830
  __ movptr(rcx, constMethod);
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14633
diff changeset
  1831
  __ load_unsigned_short(rcx, Address(rcx, ConstMethod::size_of_parameters_offset()));
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14633
diff changeset
  1832
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1833
  __ lea(rsp, Address(rsp, rcx, Address::times_ptr));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1834
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1835
  __ movl(rcx, Address(rbx, Method::result_index_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1836
  ExternalAddress tosca_to_stack((address)CppInterpreter::_tosca_to_stack);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1837
  // Address index(noreg, rax, Address::times_ptr);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1838
  __ movptr(rcx, ArrayAddress(tosca_to_stack, Address(noreg, rcx, Address::times_ptr)));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1839
  // __ movl(rcx, Address(noreg, rcx, Address::times_ptr, int(AbstractInterpreter::_tosca_to_stack)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1840
  __ call(rcx);                                               // call result converter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1841
  __ jmp(resume_interpreter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1842
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1843
  // An exception is being caught on return to a vanilla interpreter frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1844
  // Empty the stack and resume interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1845
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1846
  __ bind(return_with_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1847
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1848
  // Exception present, empty stack
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1849
  __ movptr(rsp, STATE(_stack_base));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1850
  __ jmp(resume_interpreter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1851
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1852
  // Return from interpreted method we return result appropriate to the caller (i.e. "recursive"
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1853
  // interpreter call, or native) and unwind this interpreter activation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1854
  // All monitors should be unlocked.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1855
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1856
  __ bind(return_from_interpreted_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1857
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1858
  Label return_to_initial_caller;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1859
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1860
  __ movptr(rbx, STATE(_method));                                   // get method just executed
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1861
  __ cmpptr(STATE(_prev_link), (int32_t)NULL_WORD);                 // returning from "recursive" interpreter call?
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1862
  __ movl(rax, Address(rbx, Method::result_index_offset())); // get result type index
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1863
  __ jcc(Assembler::equal, return_to_initial_caller);               // back to native code (call_stub/c1/c2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1864
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1865
  // Copy result to callers java stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1866
  ExternalAddress stack_to_stack((address)CppInterpreter::_stack_to_stack);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1867
  // Address index(noreg, rax, Address::times_ptr);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1868
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1869
  __ movptr(rax, ArrayAddress(stack_to_stack, Address(noreg, rax, Address::times_ptr)));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1870
  // __ movl(rax, Address(noreg, rax, Address::times_ptr, int(AbstractInterpreter::_stack_to_stack)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1871
  __ call(rax);                                                     // call result converter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1872
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1873
  Label unwind_recursive_activation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1874
  __ bind(unwind_recursive_activation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1875
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
  // returning to interpreter method from "recursive" interpreter call
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1877
  // result converter left rax pointing to top of the java stack for method we are returning
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1878
  // to. Now all we must do is unwind the state from the completed call
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1879
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1880
  __ movptr(state, STATE(_prev_link));                              // unwind state
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1881
  __ leave();                                                       // pop the frame
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1882
  __ mov(rsp, rax);                                                 // unwind stack to remove args
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1883
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1884
  // Resume the interpreter. The current frame contains the current interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1885
  // state object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1886
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1887
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1888
  __ bind(resume_interpreter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1889
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1890
  // state == interpreterState object for method we are resuming
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1891
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1892
  __ movl(STATE(_msg), (int)BytecodeInterpreter::method_resume);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1893
  __ lea(rsp, Address(rsp, -wordSize));                            // prepush stack (result if any already present)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1894
  __ movptr(STATE(_stack), rsp);                                   // inform interpreter of new stack depth (parameters removed,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1895
                                                                   // result if any on stack already )
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1896
  __ movptr(rsp, STATE(_stack_limit));                             // restore expression stack to full depth
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1897
  __ jmp(call_interpreter_2);                                      // No need to bang
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1898
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1899
  // interpreter returning to native code (call_stub/c1/c2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1900
  // convert result and unwind initial activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1901
  // rax - result index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1902
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1903
  __ bind(return_to_initial_caller);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1904
  ExternalAddress stack_to_native((address)CppInterpreter::_stack_to_native_abi);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1905
  // Address index(noreg, rax, Address::times_ptr);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1906
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1907
  __ movptr(rax, ArrayAddress(stack_to_native, Address(noreg, rax, Address::times_ptr)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1908
  __ call(rax);                                                    // call result converter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1909
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1910
  Label unwind_initial_activation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1911
  __ bind(unwind_initial_activation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1912
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1913
  // RETURN TO CALL_STUB/C1/C2 code (result if any in rax/rdx ST(0))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
  /* Current stack picture
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
        [ incoming parameters ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1918
        [ extra locals ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
        [ return address to CALL_STUB/C1/C2]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
  fp -> [ CALL_STUB/C1/C2 fp ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
        BytecodeInterpreter object
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1922
        expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1923
  sp ->
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1924
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1925
  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1926
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1927
  // return restoring the stack to the original sender_sp value
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1928
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1929
  __ movptr(rcx, STATE(_sender_sp));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1930
  __ leave();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1931
  __ pop(rdi);                                                        // get return address
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1932
  // set stack to sender's sp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1933
  __ mov(rsp, rcx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
  __ jmp(rdi);                                                        // return to call_stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1936
  // OSR request, adjust return address to make current frame into adapter frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
  // and enter OSR nmethod
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1938
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1939
  __ bind(do_OSR);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1940
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1941
  Label remove_initial_frame;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1942
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
  // We are going to pop this frame. Is there another interpreter frame underneath
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1944
  // it or is it callstub/compiled?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1945
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1946
  // Move buffer to the expected parameter location
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1947
  __ movptr(rcx, STATE(_result._osr._osr_buf));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1948
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1949
  __ movptr(rax, STATE(_result._osr._osr_entry));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1950
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1951
  __ cmpptr(STATE(_prev_link), (int32_t)NULL_WORD);            // returning from "recursive" interpreter call?
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
  __ jcc(Assembler::equal, remove_initial_frame);              // back to native code (call_stub/c1/c2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1954
  __ movptr(sender_sp_on_entry, STATE(_sender_sp));            // get sender's sp in expected register
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1955
  __ leave();                                                  // pop the frame
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1956
  __ mov(rsp, sender_sp_on_entry);                             // trim any stack expansion
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1957
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1958
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1959
  // We know we are calling compiled so push specialized return
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
  // method uses specialized entry, push a return so we look like call stub setup
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
  // this path will handle fact that result is returned in registers and not
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1962
  // on the java stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1963
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1964
  __ pushptr(return_from_native_method.addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1965
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1966
  __ jmp(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1967
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1968
  __ bind(remove_initial_frame);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1969
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1970
  __ movptr(rdx, STATE(_sender_sp));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1971
  __ leave();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
  // get real return
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1973
  __ pop(rsi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1974
  // set stack to sender's sp
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1975
  __ mov(rsp, rdx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1976
  // repush real return
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1977
  __ push(rsi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1978
  // Enter OSR nmethod
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
  __ jmp(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1980
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1981
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1982
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1983
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
  // Call a new method. All we do is (temporarily) trim the expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1985
  // push a return address to bring us back to here and leap to the new entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1986
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1987
  __ bind(call_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1988
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1989
  // stack points to next free location and not top element on expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
  // method expects sp to be pointing to topmost element
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1991
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1992
  __ movptr(rsp, STATE(_stack));                                     // pop args to c++ interpreter, set sp to java stack top
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1993
  __ lea(rsp, Address(rsp, wordSize));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1994
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1995
  __ movptr(rbx, STATE(_result._to_call._callee));                   // get method to execute
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1996
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1997
  // don't need a return address if reinvoking interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1998
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1999
  // Make it look like call_stub calling conventions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2000
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2001
  // Get (potential) receiver
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14633
diff changeset
  2002
  // get size of parameters in words
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14633
diff changeset
  2003
  __ movptr(rcx, constMethod);
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14633
diff changeset
  2004
  __ load_unsigned_short(rcx, Address(rcx, ConstMethod::size_of_parameters_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2005
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2006
  ExternalAddress recursive(CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2007
  __ pushptr(recursive.addr());                                      // make it look good in the debugger
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2008
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
  InternalAddress entry(entry_point);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2010
  __ cmpptr(STATE(_result._to_call._callee_entry_point), entry.addr()); // returning to interpreter?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2011
  __ jcc(Assembler::equal, re_dispatch);                             // yes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  2013
  __ pop(rax);                                                       // pop dummy address
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2014
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2015
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2016
  // get specialized entry
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  2017
  __ movptr(rax, STATE(_result._to_call._callee_entry_point));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2018
  // set sender SP
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  2019
  __ mov(sender_sp_on_entry, rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
  // method uses specialized entry, push a return so we look like call stub setup
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2022
  // this path will handle fact that result is returned in registers and not
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2023
  // on the java stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2024
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2025
  __ pushptr(return_from_native_method.addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2026
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2027
  __ jmp(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2029
  __ bind(bad_msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2030
  __ stop("Bad message from interpreter");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2031
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2032
  // Interpreted method "returned" with an exception pass it on...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2033
  // Pass result, unwind activation and continue/return to interpreter/call_stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2034
  // We handle result (if any) differently based on return to interpreter or call_stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2035
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
  Label unwind_initial_with_pending_exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
  __ bind(throw_exception);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  2039
  __ cmpptr(STATE(_prev_link), (int32_t)NULL_WORD);                 // returning from recursive interpreter call?
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
  __ jcc(Assembler::equal, unwind_initial_with_pending_exception);  // no, back to native code (call_stub/c1/c2)
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  2041
  __ movptr(rax, STATE(_locals));                                   // pop parameters get new stack value
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  2042
  __ addptr(rax, wordSize);                                         // account for prepush before we return
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
  __ jmp(unwind_recursive_activation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
  __ bind(unwind_initial_with_pending_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2046
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
  // We will unwind the current (initial) interpreter frame and forward
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2048
  // the exception to the caller. We must put the exception in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2049
  // expected register and clear pending exception and then forward.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
  __ jmp(unwind_and_forward);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
  interpreter_frame_manager = entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2054
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
InterpreterGenerator::InterpreterGenerator(StubQueue* code)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
 : CppInterpreterGenerator(code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
   generate_all(); // down here so it can be "virtual"
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
// Deoptimization helpers for C++ interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2064
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2065
// How much stack a method activation needs in words.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2066
int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2067
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2068
  const int stub_code = 4;  // see generate_call_stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2069
  // Save space for one monitor to get into the interpreted method in case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2070
  // the method is synchronized
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2071
  int monitor_size    = method->is_synchronized() ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2072
                                1*frame::interpreter_frame_monitor_size() : 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2073
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2074
  // total static overhead size. Account for interpreter state object, return
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2075
  // address, saved rbp and 2 words for a "static long no_params() method" issue.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2077
  const int overhead_size = sizeof(BytecodeInterpreter)/wordSize +
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2078
    ( frame::sender_sp_offset - frame::link_offset) + 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2079
17875
9d4aa49a1d76 8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents: 17000
diff changeset
  2080
  const int method_stack = (method->max_locals() + method->max_stack()) *
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2081
                           Interpreter::stackElementWords;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2082
  return overhead_size + method_stack + stub_code;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2083
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2084
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2085
// returns the activation size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2086
static int size_activation_helper(int extra_locals_size, int monitor_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2087
  return (extra_locals_size +                  // the addition space for locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2088
          2*BytesPerWord +                     // return address and saved rbp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
          2*BytesPerWord +                     // "static long no_params() method" issue
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
          sizeof(BytecodeInterpreter) +               // interpreterState
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
          monitor_size);                       // monitors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2092
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2093
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
                                           frame* caller,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2096
                                           frame* current,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2097
                                           Method* method,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2098
                                           intptr_t* locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2099
                                           intptr_t* stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2100
                                           intptr_t* stack_base,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2101
                                           intptr_t* monitor_base,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2102
                                           intptr_t* frame_bottom,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2103
                                           bool is_top_frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2104
                                           )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2105
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2106
  // What about any vtable?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2108
  to_fill->_thread = JavaThread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2109
  // This gets filled in later but make it something recognizable for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2110
  to_fill->_bcp = method->code_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2111
  to_fill->_locals = locals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2112
  to_fill->_constants = method->constants()->cache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2113
  to_fill->_method = method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2114
  to_fill->_mdx = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
  to_fill->_stack = stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2116
  if (is_top_frame && JavaThread::current()->popframe_forcing_deopt_reexecution() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2117
    to_fill->_msg = deopt_resume2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2118
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2119
    to_fill->_msg = method_resume;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2121
  to_fill->_result._to_call._bcp_advance = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2122
  to_fill->_result._to_call._callee_entry_point = NULL; // doesn't matter to anyone
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2123
  to_fill->_result._to_call._callee = NULL; // doesn't matter to anyone
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2124
  to_fill->_prev_link = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2125
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2126
  to_fill->_sender_sp = caller->unextended_sp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2127
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2128
  if (caller->is_interpreted_frame()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2129
    interpreterState prev  = caller->get_interpreterState();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2130
    to_fill->_prev_link = prev;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2131
    // *current->register_addr(GR_Iprev_state) = (intptr_t) prev;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2132
    // Make the prev callee look proper
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2133
    prev->_result._to_call._callee = method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2134
    if (*prev->_bcp == Bytecodes::_invokeinterface) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2135
      prev->_result._to_call._bcp_advance = 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2136
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2137
      prev->_result._to_call._bcp_advance = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2138
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2139
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
  to_fill->_oop_temp = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2141
  to_fill->_stack_base = stack_base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
  // Need +1 here because stack_base points to the word just above the first expr stack entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2143
  // and stack_limit is supposed to point to the word just below the last expr stack entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
  // See generate_compute_interpreter_state.
17875
9d4aa49a1d76 8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents: 17000
diff changeset
  2145
  to_fill->_stack_limit = stack_base - (method->max_stack() + 1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2146
  to_fill->_monitor_base = (BasicObjectLock*) monitor_base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
  to_fill->_self_link = to_fill;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2149
  assert(stack >= to_fill->_stack_limit && stack < to_fill->_stack_base,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
         "Stack top out of range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2153
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2154
static int frame_size_helper(int max_stack,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2155
                             int tempcount,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2156
                             int moncount,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2157
                             int callee_param_count,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2158
                             int callee_locals,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2159
                             bool is_top_frame,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2160
                             int& monitor_size,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2161
                             int& full_frame_size) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2162
  int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2163
  monitor_size = sizeof(BasicObjectLock) * moncount;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2164
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2165
  // First calculate the frame size without any java expression stack
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2166
  int short_frame_size = size_activation_helper(extra_locals_size,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2167
                                                monitor_size);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2168
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2169
  // Now with full size expression stack
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2170
  full_frame_size = short_frame_size + max_stack * BytesPerWord;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2171
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2172
  // and now with only live portion of the expression stack
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2173
  short_frame_size = short_frame_size + tempcount * BytesPerWord;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2174
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2175
  // the size the activation is right now. Only top frame is full size
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2176
  int frame_size = (is_top_frame ? full_frame_size : short_frame_size);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2177
  return frame_size;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2178
}
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2179
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2180
int AbstractInterpreter::size_activation(int max_stack,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2181
                                         int tempcount,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2182
                                         int extra_args,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2183
                                         int moncount,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2184
                                         int callee_param_count,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2185
                                         int callee_locals,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2186
                                         bool is_top_frame) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2187
  assert(extra_args == 0, "FIX ME");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2188
  // NOTE: return size is in words not bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2189
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2190
  // Calculate the amount our frame will be adjust by the callee. For top frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2191
  // this is zero.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2192
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2193
  // NOTE: ia64 seems to do this wrong (or at least backwards) in that it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2194
  // calculates the extra locals based on itself. Not what the callee does
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2195
  // to it. So it ignores last_frame_adjust value. Seems suspicious as far
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2196
  // as getting sender_sp correct.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2197
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2198
  int unused_monitor_size = 0;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2199
  int unused_full_frame_size = 0;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2200
  return frame_size_helper(max_stack, tempcount, moncount, callee_param_count, callee_locals,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2201
                           is_top_frame, unused_monitor_size, unused_full_frame_size)/BytesPerWord;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2202
}
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2203
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2204
void AbstractInterpreter::layout_activation(Method* method,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2205
                                            int tempcount,  //
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2206
                                            int popframe_extra_args,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2207
                                            int moncount,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2208
                                            int caller_actual_parameters,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2209
                                            int callee_param_count,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2210
                                            int callee_locals,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2211
                                            frame* caller,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2212
                                            frame* interpreter_frame,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2213
                                            bool is_top_frame,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2214
                                            bool is_bottom_frame) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2215
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2216
  assert(popframe_extra_args == 0, "FIX ME");
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2217
  // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2218
  // does as far as allocating an interpreter frame.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2219
  // Set up the method, locals, and monitors.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2220
  // The frame interpreter_frame is guaranteed to be the right size,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2221
  // as determined by a previous call to the size_activation() method.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2222
  // It is also guaranteed to be walkable even though it is in a skeletal state
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2223
  // NOTE: tempcount is the current size of the java expression stack. For top most
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2224
  //       frames we will allocate a full sized expression stack and not the curback
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2225
  //       version that non-top frames have.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2226
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2227
  int monitor_size = 0;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2228
  int full_frame_size = 0;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2229
  int frame_size = frame_size_helper(method->max_stack(), tempcount, moncount, callee_param_count, callee_locals,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2230
                                     is_top_frame, monitor_size, full_frame_size);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2231
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2232
#ifdef ASSERT
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2233
  assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2234
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2235
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2236
  // MUCHO HACK
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2237
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2238
  intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2239
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2240
  /* Now fillin the interpreterState object */
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2241
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2242
  // The state object is the first thing on the frame and easily located
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2243
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2244
  interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2245
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2246
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2247
  // Find the locals pointer. This is rather simple on x86 because there is no
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2248
  // confusing rounding at the callee to account for. We can trivially locate
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2249
  // our locals based on the current fp().
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2250
  // Note: the + 2 is for handling the "static long no_params() method" issue.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2251
  // (too bad I don't really remember that issue well...)
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2252
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2253
  intptr_t* locals;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2254
  // If the caller is interpreted we need to make sure that locals points to the first
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2255
  // argument that the caller passed and not in an area where the stack might have been extended.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2256
  // because the stack to stack to converter needs a proper locals value in order to remove the
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2257
  // arguments from the caller and place the result in the proper location. Hmm maybe it'd be
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2258
  // simpler if we simply stored the result in the BytecodeInterpreter object and let the c++ code
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2259
  // adjust the stack?? HMMM QQQ
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2260
  //
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2261
  if (caller->is_interpreted_frame()) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2262
    // locals must agree with the caller because it will be used to set the
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2263
    // caller's tos when we return.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2264
    interpreterState prev  = caller->get_interpreterState();
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2265
    // stack() is prepushed.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2266
    locals = prev->stack() + method->size_of_parameters();
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2267
    // locals = caller->unextended_sp() + (method->size_of_parameters() - 1);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2268
    if (locals != interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2269
      // os::breakpoint();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2270
    }
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2271
  } else {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2272
    // this is where a c2i would have placed locals (except for the +2)
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2273
    locals = interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2274
  }
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2275
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2276
  intptr_t* monitor_base = (intptr_t*) cur_state;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2277
  intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2278
  /* +1 because stack is always prepushed */
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2279
  intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2280
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2281
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2282
  BytecodeInterpreter::layout_interpreterState(cur_state,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2283
                                               caller,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2284
                                               interpreter_frame,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2285
                                               method,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2286
                                               locals,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2287
                                               stack,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2288
                                               stack_base,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2289
                                               monitor_base,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2290
                                               frame_bottom,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2291
                                               is_top_frame);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2292
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2293
  // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2294
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2295
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2296
bool AbstractInterpreter::can_be_compiled(methodHandle m) {
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2297
  switch (method_kind(m)) {
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2298
    case Interpreter::java_lang_math_sin     : // fall thru
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2299
    case Interpreter::java_lang_math_cos     : // fall thru
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2300
    case Interpreter::java_lang_math_tan     : // fall thru
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2301
    case Interpreter::java_lang_math_abs     : // fall thru
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2302
    case Interpreter::java_lang_math_log     : // fall thru
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2303
    case Interpreter::java_lang_math_log10   : // fall thru
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2304
    case Interpreter::java_lang_math_sqrt    : // fall thru
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2305
    case Interpreter::java_lang_math_pow     : // fall thru
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2306
    case Interpreter::java_lang_math_exp     :
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2307
      return false;
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2308
    default:
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2309
      return true;
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2310
  }
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2311
}
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2312
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  2313
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2314
#endif // CC_INTERP (all)