hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp
author vlivanov
Fri, 04 Dec 2015 23:46:19 +0300
changeset 35086 bbf32241d851
parent 33160 c59f1676d27e
permissions -rw-r--r--
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls Reviewed-by: jrose, dlong, aph, forax
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"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "asm/assembler.hpp"
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"
25950
b5c40ed1d349 8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents: 24018
diff changeset
    32
#include "interpreter/interp_masm.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "oops/arrayOop.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    34
#include "oops/methodData.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    35
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "prims/jvmtiExport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#include "prims/jvmtiThreadState.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
#include "runtime/arguments.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    40
#include "runtime/deoptimization.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    41
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    42
#include "runtime/interfaceSupport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    43
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    44
#include "runtime/stubRoutines.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    45
#include "runtime/synchronizer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    46
#include "runtime/timer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    47
#include "runtime/vframeArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    48
#include "utilities/debug.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 15116
diff changeset
    49
#include "utilities/macros.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    50
#ifdef SHARK
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    51
#include "shark/shark_globals.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    52
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
#ifdef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// Routine exists to make tracebacks look decent in debugger
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
// while "shadow" interpreter frames are on stack. It is also
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
// used to distinguish interpreter frames.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
extern "C" void RecursiveInterpreterActivation(interpreterState istate) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
bool CppInterpreter::contains(address pc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  return ( _code->contains(pc) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
         ( pc == (CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation) + frame::pc_return_offset)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
#define STATE(field_name) Lstate, in_bytes(byte_offset_of(BytecodeInterpreter, field_name))
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
#define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
25950
b5c40ed1d349 8003426: Remove UseFastAccessors and UseFastEmptyMethods except for zero
coleenp
parents: 24018
diff changeset
    72
Label frame_manager_entry; // c++ interpreter entry point this holds that entry point label.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
static address unctrap_frame_manager_entry  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
static address interpreter_return_address  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
static address deopt_frame_manager_return_atos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
static address deopt_frame_manager_return_btos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
static address deopt_frame_manager_return_itos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
static address deopt_frame_manager_return_ltos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
static address deopt_frame_manager_return_ftos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
static address deopt_frame_manager_return_dtos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
static address deopt_frame_manager_return_vtos  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
const Register prevState = G1_scratch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
void InterpreterGenerator::save_native_result(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // result potentially in O0/O1: save it across calls
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  __ stf(FloatRegisterImpl::D, F0, STATE(_native_fresult));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  __ stx(O0, STATE(_native_lresult));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  __ std(O0, STATE(_native_lresult));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
void InterpreterGenerator::restore_native_result(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // Restore any method result value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  __ ldf(FloatRegisterImpl::D, STATE(_native_fresult), F0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  __ ldx(STATE(_native_lresult), O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  __ ldd(STATE(_native_lresult), O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
// A result handler converts/unboxes a native call result into
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
// a java interpreter/compiler result. The current frame is an
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
// interpreter frame. The activation frame unwind code must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
// consistent with that of TemplateTable::_return(...). In the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
// case of native methods, the caller's SP was not modified.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
address CppInterpreterGenerator::generate_result_handler_for(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  Register Itos_i  = Otos_i ->after_save();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  Register Itos_l  = Otos_l ->after_save();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  Register Itos_l1 = Otos_l1->after_save();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  Register Itos_l2 = Otos_l2->after_save();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    case T_BOOLEAN: __ subcc(G0, O0, G0); __ addc(G0, 0, Itos_i); break; // !0 => true; 0 => false
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    case T_CHAR   : __ sll(O0, 16, O0); __ srl(O0, 16, Itos_i);   break; // cannot use and3, 0xFFFF too big as immediate value!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    case T_BYTE   : __ sll(O0, 24, O0); __ sra(O0, 24, Itos_i);   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    case T_SHORT  : __ sll(O0, 16, O0); __ sra(O0, 16, Itos_i);   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    case T_LONG   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
#ifndef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
                    __ mov(O1, Itos_l2);  // move other half of long
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
#endif              // ifdef or no ifdef, fall through to the T_INT case
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    case T_INT    : __ mov(O0, Itos_i);                         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    case T_VOID   : /* nothing to do */                         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    case T_FLOAT  : assert(F0 == Ftos_f, "fix this code" );     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    case T_DOUBLE : assert(F0 == Ftos_d, "fix this code" );     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    case T_OBJECT :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
      __ ld_ptr(STATE(_oop_temp), Itos_i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
      __ verify_oop(Itos_i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    default       : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  __ ret();                           // return from interpreter activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  __ delayed()->restore(I5_savedSP, G0, SP);  // remove interpreter frame
15116
af423dcb739c 8004537: replace AbstractAssembler emit_long with emit_int32
twisti
parents: 14745
diff changeset
   140
  NOT_PRODUCT(__ emit_int32(0);)       // marker for disassembly
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
// tosca based result to c++ interpreter stack based result.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
// Result goes to address in L1_scratch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
address CppInterpreterGenerator::generate_tosca_to_stack_converter(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // A result is in the native abi result register from a native method call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // We need to return this result to the interpreter by pushing the result on the interpreter's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  // stack. This is relatively simple the destination is in L1_scratch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // i.e. L1_scratch is the first free element on the stack. If we "push" a return value we must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  // adjust L1_scratch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
      // !0 => true; 0 => false
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
      __ subcc(G0, O0, G0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
      __ addc(G0, 0, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
      __ st(O0, L1_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
      __ sub(L1_scratch, wordSize, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    // cannot use and3, 0xFFFF too big as immediate value!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    case T_CHAR   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
      __ sll(O0, 16, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
      __ srl(O0, 16, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
      __ st(O0, L1_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
      __ sub(L1_scratch, wordSize, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    case T_BYTE   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
      __ sll(O0, 24, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
      __ sra(O0, 24, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
      __ st(O0, L1_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
      __ sub(L1_scratch, wordSize, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    case T_SHORT  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
      __ sll(O0, 16, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
      __ sra(O0, 16, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
      __ st(O0, L1_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
      __ sub(L1_scratch, wordSize, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    case T_LONG   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
#ifndef _LP64
370
33ba64c16c1f 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 1
diff changeset
   186
#if defined(COMPILER2)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // All return values are where we want them, except for Longs.  C2 returns
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  // longs in G1 in the 32-bit build whereas the interpreter wants them in O0/O1.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  // Since the interpreter will return longs in G1 and O0/O1 in the 32bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  // build even if we are returning from interpreted we just do a little
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  // stupid shuffing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  // Note: I tried to make c2 return longs in O0/O1 and G1 so we wouldn't have to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // do this here. Unfortunately if we did a rethrow we'd see an machepilog node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  // first which would move g1 -> O0/O1 and destroy the exception we were throwing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
      __ stx(G1, L1_scratch, -wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
      // native result is in O0, O1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
      __ st(O1, L1_scratch, 0);                      // Low order
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      __ st(O0, L1_scratch, -wordSize);              // High order
370
33ba64c16c1f 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 1
diff changeset
   200
#endif /* COMPILER2 */
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
#else
370
33ba64c16c1f 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 1
diff changeset
   202
      __ stx(O0, L1_scratch, -wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
      __ sub(L1_scratch, 2*wordSize, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    case T_INT    :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
      __ st(O0, L1_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
      __ sub(L1_scratch, wordSize, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    case T_VOID   : /* nothing to do */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    case T_FLOAT  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
      __ stf(FloatRegisterImpl::S, F0, L1_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      __ sub(L1_scratch, wordSize, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    case T_DOUBLE :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
      // Every stack slot is aligned on 64 bit, However is this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
      // the correct stack slot on 64bit?? QQQ
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
      __ stf(FloatRegisterImpl::D, F0, L1_scratch, -wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
      __ sub(L1_scratch, 2*wordSize, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    case T_OBJECT :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
      __ verify_oop(O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      __ st_ptr(O0, L1_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
      __ sub(L1_scratch, wordSize, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    default       : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  __ retl();                          // return from interpreter activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  __ delayed()->nop();                // schedule this better
15116
af423dcb739c 8004537: replace AbstractAssembler emit_long with emit_int32
twisti
parents: 14745
diff changeset
   235
  NOT_PRODUCT(__ emit_int32(0);)       // marker for disassembly
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
address CppInterpreterGenerator::generate_stack_to_stack_converter(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  // A result is in the java expression stack of the interpreted method that has just
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // returned. Place this result on the java expression stack of the caller.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  // The current interpreter activation in Lstate is for the method just returning its
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // result. So we know that the result of this method is on the top of the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // execution stack (which is pre-pushed) and will be return to the top of the caller
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  // stack. The top of the callers stack is the bottom of the locals of the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  // activation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  // Because of the way activation are managed by the frame manager the value of esp is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  // below both the stack top of the current activation and naturally the stack top
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  // of the calling activation. This enable this routine to leave the return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // to the frame manager on the stack and do a vanilla return.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  // On entry: O0 - points to source (callee stack top)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  //           O1 - points to destination (caller stack top [i.e. free location])
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  // destroys O2, O3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    case T_VOID:  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    case T_FLOAT  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    case T_CHAR   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    case T_BYTE   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    case T_SHORT  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    case T_INT    :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
      // 1 word result
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
      __ ld(O0, 0, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
      __ st(O2, O1, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
      __ sub(O1, wordSize, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    case T_DOUBLE  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    case T_LONG    :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
      // return top two words on current expression stack to caller's expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
      // The caller's expression stack is adjacent to the current frame manager's intepretState
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
      // except we allocated one extra word for this intepretState so we won't overwrite it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
      // when we return a two word result.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
      __ ld_ptr(O0, 0, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
      __ st_ptr(O2, O1, -wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
      __ ld(O0, 0, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
      __ ld(O0, wordSize, O3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
      __ st(O3, O1, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
      __ st(O2, O1, -wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
      __ sub(O1, 2*wordSize, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    case T_OBJECT :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
      __ ld_ptr(O0, 0, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
      __ verify_oop(O2);                                               // verify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
      __ st_ptr(O2, O1, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
      __ sub(O1, wordSize, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    default       : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  __ retl();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  __ delayed()->nop(); // QQ schedule this better
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
address CppInterpreterGenerator::generate_stack_to_native_abi_converter(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  // A result is in the java expression stack of the interpreted method that has just
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  // returned. Place this result in the native abi that the caller expects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  // We are in a new frame registers we set must be in caller (i.e. callstub) frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  // Similar to generate_stack_to_stack_converter above. Called at a similar time from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  // frame manager execept in this situation the caller is native code (c1/c2/call_stub)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  // and so rather than return result onto caller's java expression stack we return the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // result in the expected location based on the native abi.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  // On entry: O0 - source (stack top)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  // On exit result in expected output register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  // QQQ schedule this better
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    case T_VOID:  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    case T_FLOAT  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
      __ ldf(FloatRegisterImpl::S, O0, 0, F0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    case T_CHAR   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    case T_BYTE   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    case T_SHORT  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    case T_INT    :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
      // 1 word result
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
      __ ld(O0, 0, O0->after_save());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    case T_DOUBLE  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
      __ ldf(FloatRegisterImpl::D, O0, 0, F0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
    case T_LONG    :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
      // return top two words on current expression stack to caller's expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
      // The caller's expression stack is adjacent to the current frame manager's interpretState
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
      // except we allocated one extra word for this intepretState so we won't overwrite it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
      // when we return a two word result.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
      __ ld_ptr(O0, 0, O0->after_save());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
      __ ld(O0, wordSize, O1->after_save());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
      __ ld(O0, 0, O0->after_save());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
#if defined(COMPILER2) && !defined(_LP64)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
      // C2 expects long results in G1 we can't tell if we're returning to interpreted
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
      // or compiled so just be safe use G1 and O0/O1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
      // Shift bits into high (msb) of G1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
      __ sllx(Otos_l1->after_save(), 32, G1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
      // Zero extend low bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
      __ srl (Otos_l2->after_save(), 0, Otos_l2->after_save());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
      __ or3 (Otos_l2->after_save(), G1, G1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
#endif /* COMPILER2 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    case T_OBJECT :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
      __ ld_ptr(O0, 0, O0->after_save());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
      __ verify_oop(O0->after_save());                                               // verify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    default       : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  __ retl();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  __ delayed()->nop();
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) + frame::pc_return_offset;
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
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
// Helpers for commoning out cases in the various type of method entries.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
// increment invocation count & check for overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
// Note: checking for negative value instead of overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
//       so we have a 'sticky' overflow test
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
// Lmethod: method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
// ??: invocation counter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
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: 15943
diff changeset
   406
  Label done;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   407
  const Register Rcounters = G3_scratch;
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   408
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   409
  __ ld_ptr(STATE(_method), G5_method);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   410
  __ get_method_counters(G5_method, Rcounters, done);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   411
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  // Update standard invocation counters
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   413
  __ increment_invocation_counter(Rcounters, O0, G4_scratch);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   414
  if (ProfileInterpreter) {
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   415
    Address interpreter_invocation_counter(Rcounters,
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   416
            in_bytes(MethodCounters::interpreter_invocation_counter_offset()));
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   417
    __ ld(interpreter_invocation_counter, G4_scratch);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   418
    __ inc(G4_scratch);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   419
    __ st(G4_scratch, interpreter_invocation_counter);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   422
  AddressLiteral invocation_limit((address)&InvocationCounter::InterpreterInvocationLimit);
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   423
  __ load_contents(invocation_limit, G3_scratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  __ cmp(O0, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  __ br(Assembler::greaterEqualUnsigned, false, Assembler::pn, *overflow);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  __ delayed()->nop();
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 15943
diff changeset
   427
  __ bind(done);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
address InterpreterGenerator::generate_empty_entry(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  // A method that does nothing but return...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  Label slow_path;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  // do nothing for empty methods (do not even increment invocation counter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  if ( UseFastEmptyMethods) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    // If we need a safepoint check, generate full interpreter entry.
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   440
    AddressLiteral sync_state(SafepointSynchronize::address_of_state());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
    __ load_contents(sync_state, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    __ br(Assembler::notEqual, false, Assembler::pn, frame_manager_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    // Code: _return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    __ retl();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    __ delayed()->mov(O5_savedSP, SP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   454
address InterpreterGenerator::generate_Reference_get_entry(void) {
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 15116
diff changeset
   455
#if INCLUDE_ALL_GCS
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   456
  if (UseG1GC) {
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   457
    // 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: 8676
diff changeset
   458
    //   * load the value in the referent field
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   459
    //   * passes that value to the pre-barrier.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   460
    //
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   461
    // 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: 8676
diff changeset
   462
    // referent in an SATB buffer if marking is active.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   463
    // This will cause concurrent marking to mark the referent
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   464
    // field as live.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   465
    Unimplemented();
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   466
  }
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 15116
diff changeset
   467
#endif // INCLUDE_ALL_GCS
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   468
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   469
  // 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: 8676
diff changeset
   470
  // Reference.get is an accessor
33070
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 25950
diff changeset
   471
  return NULL;
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   472
}
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
   473
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
// Interpreter stub for calling a native method. (C++ interpreter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
// This sets up a somewhat different looking stack for calling the native method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
// than the typical interpreter frame setup.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
address InterpreterGenerator::generate_native_entry(bool synchronized) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  // the following temporary registers are used during frame creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  const Register Gtmp1 = G3_scratch ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  const Register Gtmp2 = G1_scratch;
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
   486
  const Register RconstMethod = Gtmp1;
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   487
  const Address constMethod(G5_method, in_bytes(Method::const_offset()));
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   488
  const Address size_of_parameters(RconstMethod, in_bytes(ConstMethod::size_of_parameters_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  bool inc_counter  = UseCompiler || CountCompiledCalls;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  // make sure registers are different!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  assert_different_registers(G2_thread, G5_method, Gargs, Gtmp1, Gtmp2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   495
  const Address access_flags      (G5_method, in_bytes(Method::access_flags_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  Label Lentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  __ bind(Lentry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  const Register Glocals_size = G3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  assert_different_registers(Glocals_size, G4_scratch, Gframe_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  // make sure method is native & not abstract
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  // rethink these assertions - they can be simplified and shared (gri 2/25/2000)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  __ ld(access_flags, Gtmp1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
    Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
    __ btst(JVM_ACC_NATIVE, Gtmp1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
    __ br(Assembler::notZero, false, Assembler::pt, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    __ stop("tried to execute non-native method as native");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    __ btst(JVM_ACC_ABSTRACT, Gtmp1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    __ br(Assembler::zero, false, Assembler::pt, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
    __ stop("tried to execute abstract method as non-abstract");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
   524
  __ ld_ptr(constMethod, RconstMethod);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  __ lduh(size_of_parameters, Gtmp1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  __ sll(Gtmp1, LogBytesPerWord, Gtmp2);       // parameter size in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  __ add(Gargs, Gtmp2, Gargs);                 // points to first local + BytesPerWord
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  // NEW
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  __ add(Gargs, -wordSize, Gargs);             // points to first local[0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  // generate the code to allocate the interpreter stack frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  // NEW FRAME ALLOCATED HERE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
  // save callers original sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  // __ mov(SP, I5_savedSP->after_restore());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  generate_compute_interpreter_state(Lstate, G0, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  // At this point Lstate points to new interpreter state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   540
  const Address do_not_unlock_if_synchronized(G2_thread,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
      in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  // Since at this point in the method invocation the exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  // would try to exit the monitor of synchronized methods which hasn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  // been entered yet, we set the thread local variable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  // _do_not_unlock_if_synchronized to true. If any exception was thrown by
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
  // runtime, exception handling i.e. unlock_if_synchronized_method will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  // check this thread local flag.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
  // This flag has two effects, one is to force an unwind in the topmost
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  // interpreter frame and not perform an unlock while doing so.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  __ movbool(true, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  __ stbool(G3_scratch, do_not_unlock_if_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  // increment invocation counter and check for overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  // Note: checking for negative value instead of overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  //       so we have a 'sticky' overflow test (may be of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  //       importance as soon as we have true MT/MP)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  Label invocation_counter_overflow;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  if (inc_counter) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    generate_counter_incr(&invocation_counter_overflow, NULL, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  Label Lcontinue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  __ bind(Lcontinue);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
  bang_stack_shadow_pages(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  // reset the _do_not_unlock_if_synchronized flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  __ stbool(G0, do_not_unlock_if_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  // check for synchronized methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  // Must happen AFTER invocation_counter check, so method is not locked
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  // if counter overflows.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  if (synchronized) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    lock_method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
    // Don't see how G2_thread is preserved here...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    // __ verify_thread(); QQQ destroys L0,L1 can't use
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
    { Label ok;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
      __ ld_ptr(STATE(_method), G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
      __ ld(access_flags, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
      __ btst(JVM_ACC_SYNCHRONIZED, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
      __ br( Assembler::zero, false, Assembler::pt, ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
      __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
      __ stop("method needs synchronization");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
      __ bind(ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  // start execution
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
//   __ verify_thread(); kills L1,L2 can't  use at the moment
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  // jvmti/jvmpi support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  __ notify_method_entry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  // native call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  // (note that O0 is never an oop--at most it is a handle)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  // It is important not to smash any handles created by this call,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
  // until any oop handle in O0 is dereferenced.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  // (note that the space for outgoing params is preallocated)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  // get signature handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  Label pending_exception_present;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
    __ ld_ptr(STATE(_method), G5_method);
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   614
    __ ld_ptr(Address(G5_method, in_bytes(Method::signature_handler_offset())), G3_scratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
    __ tst(G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    __ brx(Assembler::notZero, false, Assembler::pt, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), G5_method, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
    __ ld_ptr(STATE(_method), G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   621
    Address exception_addr(G2_thread, in_bytes(Thread::pending_exception_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
    __ ld_ptr(exception_addr, G3_scratch);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
   623
    __ br_notnull_short(G3_scratch, Assembler::pn, pending_exception_present);
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   624
    __ ld_ptr(Address(G5_method, in_bytes(Method::signature_handler_offset())), G3_scratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  // Push a new frame so that the args will really be stored in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
  // Copy a few locals across so the new frame has the variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
  // we need but these values will be dead at the jni call and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
  // therefore not gc volatile like the values in the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  // frame (Lstate in particular)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  // Flush the state pointer to the register save area
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
  // Which is the only register we need for a stack walk.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
  __ st_ptr(Lstate, SP, (Lstate->sp_offset_in_saved_window() * wordSize) + STACK_BIAS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
  __ mov(Lstate, O1);         // Need to pass the state pointer across the frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
  // Calculate current frame size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
  __ sub(SP, FP, O3);         // Calculate negative of current frame size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
  __ save(SP, O3, SP);        // Allocate an identical sized frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  __ mov(I1, Lstate);          // In the "natural" register.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  // Note I7 has leftover trash. Slow signature handler will fill it in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  // should we get there. Normal jni call will set reasonable last_Java_pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  // below (and fix I7 so the stack trace doesn't have a meaningless frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  // in it).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  // call signature handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
  __ ld_ptr(STATE(_method), Lmethod);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  __ ld_ptr(STATE(_locals), Llocals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
  __ callr(G3_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
  __ ld_ptr(STATE(_thread), G2_thread);        // restore thread (shouldn't be needed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  { Label not_static;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    __ ld_ptr(STATE(_method), G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
    __ ld(access_flags, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
    __ btst(JVM_ACC_STATIC, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
    __ br( Assembler::zero, false, Assembler::pt, not_static);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    __ delayed()->
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
      // get native function entry point(O0 is a good temp until the very end)
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   668
       ld_ptr(Address(G5_method, in_bytes(Method::native_function_offset())), O0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
    // for static methods insert the mirror argument
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 10252
diff changeset
   670
    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   672
    __ ld_ptr(Address(G5_method, in_bytes(Method:: const_offset())), O1);
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   673
    __ ld_ptr(Address(O1, in_bytes(ConstMethod::constants_offset())), O1);
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   674
    __ ld_ptr(Address(O1, ConstantPool::pool_holder_offset_in_bytes()), O1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
    __ ld_ptr(O1, mirror_offset, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
    // where the mirror handle body is allocated:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
    if (!PrintSignatureHandlers)  // do not dirty the output with this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
    { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
      __ tst(O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
      __ brx(Assembler::notZero, false, Assembler::pt, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
      __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
      __ stop("mirror is missing");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
      __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
    __ st_ptr(O1, STATE(_oop_temp));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
    __ add(STATE(_oop_temp), O1);            // this is really an LEA not an add
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
    __ bind(not_static);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  // At this point, arguments have been copied off of stack into
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
  // their JNI positions, which are O1..O5 and SP[68..].
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
  // Oops are boxed in-place on the stack, with handles copied to arguments.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  // The result handler is in Lscratch.  O0 will shortly hold the JNIEnv*.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
  { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
    __ tst(O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
    __ brx(Assembler::notZero, false, Assembler::pt, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
    __ stop("native entry point is missing");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
  // setup the java frame anchor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
  // The scavenge function only needs to know that the PC of this frame is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
  // in the interpreter method entry code, it doesn't need to know the exact
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
  // PC and hence we can use O7 which points to the return address from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
  // previous call in the code stream (signature handler function)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  // The other trick is we set last_Java_sp to FP instead of the usual SP because
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  // we have pushed the extra frame in order to protect the volatile register(s)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  // in that frame when we return from the jni call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
  __ set_last_Java_frame(FP, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
  __ mov(O7, I7);  // make dummy interpreter frame look like one above,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
                   // not meaningless information that'll confuse me.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
  // flush the windows now. We don't care about the current (protection) frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
  // only the outer frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   728
  __ flushw();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
  // mark windows as flushed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  Address flags(G2_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
                in_bytes(JavaThread::frame_anchor_offset()) + in_bytes(JavaFrameAnchor::flags_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
  __ set(JavaFrameAnchor::flushed, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
  __ st(G3_scratch, flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
  // Transition from _thread_in_Java to _thread_in_native. We are already safepoint ready.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   738
  Address thread_state(G2_thread, in_bytes(JavaThread::thread_state_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  { Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
    __ ld(thread_state, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
    __ cmp(G3_scratch, _thread_in_Java);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
    __ br(Assembler::equal, false, Assembler::pt, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
    __ stop("Wrong thread state in native stub");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  __ set(_thread_in_native, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
  __ st(G3_scratch, thread_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
  // Call the jni method, using the delay slot to set the JNIEnv* argument.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
  __ callr(O0, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
  __ delayed()->
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
     add(G2_thread, in_bytes(JavaThread::jni_environment_offset()), O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
  __ ld_ptr(STATE(_thread), G2_thread);  // restore thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
  // must we block?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
  // Block, if necessary, before resuming in _thread_in_Java state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
  // In order for GC to work, don't clear the last_Java_sp until after blocking.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
  { Label no_block;
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   763
    AddressLiteral sync_state(SafepointSynchronize::address_of_state());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
    // Switch thread to "native transition" state before reading the synchronization state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
    // This additional state is necessary because reading and testing the synchronization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
    // state is not atomic w.r.t. GC, as this scenario demonstrates:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
    //     Java thread A, in _thread_in_native state, loads _not_synchronized and is preempted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
    //     VM thread changes sync state to synchronizing and suspends threads for GC.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
    //     Thread A is resumed to finish this native method, but doesn't block here since it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
    //     didn't see any synchronization is progress, and escapes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
    __ set(_thread_in_native_trans, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
    __ st(G3_scratch, thread_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
    if(os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
      // Write serialization page so VM thread can do a pseudo remote membar.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
      // We use the current thread pointer to calculate a thread specific
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
      // offset to write to within the page. This minimizes bus traffic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
      // due to cache line collision.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
      __ serialize_memory(G2_thread, G1_scratch, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
    __ load_contents(sync_state, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
    __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
    Label L;
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   786
    Address suspend_state(G2_thread, in_bytes(JavaThread::suspend_flags_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
    __ br(Assembler::notEqual, false, Assembler::pn, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
    __ delayed()->
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
      ld(suspend_state, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
    __ cmp(G3_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
    __ br(Assembler::equal, false, Assembler::pt, no_block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
    // Block.  Save any potential method result value before the operation and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
    // use a leaf call to leave the last_Java_frame setup undisturbed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
    save_native_result();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    __ call_VM_leaf(noreg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
                    CAST_FROM_FN_PTR(address, JavaThread::check_safepoint_and_suspend_for_native_trans),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
                    G2_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
    __ ld_ptr(STATE(_thread), G2_thread);  // restore thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
    // Restore any method result value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
    restore_native_result();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
    __ bind(no_block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
  // Clear the frame anchor now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
  __ reset_last_Java_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
  // Move the result handler address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
  __ mov(Lscratch, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
  // return possible result to the outer frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
#ifndef __LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
  __ mov(O0, I0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
  __ restore(O1, G0, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
  __ restore(O0, G0, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
#endif /* __LP64 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
  // Move result handler to expected register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
  __ mov(G3_scratch, Lscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
  // thread state is thread_in_native_trans. Any safepoint blocking has
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
  // happened in the trampoline we are ready to switch to thread_in_Java.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
  __ set(_thread_in_Java, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
  __ st(G3_scratch, thread_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
  // If we have an oop result store it where it will be safe for any further gc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
  // until we return now that we've released the handle it might be protected by
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
    Label no_oop, store_result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
    __ set((intptr_t)AbstractInterpreter::result_handler(T_OBJECT), G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
    __ cmp(G3_scratch, Lscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
    __ brx(Assembler::notEqual, false, Assembler::pt, no_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
    __ addcc(G0, O0, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
    __ brx(Assembler::notZero, true, Assembler::pt, store_result);     // if result is not NULL:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
    __ delayed()->ld_ptr(O0, 0, O0);                                   // unbox it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
    __ mov(G0, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
    __ bind(store_result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
    // Store it where gc will look for it and result handler expects it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
    __ st_ptr(O0, STATE(_oop_temp));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
    __ bind(no_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
  // reset handle block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
  __ ld_ptr(G2_thread, in_bytes(JavaThread::active_handles_offset()), G3_scratch);
23844
0c29a324ae14 8039146: Fix 64-bit store to int JNIHandleBlock::_top
goetz
parents: 23203
diff changeset
   856
  __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
  // handle exceptions (exception handling will handle unlocking!)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
  { Label L;
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   861
    Address exception_addr (G2_thread, in_bytes(Thread::pending_exception_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
    __ ld_ptr(exception_addr, Gtemp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
    __ tst(Gtemp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
    __ brx(Assembler::equal, false, Assembler::pt, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
    __ bind(pending_exception_present);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
    // With c++ interpreter we just leave it pending caller will do the correct thing. However...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
    // Like x86 we ignore the result of the native call and leave the method locked. This
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
    // seems wrong to leave things locked.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
    __ br(Assembler::always, false, Assembler::pt, StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
    __ delayed()->restore(I5_savedSP, G0, SP);  // remove interpreter frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
    __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
  // jvmdi/jvmpi support (preserves thread register)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
  __ notify_method_exit(true, ilgl, InterpreterMacroAssembler::NotifyJVMTI);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
  if (synchronized) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
    // save and restore any potential method result value around the unlocking operation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
    save_native_result();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
    const int entry_size            = frame::interpreter_frame_monitor_size() * wordSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
    // Get the initial monitor we allocated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
    __ sub(Lstate, entry_size, O1);                        // initial monitor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
    __ unlock_object(O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
    restore_native_result();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
#if defined(COMPILER2) && !defined(_LP64)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
  // C2 expects long results in G1 we can't tell if we're returning to interpreted
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  // or compiled so just be safe.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
  __ sllx(O0, 32, G1);          // Shift bits into high G1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
  __ srl (O1, 0, O1);           // Zero extend O1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
  __ or3 (O1, G1, G1);          // OR 64 bits into G1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
#endif /* COMPILER2 && !_LP64 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
    Label ok;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
    __ cmp(I5_savedSP, FP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
    __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
    __ stop("bad I5_savedSP value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
    __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
    __ bind(ok);
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
  // Calls result handler which POPS FRAME
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
  if (TraceJumps) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
    // Move target to register that is recordable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
    __ mov(Lscratch, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
    __ JMP(G3_scratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
    __ jmp(Lscratch, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
  if (inc_counter) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
    // handle invocation counter overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
    __ bind(invocation_counter_overflow);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
    generate_counter_overflow(Lcontinue);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
void CppInterpreterGenerator::generate_compute_interpreter_state(const Register state,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
                                                              const Register prev_state,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
                                                              bool native) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
  // On entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
  // G5_method - caller's method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
  // Gargs - points to initial parameters (i.e. locals[0])
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
  // G2_thread - valid? (C1 only??)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
  // "prev_state" - contains any previous frame manager state which we must save a link
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
  // On return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
  // "state" is a pointer to the newly allocated  state object. We must allocate and initialize
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
  // a new interpretState object and the method expression stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
  assert_different_registers(state, prev_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
  assert_different_registers(prev_state, G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  const Register Gtmp = G3_scratch;
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   951
  const Address constMethod       (G5_method, in_bytes(Method::const_offset()));
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   952
  const Address access_flags      (G5_method, in_bytes(Method::access_flags_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
  // slop factor is two extra slots on the expression stack so that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
  // we always have room to store a result when returning from a call without parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
  // that returns a result.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
  const int slop_factor = 2*wordSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
  const int fixed_size = ((sizeof(BytecodeInterpreter) + slop_factor) >> LogBytesPerWord) + // what is the slop factor?
17875
9d4aa49a1d76 8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents: 17000
diff changeset
   961
                         Method::extra_stack_entries() + // extra stack for jsr 292
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
                         frame::memory_parameter_word_sp_offset +  // register save area + param window
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
                         (native ?  frame::interpreter_frame_extra_outgoing_argument_words : 0); // JNI, class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
  // XXX G5_method valid
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
  // Now compute new frame size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
  if (native) {
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
   970
    const Register RconstMethod = Gtmp;
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
   971
    const Address size_of_parameters(RconstMethod, in_bytes(ConstMethod::size_of_parameters_offset()));
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
   972
    __ ld_ptr(constMethod, RconstMethod);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
    __ lduh( size_of_parameters, Gtmp );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
    __ calc_mem_param_words(Gtmp, Gtmp);     // space for native call parameters passed on the stack in words
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
  } else {
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13728
diff changeset
   976
    // Full size expression stack
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13728
diff changeset
   977
    __ ld_ptr(constMethod, Gtmp);
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13728
diff changeset
   978
    __ lduh(Gtmp, in_bytes(ConstMethod::max_stack_offset()), Gtmp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
  __ add(Gtmp, fixed_size, Gtmp);           // plus the fixed portion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
  __ neg(Gtmp);                               // negative space for stack/parameters in words
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
  __ and3(Gtmp, -WordsPerLong, Gtmp);        // make multiple of 2 (SP must be 2-word aligned)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
  __ sll(Gtmp, LogBytesPerWord, Gtmp);       // negative space for frame in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
  // Need to do stack size check here before we fault on large frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
  Label stack_ok;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
  const int max_pages = StackShadowPages > (StackRedPages+StackYellowPages) ? StackShadowPages :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
                                                                              (StackRedPages+StackYellowPages);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
  __ ld_ptr(G2_thread, in_bytes(Thread::stack_base_offset()), O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
  __ ld_ptr(G2_thread, in_bytes(Thread::stack_size_offset()), O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
  // compute stack bottom
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
  __ sub(O0, O1, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
  // Avoid touching the guard pages
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
  // Also a fudge for frame size of BytecodeInterpreter::run
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
  // It varies from 1k->4k depending on build type
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
  const int fudge = 6 * K;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
  __ set(fudge + (max_pages * os::vm_page_size()), O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
  __ add(O0, O1, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
  __ sub(O0, Gtmp, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
  __ cmp(SP, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
  __ brx(Assembler::greaterUnsigned, false, Assembler::pt, stack_ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
     // throw exception return address becomes throwing pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
  __ call_VM(Oexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_StackOverflowError));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
  __ stop("never reached");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
  __ bind(stack_ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
  __ save(SP, Gtmp, SP);                      // setup new frame and register window
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
  // New window I7 call_stub or previous activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
  // O6 - register save area, BytecodeInterpreter just below it, args/locals just above that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
  __ sub(FP, sizeof(BytecodeInterpreter), state);        // Point to new Interpreter state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
  __ add(state, STACK_BIAS, state );         // Account for 64bit bias
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
#define XXX_STATE(field_name) state, in_bytes(byte_offset_of(BytecodeInterpreter, field_name))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
  // Initialize a new Interpreter state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
  // orig_sp - caller's original sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
  // G2_thread - thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
  // Gargs - &locals[0] (unbiased?)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
  // G5_method - method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
  // SP (biased) - accounts for full size java stack, BytecodeInterpreter object, register save area, and register parameter save window
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
  __ set(0xdead0004, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
  __ st_ptr(Gargs, XXX_STATE(_locals));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
  __ st_ptr(G0, XXX_STATE(_oop_temp));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
  __ st_ptr(state, XXX_STATE(_self_link));                // point to self
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
  __ st_ptr(prev_state->after_save(), XXX_STATE(_prev_link)); // Chain interpreter states
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
  __ st_ptr(G2_thread, XXX_STATE(_thread));               // Store javathread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
  if (native) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
    __ st_ptr(G0, XXX_STATE(_bcp));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
  } else {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1050
    __ ld_ptr(G5_method, in_bytes(Method::const_offset()), O2); // get ConstMethod*
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1051
    __ add(O2, in_bytes(ConstMethod::codes_offset()), O2);        // get bcp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
    __ st_ptr(O2, XXX_STATE(_bcp));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
  __ st_ptr(G0, XXX_STATE(_mdx));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
  __ st_ptr(G5_method, XXX_STATE(_method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
  __ set((int) BytecodeInterpreter::method_entry, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
  __ st(O1, XXX_STATE(_msg));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 12103
diff changeset
  1061
  __ ld_ptr(constMethod, O3);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1062
  __ ld_ptr(O3, in_bytes(ConstMethod::constants_offset()), O3);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1063
  __ ld_ptr(O3, ConstantPool::cache_offset_in_bytes(), O2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
  __ st_ptr(O2, XXX_STATE(_constants));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
  __ st_ptr(G0, XXX_STATE(_result._to_call._callee));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
  // Monitor base is just start of BytecodeInterpreter object;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
  __ mov(state, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
  __ st_ptr(O2, XXX_STATE(_monitor_base));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
  // Do we need a monitor for synchonized method?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
    __ ld(access_flags, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
    Label done;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
    Label got_obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
    __ btst(JVM_ACC_SYNCHRONIZED, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
    __ br( Assembler::zero, false, Assembler::pt, done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 10252
diff changeset
  1080
    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
    __ delayed()->btst(JVM_ACC_STATIC, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
    __ ld_ptr(XXX_STATE(_locals), O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
    __ br( Assembler::zero, true, Assembler::pt, got_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
    __ delayed()->ld_ptr(O1, 0, O1);                  // get receiver for not-static case
12937
0032fb2caff6 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 12103
diff changeset
  1085
    __ ld_ptr(constMethod, O1);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1086
    __ ld_ptr( O1, in_bytes(ConstMethod::constants_offset()), O1);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1087
    __ ld_ptr( O1, ConstantPool::pool_holder_offset_in_bytes(), O1);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1088
    // lock the mirror, not the Klass*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
    __ ld_ptr( O1, mirror_offset, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
    __ bind(got_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
  #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
    __ tst(O1);
12103
2ceb7aff05e3 7150046: SIGILL on sparcv9 fastdebug
coleenp
parents: 11430
diff changeset
  1095
    __ breakpoint_trap(Assembler::zero, Assembler::ptr_cc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
  #endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
    const int entry_size            = frame::interpreter_frame_monitor_size() * wordSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
    __ sub(SP, entry_size, SP);                         // account for initial monitor
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
    __ sub(O2, entry_size, O2);                        // initial monitor
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
    __ st_ptr(O1, O2, BasicObjectLock::obj_offset_in_bytes()); // and allocate it for interpreter use
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
    __ bind(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
  // Remember initial frame bottom
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
  __ st_ptr(SP, XXX_STATE(_frame_bottom));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
  __ st_ptr(O2, XXX_STATE(_stack_base));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
  __ sub(O2, wordSize, O2);                    // prepush
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
  __ st_ptr(O2, XXX_STATE(_stack));                // PREPUSH
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
14586
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13728
diff changeset
  1114
  // Full size expression stack
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13728
diff changeset
  1115
  __ ld_ptr(constMethod, O3);
1262473e8fc1 8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents: 13728
diff changeset
  1116
  __ lduh(O3, in_bytes(ConstMethod::max_stack_offset()), O3);
17875
9d4aa49a1d76 8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents: 17000
diff changeset
  1117
  __ inc(O3, Method::extra_stack_entries());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
  __ sll(O3, LogBytesPerWord, O3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
  __ sub(O2, O3, O3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
//  __ sub(O3, wordSize, O3);                    // so prepush doesn't look out of bounds
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
  __ st_ptr(O3, XXX_STATE(_stack_limit));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
  if (!native) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
    // Code to initialize locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
    Register init_value = noreg;    // will be G0 if we must clear locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
    // Now zero locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
    if (true /* zerolocals */ || ClearInterpreterLocals) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
      // explicitly initialize locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
      init_value = G0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
      // initialize locals to a garbage pattern for better debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
      init_value = O3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
      __ set( 0x0F0F0F0F, init_value );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
    #endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
    if (init_value != noreg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
      Label clear_loop;
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
  1141
      const Register RconstMethod = O1;
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  1142
      const Address size_of_parameters(RconstMethod, in_bytes(ConstMethod::size_of_parameters_offset()));
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  1143
      const Address size_of_locals    (RconstMethod, in_bytes(ConstMethod::size_of_locals_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
      // NOTE: If you change the frame layout, this code will need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
      // be updated!
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
  1147
      __ ld_ptr( constMethod, RconstMethod );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
      __ lduh( size_of_locals, O2 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
      __ lduh( size_of_parameters, O1 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
      __ sll( O2, LogBytesPerWord, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
      __ sll( O1, LogBytesPerWord, O1 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
      __ ld_ptr(XXX_STATE(_locals), L2_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
      __ sub( L2_scratch, O2, O2 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
      __ sub( L2_scratch, O1, O1 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
      __ bind( clear_loop );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
      __ inc( O2, wordSize );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
      __ cmp( O2, O1 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
      __ br( Assembler::lessEqualUnsigned, true, Assembler::pt, clear_loop );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
      __ delayed()->st_ptr( init_value, O2, 0 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
// Find preallocated  monitor and lock method (C++ interpreter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
//
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33070
diff changeset
  1167
void CppInterpreterGenerator::lock_method() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
// Lock the current method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
// Destroys registers L2_scratch, L3_scratch, O0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
// Find everything relative to Lstate
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
  __ ld_ptr(STATE(_method), L2_scratch);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1175
  __ ld(L2_scratch, in_bytes(Method::access_flags_offset()), O0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
 { Label ok;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
   __ btst(JVM_ACC_SYNCHRONIZED, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
   __ br( Assembler::notZero, false, Assembler::pt, ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
   __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
   __ stop("method doesn't need synchronization");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
   __ bind(ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
  // monitor is already allocated at stack base
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
  // and the lockee is already present
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
  __ ld_ptr(STATE(_stack_base), L2_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
  __ ld_ptr(L2_scratch, BasicObjectLock::obj_offset_in_bytes(), O0);   // get object
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
  __ lock_object(L2_scratch, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
//  Generate code for handling resuming a deopted method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
void CppInterpreterGenerator::generate_deopt_handling() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
  Label return_from_deopt_common;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
  deopt_frame_manager_return_atos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
  // O0/O1 live
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1203
  __ ba(return_from_deopt_common);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
  __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_OBJECT), L3_scratch);    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
  deopt_frame_manager_return_btos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
  // O0/O1 live
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1211
  __ ba(return_from_deopt_common);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
  __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_BOOLEAN), L3_scratch);    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
  deopt_frame_manager_return_itos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
  // O0/O1 live
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1218
  __ ba(return_from_deopt_common);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
  __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_INT), L3_scratch);    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
  deopt_frame_manager_return_ltos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
#if !defined(_LP64) && defined(COMPILER2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
  // All return values are where we want them, except for Longs.  C2 returns
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
  // longs in G1 in the 32-bit build whereas the interpreter wants them in O0/O1.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
  // Since the interpreter will return longs in G1 and O0/O1 in the 32bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
  // build even if we are returning from interpreted we just do a little
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
  // stupid shuffing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
  // Note: I tried to make c2 return longs in O0/O1 and G1 so we wouldn't have to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
  // do this here. Unfortunately if we did a rethrow we'd see an machepilog node
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
  // first which would move g1 -> O0/O1 and destroy the exception we were throwing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
  __ srl (G1, 0,O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
  __ srlx(G1,32,O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
#endif /* !_LP64 && COMPILER2 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
  // O0/O1 live
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1238
  __ ba(return_from_deopt_common);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
  __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_LONG), L3_scratch);    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
  deopt_frame_manager_return_ftos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
  // O0/O1 live
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1245
  __ ba(return_from_deopt_common);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
  __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_FLOAT), L3_scratch);    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
  deopt_frame_manager_return_dtos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
  // O0/O1 live
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1252
  __ ba(return_from_deopt_common);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
  __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_DOUBLE), L3_scratch);    // Result stub address array index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
  // deopt needs to jump to here to enter the interpreter (return a result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
  deopt_frame_manager_return_vtos  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
  // O0/O1 live
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
  __ set(AbstractInterpreter::BasicType_as_index(T_VOID), L3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
  // Deopt return common
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
  // an index is present that lets us move any possible result being
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
  // return to the interpreter's stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
  __ bind(return_from_deopt_common);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
  // Result if any is in native abi result (O0..O1/F0..F1). The java expression
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
  // stack is in the state that the  calling convention left it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
  // Copy the result from native abi result and place it on java expression stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
  // Current interpreter state is present in Lstate
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
  // Get current pre-pushed top of interpreter stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
  // Any result (if any) is in native abi
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
  // result type index is in L3_scratch
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
  __ ld_ptr(STATE(_stack), L1_scratch);                                          // get top of java expr stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
  __ set((intptr_t)CppInterpreter::_tosca_to_stack, L4_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
  __ sll(L3_scratch, LogBytesPerWord, L3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
  __ ld_ptr(L4_scratch, L3_scratch, Lscratch);                                       // get typed result converter address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
  __ jmpl(Lscratch, G0, O7);                                         // and convert it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
  // L1_scratch points to top of stack (prepushed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
  __ st_ptr(L1_scratch, STATE(_stack));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
// Generate the code to handle a more_monitors message from the c++ interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
void CppInterpreterGenerator::generate_more_monitors() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
  Label entry, loop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
  const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
  // 1. compute new pointers                                // esp: old expression stack top
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
  __ delayed()->ld_ptr(STATE(_stack_base), L4_scratch);            // current expression stack bottom
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
  __ sub(L4_scratch, entry_size, L4_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
  __ st_ptr(L4_scratch, STATE(_stack_base));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
  __ sub(SP, entry_size, SP);                  // Grow stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1300
  __ st_ptr(SP, STATE(_frame_bottom));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
  __ ld_ptr(STATE(_stack_limit), L2_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
  __ sub(L2_scratch, entry_size, L2_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
  __ st_ptr(L2_scratch, STATE(_stack_limit));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
  __ ld_ptr(STATE(_stack), L1_scratch);                // Get current stack top
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
  __ sub(L1_scratch, entry_size, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
  __ st_ptr(L1_scratch, STATE(_stack));
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1309
  __ ba(entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
  __ delayed()->add(L1_scratch, wordSize, L1_scratch);        // first real entry (undo prepush)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
  // 2. move expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
  __ bind(loop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
  __ st_ptr(L3_scratch, Address(L1_scratch, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
  __ add(L1_scratch, wordSize, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
  __ bind(entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
  __ cmp(L1_scratch, L4_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
  __ br(Assembler::notEqual, false, Assembler::pt, loop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
  __ delayed()->ld_ptr(L1_scratch, entry_size, L3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
  // now zero the slot so we can find it.
370
33ba64c16c1f 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 1
diff changeset
  1323
  __ st_ptr(G0, L4_scratch, BasicObjectLock::obj_offset_in_bytes());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
// Initial entry to C++ interpreter from the call_stub.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
// This entry point is called the frame manager since it handles the generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
// of interpreter activation frames via requests directly from the vm (via call_stub)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
// and via requests from the interpreter. The requests from the call_stub happen
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
// directly thru the entry point. Requests from the interpreter happen via returning
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
// from the interpreter and examining the message the interpreter has returned to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
// the frame manager. The frame manager can take the following requests:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
// NO_REQUEST - error, should never happen.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
// MORE_MONITORS - need a new monitor. Shuffle the expression stack on down and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
//                 allocate a new monitor.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
// CALL_METHOD - setup a new activation to call a new method. Very similar to what
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
//               happens during entry during the entry via the call stub.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
// RETURN_FROM_METHOD - remove an activation. Return to interpreter or call stub.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
// Arguments:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
//
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1344
// ebx: Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
// ecx: receiver - unused (retrieved from stack as needed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
// esi: previous frame manager state (NULL from the call_stub/c1/c2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
// Stack layout at entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
// [ return address     ] <--- esp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
// [ parameter n        ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
//   ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
// [ parameter 1        ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
// [ expression stack   ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
// We are free to blow any registers we like because the call_stub which brought us here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
// initially has preserved the callee save registers already.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
static address interpreter_frame_manager = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
  #define VALIDATE_STATE(scratch, marker)                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
  {                                                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
    Label skip;                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
    __ ld_ptr(STATE(_self_link), scratch);                        \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
    __ cmp(Lstate, scratch);                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
    __ brx(Assembler::equal, false, Assembler::pt, skip);         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
    __ delayed()->nop();                                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
    __ breakpoint_trap();                                         \
15116
af423dcb739c 8004537: replace AbstractAssembler emit_long with emit_int32
twisti
parents: 14745
diff changeset
  1374
    __ emit_int32(marker);                                         \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
    __ bind(skip);                                                \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
  #define VALIDATE_STATE(scratch, marker)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
#endif /* ASSERT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
void CppInterpreterGenerator::adjust_callers_stack(Register args) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
// Adjust caller's stack so that all the locals can be contiguous with
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
// the parameters.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
// Worries about stack overflow make this a pain.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
// Destroys args, G3_scratch, G3_scratch
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
// In/Out O5_savedSP (sender's original SP)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
//  assert_different_registers(state, prev_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
  const Register Gtmp = G3_scratch;
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  1392
  const Register RconstMethod = G3_scratch;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
  const Register tmp = O2;
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  1394
  const Address constMethod(G5_method, in_bytes(Method::const_offset()));
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  1395
  const Address size_of_parameters(RconstMethod, in_bytes(ConstMethod::size_of_parameters_offset()));
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  1396
  const Address size_of_locals    (RconstMethod, in_bytes(ConstMethod::size_of_locals_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
  1398
  __ ld_ptr(constMethod, RconstMethod);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
  __ lduh(size_of_parameters, tmp);
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
  1400
  __ sll(tmp, LogBytesPerWord, Gargs);       // parameter size in bytes
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
  1401
  __ add(args, Gargs, Gargs);                // points to first local + BytesPerWord
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
  // NEW
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
  __ add(Gargs, -wordSize, Gargs);             // points to first local[0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
  // determine extra space for non-argument locals & adjust caller's SP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
  // Gtmp1: parameter size in words
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
  __ lduh(size_of_locals, Gtmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
  __ compute_extra_locals_size_in_bytes(tmp, Gtmp, Gtmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
#if 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
  // c2i adapters place the final interpreter argument in the register save area for O0/I0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
  // the call_stub will place the final interpreter argument at
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
  // frame::memory_parameter_word_sp_offset. This is mostly not noticable for either asm
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
  // or c++ interpreter. However with the c++ interpreter when we do a recursive call
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
  // and try to make it look good in the debugger we will store the argument to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
  // RecursiveInterpreterActivation in the register argument save area. Without allocating
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
  // extra space for the compiler this will overwrite locals in the local array of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
  // interpreter.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
  // QQQ still needed with frameless adapters???
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
  const int c2i_adjust_words = frame::memory_parameter_word_sp_offset - frame::callee_register_argument_save_area_sp_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
  __ add(Gtmp, c2i_adjust_words*wordSize, Gtmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
#endif // 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
  __ sub(SP, Gtmp, SP);                      // just caller's frame for the additional space we need.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
address InterpreterGenerator::generate_normal_entry(bool synchronized) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1431
  // G5_method: Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
  // G2_thread: thread (unused)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
  // Gargs:   bottom of args (sender_sp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1434
  // O5: sender's sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
  // A single frame manager is plenty as we don't specialize for synchronized. We could and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
  // the code is pretty much ready. Would need to change the test below and for good measure
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
  // modify generate_interpreter_state to only do the (pre) sync stuff stuff for synchronized
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
  // routines. Not clear this is worth it yet.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
  if (interpreter_frame_manager) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
    return interpreter_frame_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
  __ bind(frame_manager_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
  // the following temporary registers are used during frame creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
  const Register Gtmp1 = G3_scratch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1449
  // const Register Lmirror = L1;     // native mirror (native calls only)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  1451
  const Address constMethod       (G5_method, in_bytes(Method::const_offset()));
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  1452
  const Address access_flags      (G5_method, in_bytes(Method::access_flags_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1455
  __ mov(G0, prevState);                                                 // no current activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
  Label re_dispatch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
  __ bind(re_dispatch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
  // Interpreter needs to have locals completely contiguous. In order to do that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
  // We must adjust the caller's stack pointer for any locals beyond just the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
  // parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
  adjust_callers_stack(Gargs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
  // O5_savedSP still contains sender's sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
  // NEW FRAME
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
  generate_compute_interpreter_state(Lstate, prevState, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
  // At this point a new interpreter frame and state object are created and initialized
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
  // Lstate has the pointer to the new activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
  // Any stack banging or limit check should already be done.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
  Label call_interpreter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1479
  __ bind(call_interpreter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
#if 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
  __ set(0xdead002, Lmirror);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
  __ set(0xdead002, L2_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
  __ set(0xdead003, L3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
  __ set(0xdead004, L4_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
  __ set(0xdead005, Lscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
  __ set(0xdead006, Lscratch2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
  __ set(0xdead007, L7_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
  __ set(0xdeaf002, O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
  __ set(0xdeaf003, O3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
  __ set(0xdeaf004, O4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
  __ set(0xdeaf005, O5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
  // Call interpreter (stack bang complete) enter here if message is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
  // set and we know stack size is valid
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
  Label call_interpreter_2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
  __ bind(call_interpreter_2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
    Label skip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
    __ ld_ptr(STATE(_frame_bottom), G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
    __ cmp(G3_scratch, SP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
    __ brx(Assembler::equal, false, Assembler::pt, skip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
    __ stop("SP not restored to frame bottom");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
    __ bind(skip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
  VALIDATE_STATE(G3_scratch, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
  __ set_last_Java_frame(SP, noreg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
  __ mov(Lstate, O0);                 // (arg) pointer to current state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
  __ call(CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
                           JvmtiExport::can_post_interpreter_events() ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
                                                                  BytecodeInterpreter::runWithChecks
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
                                                                : BytecodeInterpreter::run),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
         relocInfo::runtime_call_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
  __ ld_ptr(STATE(_thread), G2_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
  __ reset_last_Java_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
  // examine msg from interpreter to determine next action
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
  __ ld_ptr(STATE(_thread), G2_thread);                                  // restore G2_thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
  __ ld(STATE(_msg), L1_scratch);                                       // Get new message
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
  Label call_method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
  Label return_from_interpreted_method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
  Label throw_exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
  Label do_OSR;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1540
  Label bad_msg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
  Label resume_interpreter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1543
  __ cmp(L1_scratch, (int)BytecodeInterpreter::call_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1544
  __ br(Assembler::equal, false, Assembler::pt, call_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
  __ delayed()->cmp(L1_scratch, (int)BytecodeInterpreter::return_from_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1546
  __ br(Assembler::equal, false, Assembler::pt, return_from_interpreted_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
  __ delayed()->cmp(L1_scratch, (int)BytecodeInterpreter::throwing_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
  __ br(Assembler::equal, false, Assembler::pt, throw_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1549
  __ delayed()->cmp(L1_scratch, (int)BytecodeInterpreter::do_osr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1550
  __ br(Assembler::equal, false, Assembler::pt, do_OSR);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1551
  __ delayed()->cmp(L1_scratch, (int)BytecodeInterpreter::more_monitors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1552
  __ br(Assembler::notEqual, false, Assembler::pt, bad_msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1554
  // Allocate more monitor space, shuffle expression stack....
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1555
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1556
  generate_more_monitors();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1558
  // new monitor slot allocated, resume the interpreter.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1559
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1560
  __ set((int)BytecodeInterpreter::got_monitors, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1561
  VALIDATE_STATE(G3_scratch, 5);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1562
  __ ba(call_interpreter);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1563
  __ delayed()->st(L1_scratch, STATE(_msg));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1564
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1565
  // uncommon trap needs to jump to here to enter the interpreter (re-execute current bytecode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1566
  unctrap_frame_manager_entry  = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1568
  // QQQ what message do we send
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1569
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1570
  __ ba(call_interpreter);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1571
  __ delayed()->ld_ptr(STATE(_frame_bottom), SP);                  // restore to full stack frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1572
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1573
  //=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1574
  // Returning from a compiled method into a deopted method. The bytecode at the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1575
  // bcp has completed. The result of the bytecode is in the native abi (the tosca
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1576
  // for the template based interpreter). Any stack space that was used by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1577
  // bytecode that has completed has been removed (e.g. parameters for an invoke)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1578
  // so all that we have to do is place any pending result on the expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1579
  // and resume execution on the next bytecode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
  generate_deopt_handling();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
  // ready to resume the interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
  __ set((int)BytecodeInterpreter::deopt_resume, L1_scratch);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1586
  __ ba(call_interpreter);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
  __ delayed()->st(L1_scratch, STATE(_msg));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
  // Current frame has caught an exception we need to dispatch to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
  // handler. We can get here because a native interpreter frame caught
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
  // an exception in which case there is no handler and we must rethrow
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1592
  // If it is a vanilla interpreted frame the we simply drop into the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1593
  // interpreter and let it do the lookup.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1594
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
  Interpreter::_rethrow_exception_entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1597
  Label return_with_exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1598
  Label unwind_and_forward;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1599
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1600
  // O0: exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
  // O7: throwing pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1603
  // We want exception in the thread no matter what we ultimately decide about frame type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
23203
76c2a23e2537 8036146: make CPP interpreter build again
roland
parents: 21198
diff changeset
  1605
  Address exception_addr (G2_thread, in_bytes(Thread::pending_exception_offset()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
  __ verify_thread();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
  __ st_ptr(O0, exception_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1609
  // get the Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
  __ ld_ptr(STATE(_method), G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
  // if this current frame vanilla or native?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
  __ ld(access_flags, Gtmp1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
  __ btst(JVM_ACC_NATIVE, Gtmp1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
  __ br(Assembler::zero, false, Assembler::pt, return_with_exception);  // vanilla interpreted frame handle directly
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
  // We drop thru to unwind a native interpreted frame with a pending exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
  // We jump here for the initial interpreter frame with exception pending
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
  // We unwind the current acivation and forward it to our caller.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1623
  __ bind(unwind_and_forward);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1624
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1625
  // Unwind frame and jump to forward exception. unwinding will place throwing pc in O7
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
  // as expected by forward_exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1627
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1628
  __ restore(FP, G0, SP);                  // unwind interpreter state frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1629
  __ br(Assembler::always, false, Assembler::pt, StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
  __ delayed()->mov(I5_savedSP->after_restore(), SP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
  // Return point from a call which returns a result in the native abi
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
  // (c1/c2/jni-native). This result must be processed onto the java
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1634
  // expression stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1636
  // A pending exception may be present in which case there is no result present
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1637
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1638
  address return_from_native_method = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1639
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
  VALIDATE_STATE(G3_scratch, 6);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
  // Result if any is in native abi result (O0..O1/F0..F1). The java expression
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1643
  // stack is in the state that the  calling convention left it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1644
  // Copy the result from native abi result and place it on java expression stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1645
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1646
  // Current interpreter state is present in Lstate
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1647
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1648
  // Exception pending?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
  __ ld_ptr(STATE(_frame_bottom), SP);                             // restore to full stack frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
  __ ld_ptr(exception_addr, Lscratch);                                         // get any pending exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1652
  __ tst(Lscratch);                                                            // exception pending?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1653
  __ brx(Assembler::notZero, false, Assembler::pt, return_with_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1656
  // Process the native abi result to java expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1658
  __ ld_ptr(STATE(_result._to_call._callee), L4_scratch);                        // called method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
  __ ld_ptr(STATE(_stack), L1_scratch);                                          // get top of java expr stack
14745
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
  1660
  // get parameter size
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
  1661
  __ ld_ptr(L4_scratch, in_bytes(Method::const_offset()), L2_scratch);
03904dd8649b 8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents: 14586
diff changeset
  1662
  __ lduh(L2_scratch, in_bytes(ConstMethod::size_of_parameters_offset()), L2_scratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1663
  __ sll(L2_scratch, LogBytesPerWord, L2_scratch     );                           // parameter size in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
  __ add(L1_scratch, L2_scratch, L1_scratch);                                      // stack destination for result
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1665
  __ ld(L4_scratch, in_bytes(Method::result_index_offset()), L3_scratch); // called method result type index
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1666
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1667
  // tosca is really just native abi
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1668
  __ set((intptr_t)CppInterpreter::_tosca_to_stack, L4_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1669
  __ sll(L3_scratch, LogBytesPerWord, L3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1670
  __ ld_ptr(L4_scratch, L3_scratch, Lscratch);                                       // get typed result converter address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
  __ jmpl(Lscratch, G0, O7);                                                   // and convert it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1672
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1673
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1674
  // L1_scratch points to top of stack (prepushed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1675
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1676
  __ ba(resume_interpreter);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1677
  __ delayed()->mov(L1_scratch, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1678
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1679
  // An exception is being caught on return to a vanilla interpreter frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1680
  // Empty the stack and resume interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1682
  __ bind(return_with_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1683
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
  __ ld_ptr(STATE(_frame_bottom), SP);                             // restore to full stack frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
  __ ld_ptr(STATE(_stack_base), O1);                               // empty java expression stack
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1686
  __ ba(resume_interpreter);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
  __ delayed()->sub(O1, wordSize, O1);                             // account for prepush
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1688
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1689
  // Return from interpreted method we return result appropriate to the caller (i.e. "recursive"
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1690
  // interpreter call, or native) and unwind this interpreter activation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1691
  // All monitors should be unlocked.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1693
  __ bind(return_from_interpreted_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1695
  VALIDATE_STATE(G3_scratch, 7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1696
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1697
  Label return_to_initial_caller;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
  // Interpreted result is on the top of the completed activation expression stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1700
  // We must return it to the top of the callers stack if caller was interpreted
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1701
  // otherwise we convert to native abi result and return to call_stub/c1/c2
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1702
  // The caller's expression stack was truncated by the call however the current activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
  // has enough stuff on the stack that we have usable space there no matter what. The
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
  // other thing that makes it easy is that the top of the caller's stack is stored in STATE(_locals)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
  // for the current activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
  __ ld_ptr(STATE(_prev_link), L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
  __ ld_ptr(STATE(_method), L2_scratch);                               // get method just executed
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1709
  __ ld(L2_scratch, in_bytes(Method::result_index_offset()), L2_scratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
  __ tst(L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
  __ brx(Assembler::zero, false, Assembler::pt, return_to_initial_caller);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
  __ delayed()->sll(L2_scratch, LogBytesPerWord, L2_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1714
  // Copy result to callers java stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
  __ set((intptr_t)CppInterpreter::_stack_to_stack, L4_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
  __ ld_ptr(L4_scratch, L2_scratch, Lscratch);                          // get typed result converter address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1718
  __ ld_ptr(STATE(_stack), O0);                                       // current top (prepushed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1719
  __ ld_ptr(STATE(_locals), O1);                                      // stack destination
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1721
  // O0 - will be source, O1 - will be destination (preserved)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1722
  __ jmpl(Lscratch, G0, O7);                                          // and convert it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1723
  __ delayed()->add(O0, wordSize, O0);                                // get source (top of current expr stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1724
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
  // O1 == &locals[0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1726
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
  // Result is now on caller's stack. Just unwind current activation and resume
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1728
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1729
  Label unwind_recursive_activation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1730
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1731
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
  __ bind(unwind_recursive_activation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1733
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1734
  // O1 == &locals[0] (really callers stacktop) for activation now returning
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
  // returning to interpreter method from "recursive" interpreter call
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
  // result converter left O1 pointing to top of the( prepushed) java stack for method we are returning
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1737
  // to. Now all we must do is unwind the state from the completed call
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1738
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
  // Must restore stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
  VALIDATE_STATE(G3_scratch, 8);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
  // Return to interpreter method after a method call (interpreted/native/c1/c2) has completed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1743
  // Result if any is already on the caller's stack. All we must do now is remove the now dead
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1744
  // frame and tell interpreter to resume.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1746
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
  __ mov(O1, I1);                                                     // pass back new stack top across activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1748
  // POP FRAME HERE ==================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
  __ restore(FP, G0, SP);                                             // unwind interpreter state frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1750
  __ ld_ptr(STATE(_frame_bottom), SP);                                // restore to full stack frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1752
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
  // Resume the interpreter. The current frame contains the current interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
  // state object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
  // O1 == new java stack pointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
  __ bind(resume_interpreter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
  VALIDATE_STATE(G3_scratch, 10);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1761
  // A frame we have already used before so no need to bang stack so use call_interpreter_2 entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
  __ set((int)BytecodeInterpreter::method_resume, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
  __ st(L1_scratch, STATE(_msg));
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1765
  __ ba(call_interpreter_2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1766
  __ delayed()->st_ptr(O1, STATE(_stack));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
  // interpreter returning to native code (call_stub/c1/c2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
  // convert result and unwind initial activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
  // L2_scratch - scaled result type index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
  __ bind(return_to_initial_caller);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1773
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1774
  __ set((intptr_t)CppInterpreter::_stack_to_native_abi, L4_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1775
  __ ld_ptr(L4_scratch, L2_scratch, Lscratch);                           // get typed result converter address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1776
  __ ld_ptr(STATE(_stack), O0);                                        // current top (prepushed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1777
  __ jmpl(Lscratch, G0, O7);                                           // and convert it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1778
  __ delayed()->add(O0, wordSize, O0);                                 // get source (top of current expr stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1779
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1780
  Label unwind_initial_activation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
  __ bind(unwind_initial_activation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
  // RETURN TO CALL_STUB/C1/C2 code (result if any in I0..I1/(F0/..F1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
  // we can return here with an exception that wasn't handled by interpreted code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
  // how does c1/c2 see it on return?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
  // compute resulting sp before/after args popped depending upon calling convention
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
  // __ ld_ptr(STATE(_saved_sp), Gtmp1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
  // POP FRAME HERE ==================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
  __ restore(FP, G0, SP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1792
  __ retl();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
  __ delayed()->mov(I5_savedSP->after_restore(), SP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1795
  // OSR request, unwind the current frame and transfer to the OSR entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1796
  // and enter OSR nmethod
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
  __ bind(do_OSR);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1799
  Label remove_initial_frame;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1800
  __ ld_ptr(STATE(_prev_link), L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1801
  __ ld_ptr(STATE(_result._osr._osr_buf), G1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1802
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1803
  // We are going to pop this frame. Is there another interpreter frame underneath
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1804
  // it or is it callstub/compiled?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1805
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1806
  __ tst(L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1807
  __ brx(Assembler::zero, false, Assembler::pt, remove_initial_frame);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1808
  __ delayed()->ld_ptr(STATE(_result._osr._osr_entry), G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1809
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1810
  // Frame underneath is an interpreter frame simply unwind
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1811
  // POP FRAME HERE ==================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
  __ restore(FP, G0, SP);                                             // unwind interpreter state frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1813
  __ mov(I5_savedSP->after_restore(), SP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1814
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
  // Since we are now calling native need to change our "return address" from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
  // dummy RecursiveInterpreterActivation to a return from native
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1818
  __ set((intptr_t)return_from_native_method - 8, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1819
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1820
  __ jmpl(G3_scratch, G0, G0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1821
  __ delayed()->mov(G1_scratch, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1822
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1823
  __ bind(remove_initial_frame);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1824
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1825
  // POP FRAME HERE ==================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1826
  __ restore(FP, G0, SP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1827
  __ mov(I5_savedSP->after_restore(), SP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1828
  __ jmpl(G3_scratch, G0, G0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1829
  __ delayed()->mov(G1_scratch, O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1830
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1831
  // Call a new method. All we do is (temporarily) trim the expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1832
  // push a return address to bring us back to here and leap to the new entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1833
  // At this point we have a topmost frame that was allocated by the frame manager
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1834
  // which contains the current method interpreted state. We trim this frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1835
  // of excess java expression stack entries and then recurse.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1836
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1837
  __ bind(call_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1838
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1839
  // stack points to next free location and not top element on expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1840
  // method expects sp to be pointing to topmost element
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1841
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1842
  __ ld_ptr(STATE(_thread), G2_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1843
  __ ld_ptr(STATE(_result._to_call._callee), G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1844
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1845
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1846
  // SP already takes in to account the 2 extra words we use for slop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1847
  // when we call a "static long no_params()" method. So if
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1848
  // we trim back sp by the amount of unused java expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1849
  // there will be automagically the 2 extra words we need.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1850
  // We also have to worry about keeping SP aligned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1851
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1852
  __ ld_ptr(STATE(_stack), Gargs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1853
  __ ld_ptr(STATE(_stack_limit), L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1854
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1855
  // compute the unused java stack size
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1856
  __ sub(Gargs, L1_scratch, L2_scratch);                       // compute unused space
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1857
370
33ba64c16c1f 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 1
diff changeset
  1858
  // Round down the unused space to that stack is always 16-byte aligned
33ba64c16c1f 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 1
diff changeset
  1859
  // by making the unused space a multiple of the size of two longs.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1860
370
33ba64c16c1f 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 1
diff changeset
  1861
  __ and3(L2_scratch, -2*BytesPerLong, L2_scratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1862
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1863
  // Now trim the stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1864
  __ add(SP, L2_scratch, SP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1865
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1866
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1867
  // Now point to the final argument (account for prepush)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1868
  __ add(Gargs, wordSize, Gargs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1869
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1870
  // Make sure we have space for the window
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1871
  __ sub(Gargs, SP, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1872
  __ cmp(L1_scratch, 16*wordSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1873
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1874
    Label skip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1875
    __ brx(Assembler::greaterEqual, false, Assembler::pt, skip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1877
    __ stop("killed stack");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1878
    __ bind(skip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1879
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1880
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1881
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1882
  // Create a new frame where we can store values that make it look like the interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1883
  // really recursed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1884
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1885
  // prepare to recurse or call specialized entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1886
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1887
  // First link the registers we need
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1888
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1889
  // make the pc look good in debugger
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1890
  __ set(CAST_FROM_FN_PTR(intptr_t, RecursiveInterpreterActivation), O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1891
  // argument too
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1892
  __ mov(Lstate, I0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1893
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1894
  // Record our sending SP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1895
  __ mov(SP, O5_savedSP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1896
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1897
  __ ld_ptr(STATE(_result._to_call._callee_entry_point), L2_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1898
  __ set((intptr_t) entry_point, L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1899
  __ cmp(L1_scratch, L2_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1900
  __ brx(Assembler::equal, false, Assembler::pt, re_dispatch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1901
  __ delayed()->mov(Lstate, prevState);                                // link activations
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1902
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1903
  // method uses specialized entry, push a return so we look like call stub setup
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1904
  // this path will handle fact that result is returned in registers and not
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1905
  // on the java stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1906
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1907
  __ set((intptr_t)return_from_native_method - 8, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1908
  __ jmpl(L2_scratch, G0, G0);                               // Do specialized entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1909
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1910
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1911
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1912
  // Bad Message from interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1913
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
  __ bind(bad_msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
  __ stop("Bad message from interpreter");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
  // Interpreted method "returned" with an exception pass it on...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1918
  // Pass result, unwind activation and continue/return to interpreter/call_stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
  // We handle result (if any) differently based on return to interpreter or call_stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
  __ bind(throw_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1922
  __ ld_ptr(STATE(_prev_link), L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1923
  __ tst(L1_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1924
  __ brx(Assembler::zero, false, Assembler::pt, unwind_and_forward);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1925
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1926
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1927
  __ ld_ptr(STATE(_locals), O1); // get result of popping callee's args
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9636
diff changeset
  1928
  __ ba(unwind_recursive_activation);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1929
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1930
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1931
  interpreter_frame_manager = entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1932
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1933
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
InterpreterGenerator::InterpreterGenerator(StubQueue* code)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1936
 : CppInterpreterGenerator(code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
   generate_all(); // down here so it can be "virtual"
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1938
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1939
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1940
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1941
static int size_activation_helper(int callee_extra_locals, int max_stack, int monitor_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1942
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
  // Figure out the size of an interpreter frame (in words) given that we have a fully allocated
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1944
  // expression stack, the callee will have callee_extra_locals (so we can account for
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1945
  // frame extension) and monitor_size for monitors. Basically we need to calculate
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1946
  // this exactly like generate_fixed_frame/generate_compute_interpreter_state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1947
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1948
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1949
  // The big complicating thing here is that we must ensure that the stack stays properly
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1950
  // aligned. This would be even uglier if monitor size wasn't modulo what the stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1951
  // needs to be aligned for). We are given that the sp (fp) is already aligned by
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
  // the caller so we must ensure that it is properly aligned for our callee.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1954
  // Ths c++ interpreter always makes sure that we have a enough extra space on the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1955
  // stack at all times to deal with the "stack long no_params()" method issue. This
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1956
  // is "slop_factor" here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1957
  const int slop_factor = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1958
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1959
  const int fixed_size = sizeof(BytecodeInterpreter)/wordSize +           // interpreter state object
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
                         frame::memory_parameter_word_sp_offset;   // register save area + param window
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
  return (round_to(max_stack +
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1962
                   slop_factor +
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1963
                   fixed_size +
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1964
                   monitor_size +
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1965
                   (callee_extra_locals * Interpreter::stackElementWords), WordsPerLong));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1966
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1967
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1968
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1969
int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1970
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1971
  // See call_stub code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
  int call_stub_size  = round_to(7 + frame::memory_parameter_word_sp_offset,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1973
                                 WordsPerLong);    // 7 + register save area
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1974
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1975
  // Save space for one monitor to get into the interpreted method in case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1976
  // the method is synchronized
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1977
  int monitor_size    = method->is_synchronized() ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1978
                                1*frame::interpreter_frame_monitor_size() : 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
  return size_activation_helper(method->max_locals(), method->max_stack(),
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  1980
                                monitor_size) + call_stub_size;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1981
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1982
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1983
void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
                                           frame* caller,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1985
                                           frame* current,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1986
                                           Method* method,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1987
                                           intptr_t* locals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1988
                                           intptr_t* stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1989
                                           intptr_t* stack_base,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
                                           intptr_t* monitor_base,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1991
                                           intptr_t* frame_bottom,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1992
                                           bool is_top_frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1993
                                           )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1994
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1995
  // What about any vtable?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1996
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1997
  to_fill->_thread = JavaThread::current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1998
  // This gets filled in later but make it something recognizable for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1999
  to_fill->_bcp = method->code_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2000
  to_fill->_locals = locals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2001
  to_fill->_constants = method->constants()->cache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2002
  to_fill->_method = method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2003
  to_fill->_mdx = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2004
  to_fill->_stack = stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2005
  if (is_top_frame && JavaThread::current()->popframe_forcing_deopt_reexecution() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2006
    to_fill->_msg = deopt_resume2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2007
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2008
    to_fill->_msg = method_resume;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2010
  to_fill->_result._to_call._bcp_advance = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2011
  to_fill->_result._to_call._callee_entry_point = NULL; // doesn't matter to anyone
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
  to_fill->_result._to_call._callee = NULL; // doesn't matter to anyone
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2013
  to_fill->_prev_link = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2014
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2015
  // Fill in the registers for the frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2016
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2017
  // Need to install _sender_sp. Actually not too hard in C++!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2018
  // When the skeletal frames are layed out we fill in a value
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2019
  // for _sender_sp. That value is only correct for the oldest
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
  // skeletal frame constructed (because there is only a single
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
  // entry for "caller_adjustment". While the skeletal frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2022
  // exist that is good enough. We correct that calculation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2023
  // here and get all the frames correct.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2024
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2025
  // to_fill->_sender_sp = locals - (method->size_of_parameters() - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2026
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2027
  *current->register_addr(Lstate) = (intptr_t) to_fill;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
  // skeletal already places a useful value here and this doesn't account
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2029
  // for alignment so don't bother.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2030
  // *current->register_addr(I5_savedSP) =     (intptr_t) locals - (method->size_of_parameters() - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2031
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2032
  if (caller->is_interpreted_frame()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2033
    interpreterState prev  = caller->get_interpreterState();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2034
    to_fill->_prev_link = prev;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2035
    // Make the prev callee look proper
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
    prev->_result._to_call._callee = method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
    if (*prev->_bcp == Bytecodes::_invokeinterface) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
      prev->_result._to_call._bcp_advance = 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2039
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
      prev->_result._to_call._bcp_advance = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2041
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
  to_fill->_oop_temp = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
  to_fill->_stack_base = stack_base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
  // Need +1 here because stack_base points to the word just above the first expr stack entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2046
  // and stack_limit is supposed to point to the word just below the last expr stack entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
  // 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
  2048
  to_fill->_stack_limit = stack_base - (method->max_stack() + 1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2049
  to_fill->_monitor_base = (BasicObjectLock*) monitor_base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
  // sparc specific
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
  to_fill->_frame_bottom = frame_bottom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
  to_fill->_self_link = to_fill;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2054
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
  to_fill->_native_fresult = 123456.789;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
  to_fill->_native_lresult = CONST64(0xdeadcafedeafcafe);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
void BytecodeInterpreter::pd_layout_interpreterState(interpreterState istate, address last_Java_pc, intptr_t* last_Java_fp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
  istate->_last_Java_pc = (intptr_t*) last_Java_pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2064
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
  2065
                             int moncount,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2066
                             int callee_param_size,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2067
                             int callee_locals_size,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2068
                             bool is_top_frame,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2069
                             int& monitor_size,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2070
                             int& full_frame_words) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2071
  int extra_locals_size = callee_locals_size - callee_param_size;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2072
  monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2073
  full_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2074
  int short_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2075
  int frame_words = is_top_frame ? full_frame_words : short_frame_words;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2077
  return frame_words;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2078
}
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2079
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2080
int AbstractInterpreter::size_activation(int max_stack,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2081
                                         int tempcount,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2082
                                         int extra_args,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2083
                                         int moncount,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2084
                                         int callee_param_size,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2085
                                         int callee_locals_size,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2086
                                         bool is_top_frame) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2087
  assert(extra_args == 0, "NEED TO FIX");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2088
  // NOTE: return size is in words not bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
  // Calculate the amount our frame will be adjust by the callee. For top frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
  // this is zero.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2092
  // NOTE: ia64 seems to do this wrong (or at least backwards) in that it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2093
  // calculates the extra locals based on itself. Not what the callee does
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
  // to it. So it ignores last_frame_adjust value. Seems suspicious as far
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
  // as getting sender_sp correct.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2096
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2097
  int unused_monitor_size = 0;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2098
  int unused_full_frame_words = 0;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2099
  return frame_size_helper(max_stack, moncount, callee_param_size, callee_locals_size, is_top_frame,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2100
                           unused_monitor_size, unused_full_frame_words);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2101
}
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2102
void AbstractInterpreter::layout_activation(Method* method,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2103
                                            int tempcount, // Number of slots on java expression stack in use
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2104
                                            int popframe_extra_args,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2105
                                            int moncount,  // Number of active monitors
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2106
                                            int caller_actual_parameters,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2107
                                            int callee_param_size,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2108
                                            int callee_locals_size,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2109
                                            frame* caller,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2110
                                            frame* interpreter_frame,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2111
                                            bool is_top_frame,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2112
                                            bool is_bottom_frame) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2113
  assert(popframe_extra_args == 0, "NEED TO FIX");
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2114
  // 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
  2115
  // 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
  2116
  // Set up the method, locals, and monitors.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2117
  // 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
  2118
  // 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
  2119
  // 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
  2120
  // 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
  2121
  //       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
  2122
  //       version that non-top frames have.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2123
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2124
  int monitor_size = 0;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2125
  int full_frame_words = 0;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2126
  int frame_words = frame_size_helper(method->max_stack(), moncount, callee_param_size, callee_locals_size,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2127
                                      is_top_frame, monitor_size, full_frame_words);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2128
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2129
  /*
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2130
    We must now fill in all the pieces of the frame. This means both
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2131
    the interpreterState and the registers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2132
  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2133
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2134
  // MUCHO HACK
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2135
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2136
  intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2137
  // 'interpreter_frame->sp()' is unbiased while 'frame_bottom' must be a biased value in 64bit mode.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2138
  assert(((intptr_t)frame_bottom & 0xf) == 0, "SP biased in layout_activation");
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2139
  frame_bottom = (intptr_t*)((intptr_t)frame_bottom - STACK_BIAS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2141
  /* Now fillin the interpreterState object */
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2143
  interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() -  sizeof(BytecodeInterpreter));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2145
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2146
  intptr_t* locals;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2147
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2148
  // Calculate the postion of locals[0]. This is painful because of
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2149
  // stack alignment (same as ia64). The problem is that we can
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2150
  // not compute the location of locals from fp(). fp() will account
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2151
  // for the extra locals but it also accounts for aligning the stack
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2152
  // and we can't determine if the locals[0] was misaligned but max_locals
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2153
  // was enough to have the
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2154
  // calculate postion of locals. fp already accounts for extra locals.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2155
  // +2 for the static long no_params() issue.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2156
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2157
  if (caller->is_interpreted_frame()) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2158
    // 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
  2159
    // caller's tos when we return.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2160
    interpreterState prev  = caller->get_interpreterState();
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2161
    // stack() is prepushed.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2162
    locals = prev->stack() + method->size_of_parameters();
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2163
  } else {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2164
    // Lay out locals block in the caller adjacent to the register window save area.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2165
    //
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2166
    // Compiled frames do not allocate a varargs area which is why this if
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2167
    // statement is needed.
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
    intptr_t* fp = interpreter_frame->fp();
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2170
    int local_words = method->max_locals() * Interpreter::stackElementWords;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2171
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2172
    if (caller->is_compiled_frame()) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2173
      locals = fp + frame::register_save_words + local_words - 1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
    } else {
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2175
      locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2176
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2177
24018
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
  // END MUCHO HACK
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2181
  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
  2182
  intptr_t* stack_base =  monitor_base - monitor_size;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2183
  /* +1 because stack is always prepushed */
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2184
  intptr_t* stack = stack_base - (tempcount + 1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2185
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2186
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2187
  BytecodeInterpreter::layout_interpreterState(cur_state,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2188
                                               caller,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2189
                                               interpreter_frame,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2190
                                               method,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2191
                                               locals,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2192
                                               stack,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2193
                                               stack_base,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2194
                                               monitor_base,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2195
                                               frame_bottom,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23844
diff changeset
  2196
                                               is_top_frame);
1
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
  BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2199
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2200
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2201
#endif // CC_INTERP