hotspot/src/cpu/ppc/vm/templateInterpreter_ppc.cpp
author goetz
Fri, 04 Jul 2014 11:46:01 +0200
changeset 25715 d5a8dbdc5150
parent 24349 d8f40e5b392d
child 25916 c5c22fab48fd
permissions -rw-r--r--
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories. Summary: Introduce and clean up umbrella headers for the files in the cpu subdirectories. Reviewed-by: lfoltan, coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     1
/*
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     3
 * Copyright 2013, 2014 SAP AG. All rights reserved.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     5
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     9
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    14
 * accompanied this code).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    15
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    19
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    22
 * questions.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    23
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    24
 */
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    25
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    26
#include "precompiled.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    27
#ifndef CC_INTERP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    28
#include "asm/macroAssembler.inline.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    29
#include "interpreter/bytecodeHistogram.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    30
#include "interpreter/interpreter.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    31
#include "interpreter/interpreterGenerator.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    32
#include "interpreter/interpreterRuntime.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24349
diff changeset
    33
#include "interpreter/interp_masm.hpp"
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    34
#include "interpreter/templateTable.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    35
#include "oops/arrayOop.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    36
#include "oops/methodData.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    37
#include "oops/method.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    38
#include "oops/oop.inline.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    39
#include "prims/jvmtiExport.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    40
#include "prims/jvmtiThreadState.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    41
#include "runtime/arguments.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    42
#include "runtime/deoptimization.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    43
#include "runtime/frame.inline.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    44
#include "runtime/sharedRuntime.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    45
#include "runtime/stubRoutines.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    46
#include "runtime/synchronizer.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    47
#include "runtime/timer.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    48
#include "runtime/vframeArray.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    49
#include "utilities/debug.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    50
#include "utilities/macros.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    51
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    52
#undef __
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    53
#define __ _masm->
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    54
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    55
#ifdef PRODUCT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    56
#define BLOCK_COMMENT(str) /* nothing */
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    57
#else
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    58
#define BLOCK_COMMENT(str) __ block_comment(str)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    59
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    60
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    61
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    62
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    63
//-----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    64
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    65
// Actually we should never reach here since we do stack overflow checks before pushing any frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    66
address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    67
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    68
  __ unimplemented("generate_StackOverflowError_handler");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    69
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    70
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    71
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    72
address TemplateInterpreterGenerator::generate_ArrayIndexOutOfBounds_handler(const char* name) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    73
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    74
  __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    75
  __ load_const_optimized(R4_ARG2, (address) name);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    76
  // Index is in R17_tos.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    77
  __ mr(R5_ARG3, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    78
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    79
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    80
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    81
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    82
#if 0
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    83
// Call special ClassCastException constructor taking object to cast
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    84
// and target class as arguments.
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
    85
address TemplateInterpreterGenerator::generate_ClassCastException_verbose_handler() {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    86
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    87
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    88
  // Expression stack must be empty before entering the VM if an
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    89
  // exception happened.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    90
  __ empty_expression_stack();
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
    91
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    92
  // Thread will be loaded to R3_ARG1.
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
    93
  // Target class oop is in register R5_ARG3 by convention!
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
    94
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ClassCastException_verbose, R17_tos, R5_ARG3));
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    95
  // Above call must not return here since exception pending.
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
    96
  DEBUG_ONLY(__ should_not_reach_here();)
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    97
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    98
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    99
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   100
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   101
address TemplateInterpreterGenerator::generate_ClassCastException_handler() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   102
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   103
  // Expression stack must be empty before entering the VM if an
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   104
  // exception happened.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   105
  __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   106
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   107
  // Load exception object.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   108
  // Thread will be loaded to R3_ARG1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   109
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ClassCastException), R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   110
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   111
  // Above call must not return here since exception pending.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   112
  __ should_not_reach_here();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   113
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   114
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   115
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   116
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   117
address TemplateInterpreterGenerator::generate_exception_handler_common(const char* name, const char* message, bool pass_oop) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   118
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   119
  //__ untested("generate_exception_handler_common");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   120
  Register Rexception = R17_tos;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   121
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   122
  // Expression stack must be empty before entering the VM if an exception happened.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   123
  __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   124
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   125
  __ load_const_optimized(R4_ARG2, (address) name, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   126
  if (pass_oop) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   127
    __ mr(R5_ARG3, Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   128
    __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_klass_exception), false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   129
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   130
    __ load_const_optimized(R5_ARG3, (address) message, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   131
    __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::create_exception), false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   132
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   133
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   134
  // Throw exception.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   135
  __ mr(R3_ARG1, Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   136
  __ load_const_optimized(R11_scratch1, Interpreter::throw_exception_entry(), R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   137
  __ mtctr(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   138
  __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   139
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   140
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   141
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   142
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   143
address TemplateInterpreterGenerator::generate_continuation_for(TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   144
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   145
  __ unimplemented("generate_continuation_for");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   146
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   147
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   148
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   149
// This entry is returned to when a call returns to the interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   150
// When we arrive here, we expect that the callee stack frame is already popped.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   151
address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step, size_t index_size) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   152
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   153
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   154
  // Move the value out of the return register back to the TOS cache of current frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   155
  switch (state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   156
    case ltos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   157
    case btos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   158
    case ctos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   159
    case stos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   160
    case atos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   161
    case itos: __ mr(R17_tos, R3_RET); break;   // RET -> TOS cache
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   162
    case ftos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   163
    case dtos: __ fmr(F15_ftos, F1_RET); break; // TOS cache -> GR_FRET
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   164
    case vtos: break;                           // Nothing to do, this was a void return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   165
    default  : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   166
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   167
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   168
  __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   169
  __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   170
  __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   171
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   172
  // Compiled code destroys templateTableBase, reload.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   173
  __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   174
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   175
  const Register cache = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   176
  const Register size  = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   177
  __ get_cache_and_index_at_bcp(cache, 1, index_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   178
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   179
  // Big Endian (get least significant byte of 64 bit value):
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   180
  __ lbz(size, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()) + 7, cache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   181
  __ sldi(size, size, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   182
  __ add(R15_esp, R15_esp, size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   183
  __ dispatch_next(state, step);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   184
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   185
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   186
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   187
address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, int step) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   188
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   189
  // If state != vtos, we're returning from a native method, which put it's result
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   190
  // into the result register. So move the value out of the return register back
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   191
  // to the TOS cache of current frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   192
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   193
  switch (state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   194
    case ltos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   195
    case btos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   196
    case ctos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   197
    case stos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   198
    case atos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   199
    case itos: __ mr(R17_tos, R3_RET); break;   // GR_RET -> TOS cache
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   200
    case ftos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   201
    case dtos: __ fmr(F15_ftos, F1_RET); break; // TOS cache -> GR_FRET
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   202
    case vtos: break;                           // Nothing to do, this was a void return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   203
    default  : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   204
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   205
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   206
  // Load LcpoolCache @@@ should be already set!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   207
  __ get_constant_pool_cache(R27_constPoolCache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   208
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   209
  // Handle a pending exception, fall through if none.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   210
  __ check_and_forward_exception(R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   211
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   212
  // Start executing bytecodes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   213
  __ dispatch_next(state, step);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   214
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   215
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   216
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   217
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   218
// A result handler converts the native result into java format.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   219
// Use the shared code between c++ and template interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   220
address TemplateInterpreterGenerator::generate_result_handler_for(BasicType type) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   221
  return AbstractInterpreterGenerator::generate_result_handler_for(type);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   222
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   223
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   224
address TemplateInterpreterGenerator::generate_safept_entry_for(TosState state, address runtime_entry) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   225
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   226
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   227
  __ push(state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   228
  __ call_VM(noreg, runtime_entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   229
  __ dispatch_via(vtos, Interpreter::_normal_table.table_for(vtos));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   230
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   231
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   232
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   233
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   234
// Helpers for commoning out cases in the various type of method entries.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   235
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   236
// Increment invocation count & check for overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   237
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   238
// Note: checking for negative value instead of overflow
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   239
//       so we have a 'sticky' overflow test.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   240
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   241
void TemplateInterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   242
  // Note: In tiered we increment either counters in method or in MDO depending if we're profiling or not.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   243
  Register Rscratch1   = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   244
  Register Rscratch2   = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   245
  Register R3_counters = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   246
  Label done;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   247
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   248
  if (TieredCompilation) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   249
    const int increment = InvocationCounter::count_increment;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   250
    const int mask = ((1 << Tier0InvokeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   251
    Label no_mdo;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   252
    if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   253
      const Register Rmdo = Rscratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   254
      // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   255
      __ ld(Rmdo, in_bytes(Method::method_data_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   256
      __ cmpdi(CCR0, Rmdo, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   257
      __ beq(CCR0, no_mdo);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   258
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   259
      // Increment backedge counter in the MDO.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   260
      const int mdo_bc_offs = in_bytes(MethodData::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   261
      __ lwz(Rscratch2, mdo_bc_offs, Rmdo);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   262
      __ addi(Rscratch2, Rscratch2, increment);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   263
      __ stw(Rscratch2, mdo_bc_offs, Rmdo);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   264
      __ load_const_optimized(Rscratch1, mask, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   265
      __ and_(Rscratch1, Rscratch2, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   266
      __ bne(CCR0, done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   267
      __ b(*overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   268
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   269
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   270
    // Increment counter in MethodCounters*.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   271
    const int mo_bc_offs = in_bytes(MethodCounters::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   272
    __ bind(no_mdo);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   273
    __ get_method_counters(R19_method, R3_counters, done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   274
    __ lwz(Rscratch2, mo_bc_offs, R3_counters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   275
    __ addi(Rscratch2, Rscratch2, increment);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   276
    __ stw(Rscratch2, mo_bc_offs, R3_counters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   277
    __ load_const_optimized(Rscratch1, mask, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   278
    __ and_(Rscratch1, Rscratch2, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   279
    __ beq(CCR0, *overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   280
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   281
    __ bind(done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   282
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   283
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   284
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   285
    // Update standard invocation counters.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   286
    Register Rsum_ivc_bec = R4_ARG2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   287
    __ get_method_counters(R19_method, R3_counters, done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   288
    __ increment_invocation_counter(R3_counters, Rsum_ivc_bec, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   289
    // Increment interpreter invocation counter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   290
    if (ProfileInterpreter) {  // %%% Merge this into methodDataOop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   291
      __ lwz(R12_scratch2, in_bytes(MethodCounters::interpreter_invocation_counter_offset()), R3_counters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   292
      __ addi(R12_scratch2, R12_scratch2, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   293
      __ stw(R12_scratch2, in_bytes(MethodCounters::interpreter_invocation_counter_offset()), R3_counters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   294
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   295
    // Check if we must create a method data obj.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   296
    if (ProfileInterpreter && profile_method != NULL) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   297
      const Register profile_limit = Rscratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   298
      int pl_offs = __ load_const_optimized(profile_limit, &InvocationCounter::InterpreterProfileLimit, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   299
      __ lwz(profile_limit, pl_offs, profile_limit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   300
      // Test to see if we should create a method data oop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   301
      __ cmpw(CCR0, Rsum_ivc_bec, profile_limit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   302
      __ blt(CCR0, *profile_method_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   303
      // If no method data exists, go to profile_method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   304
      __ test_method_data_pointer(*profile_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   305
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   306
    // Finally check for counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   307
    if (overflow) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   308
      const Register invocation_limit = Rscratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   309
      int il_offs = __ load_const_optimized(invocation_limit, &InvocationCounter::InterpreterInvocationLimit, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   310
      __ lwz(invocation_limit, il_offs, invocation_limit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   311
      assert(4 == sizeof(InvocationCounter::InterpreterInvocationLimit), "unexpected field size");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   312
      __ cmpw(CCR0, Rsum_ivc_bec, invocation_limit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   313
      __ bge(CCR0, *overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   314
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   315
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   316
    __ bind(done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   317
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   318
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   319
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   320
// Generate code to initiate compilation on invocation counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   321
void TemplateInterpreterGenerator::generate_counter_overflow(Label& continue_entry) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   322
  // Generate code to initiate compilation on the counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   323
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   324
  // InterpreterRuntime::frequency_counter_overflow takes one arguments,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   325
  // which indicates if the counter overflow occurs at a backwards branch (NULL bcp)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   326
  // We pass zero in.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   327
  // The call returns the address of the verified entry point for the method or NULL
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   328
  // if the compilation did not complete (either went background or bailed out).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   329
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   330
  // Unlike the C++ interpreter above: Check exceptions!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   331
  // Assumption: Caller must set the flag "do_not_unlock_if_sychronized" if the monitor of a sync'ed
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   332
  // method has not yet been created. Thus, no unlocking of a non-existing monitor can occur.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   333
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   334
  __ li(R4_ARG2, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   335
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), R4_ARG2, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   336
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   337
  // Returns verified_entry_point or NULL.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   338
  // We ignore it in any case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   339
  __ b(continue_entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   340
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   341
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   342
void TemplateInterpreterGenerator::generate_stack_overflow_check(Register Rmem_frame_size, Register Rscratch1) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   343
  assert_different_registers(Rmem_frame_size, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   344
  __ generate_stack_overflow_check_with_compare_and_throw(Rmem_frame_size, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   345
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   346
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   347
void TemplateInterpreterGenerator::unlock_method(bool check_exceptions) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   348
  __ unlock_object(R26_monitor, check_exceptions);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   349
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   350
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   351
// Lock the current method, interpreter register window must be set up!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   352
void TemplateInterpreterGenerator::lock_method(Register Rflags, Register Rscratch1, Register Rscratch2, bool flags_preloaded) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   353
  const Register Robj_to_lock = Rscratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   354
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   355
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   356
    if (!flags_preloaded) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   357
      __ lwz(Rflags, method_(access_flags));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   358
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   359
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   360
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   361
    // Check if methods needs synchronization.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   362
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   363
      Label Lok;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   364
      __ testbitdi(CCR0, R0, Rflags, JVM_ACC_SYNCHRONIZED_BIT);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   365
      __ btrue(CCR0,Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   366
      __ stop("method doesn't need synchronization");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   367
      __ bind(Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   368
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   369
#endif // ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   370
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   371
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   372
  // Get synchronization object to Rscratch2.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   373
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   374
    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   375
    Label Lstatic;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   376
    Label Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   377
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   378
    __ testbitdi(CCR0, R0, Rflags, JVM_ACC_STATIC_BIT);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   379
    __ btrue(CCR0, Lstatic);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   380
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   381
    // Non-static case: load receiver obj from stack and we're done.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   382
    __ ld(Robj_to_lock, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   383
    __ b(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   384
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   385
    __ bind(Lstatic); // Static case: Lock the java mirror
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   386
    __ ld(Robj_to_lock, in_bytes(Method::const_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   387
    __ ld(Robj_to_lock, in_bytes(ConstMethod::constants_offset()), Robj_to_lock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   388
    __ ld(Robj_to_lock, ConstantPool::pool_holder_offset_in_bytes(), Robj_to_lock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   389
    __ ld(Robj_to_lock, mirror_offset, Robj_to_lock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   390
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   391
    __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   392
    __ verify_oop(Robj_to_lock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   393
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   394
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   395
  // Got the oop to lock => execute!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   396
  __ add_monitor_to_stack(true, Rscratch1, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   397
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   398
  __ std(Robj_to_lock, BasicObjectLock::obj_offset_in_bytes(), R26_monitor);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   399
  __ lock_object(R26_monitor, Robj_to_lock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   400
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   401
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   402
// Generate a fixed interpreter frame for pure interpreter
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   403
// and I2N native transition frames.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   404
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   405
// Before (stack grows downwards):
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   406
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   407
//         |  ...         |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   408
//         |------------- |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   409
//         |  java arg0   |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   410
//         |  ...         |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   411
//         |  java argn   |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   412
//         |              |   <-   R15_esp
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   413
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   414
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   415
//         | abi_112      |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   416
//         |              |   <-   R1_SP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   417
//         |==============|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   418
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   419
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   420
// After:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   421
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   422
//         |  ...         |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   423
//         |  java arg0   |<-   R18_locals
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   424
//         |  ...         |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   425
//         |  java argn   |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   426
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   427
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   428
//         |  java locals |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   429
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   430
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   431
//         |  abi_48      |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   432
//         |==============|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   433
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   434
//         |   istate     |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   435
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   436
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   437
//         |   monitor    |<-   R26_monitor
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   438
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   439
//         |              |<-   R15_esp
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   440
//         | expression   |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   441
//         | stack        |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   442
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   443
//         |--------------|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   444
//         |              |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   445
//         | abi_112      |<-   R1_SP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   446
//         |==============|
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   447
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   448
// The top most frame needs an abi space of 112 bytes. This space is needed,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   449
// since we call to c. The c function may spill their arguments to the caller
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   450
// frame. When we call to java, we don't need these spill slots. In order to save
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   451
// space on the stack, we resize the caller. However, java local reside in
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   452
// the caller frame and the frame has to be increased. The frame_size for the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   453
// current frame was calculated based on max_stack as size for the expression
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   454
// stack. At the call, just a part of the expression stack might be used.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   455
// We don't want to waste this space and cut the frame back accordingly.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   456
// The resulting amount for resizing is calculated as follows:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   457
// resize =   (number_of_locals - number_of_arguments) * slot_size
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   458
//          + (R1_SP - R15_esp) + 48
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   459
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   460
// The size for the callee frame is calculated:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   461
// framesize = 112 + max_stack + monitor + state_size
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   462
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   463
// maxstack:   Max number of slots on the expression stack, loaded from the method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   464
// monitor:    We statically reserve room for one monitor object.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   465
// state_size: We save the current state of the interpreter to this area.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   466
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   467
void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Register Rsize_of_parameters, Register Rsize_of_locals) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   468
  Register parent_frame_resize = R6_ARG4, // Frame will grow by this number of bytes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   469
           top_frame_size      = R7_ARG5,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   470
           Rconst_method       = R8_ARG6;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   471
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   472
  assert_different_registers(Rsize_of_parameters, Rsize_of_locals, parent_frame_resize, top_frame_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   473
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   474
  __ ld(Rconst_method, method_(const));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   475
  __ lhz(Rsize_of_parameters /* number of params */,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   476
         in_bytes(ConstMethod::size_of_parameters_offset()), Rconst_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   477
  if (native_call) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   478
    // If we're calling a native method, we reserve space for the worst-case signature
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   479
    // handler varargs vector, which is max(Argument::n_register_parameters, parameter_count+2).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   480
    // We add two slots to the parameter_count, one for the jni
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   481
    // environment and one for a possible native mirror.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   482
    Label skip_native_calculate_max_stack;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   483
    __ addi(top_frame_size, Rsize_of_parameters, 2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   484
    __ cmpwi(CCR0, top_frame_size, Argument::n_register_parameters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   485
    __ bge(CCR0, skip_native_calculate_max_stack);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   486
    __ li(top_frame_size, Argument::n_register_parameters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   487
    __ bind(skip_native_calculate_max_stack);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   488
    __ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   489
    __ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   490
    __ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   491
    assert(Rsize_of_locals == noreg, "Rsize_of_locals not initialized"); // Only relevant value is Rsize_of_parameters.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   492
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   493
    __ lhz(Rsize_of_locals /* number of params */, in_bytes(ConstMethod::size_of_locals_offset()), Rconst_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   494
    __ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   495
    __ sldi(Rsize_of_locals, Rsize_of_locals, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   496
    __ lhz(top_frame_size, in_bytes(ConstMethod::max_stack_offset()), Rconst_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   497
    __ sub(R11_scratch1, Rsize_of_locals, Rsize_of_parameters); // >=0
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   498
    __ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   499
    __ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   500
    __ add(parent_frame_resize, parent_frame_resize, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   501
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   502
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   503
  // Compute top frame size.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   504
  __ addi(top_frame_size, top_frame_size, frame::abi_reg_args_size + frame::ijava_state_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   505
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   506
  // Cut back area between esp and max_stack.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   507
  __ addi(parent_frame_resize, parent_frame_resize, frame::abi_minframe_size - Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   508
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   509
  __ round_to(top_frame_size, frame::alignment_in_bytes);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   510
  __ round_to(parent_frame_resize, frame::alignment_in_bytes);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   511
  // parent_frame_resize = (locals-parameters) - (ESP-SP-ABI48) Rounded to frame alignment size.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   512
  // Enlarge by locals-parameters (not in case of native_call), shrink by ESP-SP-ABI48.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   513
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   514
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   515
    // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   516
    // Stack overflow check
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   517
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   518
    Label cont;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   519
    __ add(R11_scratch1, parent_frame_resize, top_frame_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   520
    generate_stack_overflow_check(R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   521
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   522
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   523
  // Set up interpreter state registers.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   524
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   525
  __ add(R18_locals, R15_esp, Rsize_of_parameters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   526
  __ ld(R27_constPoolCache, in_bytes(ConstMethod::constants_offset()), Rconst_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   527
  __ ld(R27_constPoolCache, ConstantPool::cache_offset_in_bytes(), R27_constPoolCache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   528
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   529
  // Set method data pointer.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   530
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   531
    Label zero_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   532
    __ ld(R28_mdx, method_(method_data));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   533
    __ cmpdi(CCR0, R28_mdx, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   534
    __ beq(CCR0, zero_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   535
    __ addi(R28_mdx, R28_mdx, in_bytes(MethodData::data_offset()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   536
    __ bind(zero_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   537
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   538
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   539
  if (native_call) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   540
    __ li(R14_bcp, 0); // Must initialize.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   541
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   542
    __ add(R14_bcp, in_bytes(ConstMethod::codes_offset()), Rconst_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   543
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   544
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   545
  // Resize parent frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   546
  __ mflr(R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   547
  __ neg(parent_frame_resize, parent_frame_resize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   548
  __ resize_frame(parent_frame_resize, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   549
  __ std(R12_scratch2, _abi(lr), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   550
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   551
  __ addi(R26_monitor, R1_SP, - frame::ijava_state_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   552
  __ addi(R15_esp, R26_monitor, - Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   553
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   554
  // Store values.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   555
  // R15_esp, R14_bcp, R26_monitor, R28_mdx are saved at java calls
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   556
  // in InterpreterMacroAssembler::call_from_interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   557
  __ std(R19_method, _ijava_state_neg(method), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   558
  __ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   559
  __ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   560
  __ std(R18_locals, _ijava_state_neg(locals), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   561
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   562
  // Note: esp, bcp, monitor, mdx live in registers. Hence, the correct version can only
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   563
  // be found in the frame after save_interpreter_state is done. This is always true
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   564
  // for non-top frames. But when a signal occurs, dumping the top frame can go wrong,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   565
  // because e.g. frame::interpreter_frame_bcp() will not access the correct value
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   566
  // (Enhanced Stack Trace).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   567
  // The signal handler does not save the interpreter state into the frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   568
  __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   569
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   570
  // Fill remaining slots with constants.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   571
  __ load_const_optimized(R11_scratch1, 0x5afe);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   572
  __ load_const_optimized(R12_scratch2, 0xdead);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   573
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   574
  // We have to initialize some frame slots for native calls (accessed by GC).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   575
  if (native_call) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   576
    __ std(R26_monitor, _ijava_state_neg(monitors), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   577
    __ std(R14_bcp, _ijava_state_neg(bcp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   578
    if (ProfileInterpreter) { __ std(R28_mdx, _ijava_state_neg(mdx), R1_SP); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   579
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   580
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   581
  else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   582
    __ std(R12_scratch2, _ijava_state_neg(monitors), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   583
    __ std(R12_scratch2, _ijava_state_neg(bcp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   584
    __ std(R12_scratch2, _ijava_state_neg(mdx), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   585
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   586
  __ std(R11_scratch1, _ijava_state_neg(ijava_reserved), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   587
  __ std(R12_scratch2, _ijava_state_neg(esp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   588
  __ std(R12_scratch2, _ijava_state_neg(lresult), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   589
  __ std(R12_scratch2, _ijava_state_neg(fresult), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   590
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   591
  __ subf(R12_scratch2, top_frame_size, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   592
  __ std(R0, _ijava_state_neg(oop_tmp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   593
  __ std(R12_scratch2, _ijava_state_neg(top_frame_sp), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   594
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   595
  // Push top frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   596
  __ push_frame(top_frame_size, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   597
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   598
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   599
// End of helpers
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   600
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   601
// ============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   602
// Various method entries
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   603
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   604
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   605
// Empty method, generate a very fast return. We must skip this entry if
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   606
// someone's debugging, indicated by the flag
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   607
// "interp_mode" in the Thread obj.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   608
// Note: empty methods are generated mostly methods that do assertions, which are
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   609
// disabled in the "java opt build".
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   610
address TemplateInterpreterGenerator::generate_empty_entry(void) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   611
  if (!UseFastEmptyMethods) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   612
    NOT_PRODUCT(__ should_not_reach_here();)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   613
    return Interpreter::entry_for_kind(Interpreter::zerolocals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   614
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   615
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   616
  Label Lslow_path;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   617
  const Register Rjvmti_mode = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   618
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   619
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   620
  __ lwz(Rjvmti_mode, thread_(interp_only_mode));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   621
  __ cmpwi(CCR0, Rjvmti_mode, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   622
  __ bne(CCR0, Lslow_path); // jvmti_mode!=0
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   623
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   624
  // Noone's debuggin: Simply return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   625
  // Pop c2i arguments (if any) off when we return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   626
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   627
    __ ld(R9_ARG7, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   628
    __ ld(R10_ARG8, 0, R21_sender_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   629
    __ cmpd(CCR0, R9_ARG7, R10_ARG8);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   630
    __ asm_assert_eq("backlink", 0x545);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   631
#endif // ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   632
  __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   633
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   634
  // And we're done.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   635
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   636
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   637
  __ bind(Lslow_path);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   638
  __ branch_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   639
  __ flush();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   640
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   641
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   642
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   643
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   644
// Support abs and sqrt like in compiler.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   645
// For others we can use a normal (native) entry.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   646
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   647
inline bool math_entry_available(AbstractInterpreter::MethodKind kind) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   648
  // Provide math entry with debugging on demand.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   649
  // Note: Debugging changes which code will get executed:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   650
  // Debugging or disabled InlineIntrinsics: java method will get interpreted and performs a native call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   651
  // Not debugging and enabled InlineIntrinics: processor instruction will get used.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   652
  // Result might differ slightly due to rounding etc.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   653
  if (!InlineIntrinsics && (!FLAG_IS_ERGO(InlineIntrinsics))) return false; // Generate a vanilla entry.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   654
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   655
  return ((kind==Interpreter::java_lang_math_sqrt && VM_Version::has_fsqrt()) ||
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   656
          (kind==Interpreter::java_lang_math_abs));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   657
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   658
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   659
address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   660
  if (!math_entry_available(kind)) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   661
    NOT_PRODUCT(__ should_not_reach_here();)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   662
    return Interpreter::entry_for_kind(Interpreter::zerolocals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   663
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   664
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   665
  Label Lslow_path;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   666
  const Register Rjvmti_mode = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   667
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   668
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   669
  // Provide math entry with debugging on demand.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   670
  __ lwz(Rjvmti_mode, thread_(interp_only_mode));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   671
  __ cmpwi(CCR0, Rjvmti_mode, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   672
  __ bne(CCR0, Lslow_path); // jvmti_mode!=0
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   673
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   674
  __ lfd(F1_RET, Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   675
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   676
  // Pop c2i arguments (if any) off when we return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   677
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   678
  __ ld(R9_ARG7, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   679
  __ ld(R10_ARG8, 0, R21_sender_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   680
  __ cmpd(CCR0, R9_ARG7, R10_ARG8);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   681
  __ asm_assert_eq("backlink", 0x545);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   682
#endif // ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   683
  __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   684
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   685
  if (kind == Interpreter::java_lang_math_sqrt) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   686
    __ fsqrt(F1_RET, F1_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   687
  } else if (kind == Interpreter::java_lang_math_abs) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   688
    __ fabs(F1_RET, F1_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   689
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   690
    ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   691
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   692
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   693
  // And we're done.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   694
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   695
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   696
  // Provide slow path for JVMTI case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   697
  __ bind(Lslow_path);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   698
  __ branch_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals), R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   699
  __ flush();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   700
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   701
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   702
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   703
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   704
// Interpreter stub for calling a native method. (asm interpreter)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   705
// This sets up a somewhat different looking stack for calling the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   706
// native method than the typical interpreter frame setup.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   707
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   708
// On entry:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   709
//   R19_method    - method
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   710
//   R16_thread    - JavaThread*
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   711
//   R15_esp       - intptr_t* sender tos
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   712
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   713
//   abstract stack (grows up)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   714
//     [  IJava (caller of JNI callee)  ]  <-- ASP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   715
//        ...
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   716
address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   717
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   718
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   719
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   720
  const bool inc_counter = UseCompiler || CountCompiledCalls;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   721
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   722
  // -----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   723
  // Allocate a new frame that represents the native callee (i2n frame).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   724
  // This is not a full-blown interpreter frame, but in particular, the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   725
  // following registers are valid after this:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   726
  // - R19_method
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   727
  // - R18_local (points to start of argumuments to native function)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   728
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   729
  //   abstract stack (grows up)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   730
  //     [  IJava (caller of JNI callee)  ]  <-- ASP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   731
  //        ...
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   732
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   733
  const Register signature_handler_fd = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   734
  const Register pending_exception    = R0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   735
  const Register result_handler_addr  = R31;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   736
  const Register native_method_fd     = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   737
  const Register access_flags         = R22_tmp2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   738
  const Register active_handles       = R11_scratch1; // R26_monitor saved to state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   739
  const Register sync_state           = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   740
  const Register sync_state_addr      = sync_state;   // Address is dead after use.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   741
  const Register suspend_flags        = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   742
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   743
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   744
  // Allocate new frame and initialize interpreter state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   745
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   746
  Label exception_return;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   747
  Label exception_return_sync_check;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   748
  Label stack_overflow_return;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   749
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   750
  // Generate new interpreter state and jump to stack_overflow_return in case of
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   751
  // a stack overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   752
  //generate_compute_interpreter_state(stack_overflow_return);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   753
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   754
  Register size_of_parameters = R22_tmp2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   755
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   756
  generate_fixed_frame(true, size_of_parameters, noreg /* unused */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   757
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   758
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   759
  // Increment invocation counter. On overflow, entry to JNI method
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   760
  // will be compiled.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   761
  Label invocation_counter_overflow, continue_after_compile;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   762
  if (inc_counter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   763
    if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   764
      // Since at this point in the method invocation the exception handler
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   765
      // would try to exit the monitor of synchronized methods which hasn't
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   766
      // been entered yet, we set the thread local variable
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   767
      // _do_not_unlock_if_synchronized to true. If any exception was thrown by
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   768
      // runtime, exception handling i.e. unlock_if_synchronized_method will
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   769
      // check this thread local flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   770
      // This flag has two effects, one is to force an unwind in the topmost
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   771
      // interpreter frame and not perform an unlock while doing so.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   772
      __ li(R0, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   773
      __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   774
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   775
    generate_counter_incr(&invocation_counter_overflow, NULL, NULL);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   776
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   777
    __ BIND(continue_after_compile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   778
    // Reset the _do_not_unlock_if_synchronized flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   779
    if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   780
      __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   781
      __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   782
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   783
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   784
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   785
  // access_flags = method->access_flags();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   786
  // Load access flags.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   787
  assert(access_flags->is_nonvolatile(),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   788
         "access_flags must be in a non-volatile register");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   789
  // Type check.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   790
  assert(4 == sizeof(AccessFlags), "unexpected field size");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   791
  __ lwz(access_flags, method_(access_flags));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   792
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   793
  // We don't want to reload R19_method and access_flags after calls
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   794
  // to some helper functions.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   795
  assert(R19_method->is_nonvolatile(),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   796
         "R19_method must be a non-volatile register");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   797
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   798
  // Check for synchronized methods. Must happen AFTER invocation counter
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   799
  // check, so method is not locked if counter overflows.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   800
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   801
  if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   802
    lock_method(access_flags, R11_scratch1, R12_scratch2, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   803
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   804
    // Update monitor in state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   805
    __ ld(R11_scratch1, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   806
    __ std(R26_monitor, _ijava_state_neg(monitors), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   807
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   808
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   809
  // jvmti/jvmpi support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   810
  __ notify_method_entry();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   811
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   812
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   813
  // Get and call the signature handler.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   814
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   815
  __ ld(signature_handler_fd, method_(signature_handler));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   816
  Label call_signature_handler;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   817
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   818
  __ cmpdi(CCR0, signature_handler_fd, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   819
  __ bne(CCR0, call_signature_handler);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   820
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   821
  // Method has never been called. Either generate a specialized
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   822
  // handler or point to the slow one.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   823
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   824
  // Pass parameter 'false' to avoid exception check in call_VM.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   825
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), R19_method, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   826
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   827
  // Check for an exception while looking up the target method. If we
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   828
  // incurred one, bail.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   829
  __ ld(pending_exception, thread_(pending_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   830
  __ cmpdi(CCR0, pending_exception, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   831
  __ bne(CCR0, exception_return_sync_check); // Has pending exception.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   832
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   833
  // Reload signature handler, it may have been created/assigned in the meanwhile.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   834
  __ ld(signature_handler_fd, method_(signature_handler));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   835
  __ twi_0(signature_handler_fd); // Order wrt. load of klass mirror and entry point (isync is below).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   836
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   837
  __ BIND(call_signature_handler);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   838
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   839
  // Before we call the signature handler we push a new frame to
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   840
  // protect the interpreter frame volatile registers when we return
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   841
  // from jni but before we can get back to Java.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   842
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   843
  // First set the frame anchor while the SP/FP registers are
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   844
  // convenient and the slow signature handler can use this same frame
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   845
  // anchor.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   846
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   847
  // We have a TOP_IJAVA_FRAME here, which belongs to us.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   848
  __ set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R12_scratch2/*tmp*/);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   849
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   850
  // Now the interpreter frame (and its call chain) have been
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   851
  // invalidated and flushed. We are now protected against eager
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   852
  // being enabled in native code. Even if it goes eager the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   853
  // registers will be reloaded as clean and we will invalidate after
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   854
  // the call so no spurious flush should be possible.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   855
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   856
  // Call signature handler and pass locals address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   857
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   858
  // Our signature handlers copy required arguments to the C stack
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   859
  // (outgoing C args), R3_ARG1 to R10_ARG8, and FARG1 to FARG13.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   860
  __ mr(R3_ARG1, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   861
  __ ld(signature_handler_fd, 0, signature_handler_fd);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   862
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   863
  __ call_stub(signature_handler_fd);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   864
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   865
  // Remove the register parameter varargs slots we allocated in
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   866
  // compute_interpreter_state. SP+16 ends up pointing to the ABI
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   867
  // outgoing argument area.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   868
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   869
  // Not needed on PPC64.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   870
  //__ add(SP, SP, Argument::n_register_parameters*BytesPerWord);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   871
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   872
  assert(result_handler_addr->is_nonvolatile(), "result_handler_addr must be in a non-volatile register");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   873
  // Save across call to native method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   874
  __ mr(result_handler_addr, R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   875
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   876
  __ isync(); // Acquire signature handler before trying to fetch the native entry point and klass mirror.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   877
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   878
  // Set up fixed parameters and call the native method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   879
  // If the method is static, get mirror into R4_ARG2.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   880
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   881
    Label method_is_not_static;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   882
    // Access_flags is non-volatile and still, no need to restore it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   883
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   884
    // Restore access flags.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   885
    __ testbitdi(CCR0, R0, access_flags, JVM_ACC_STATIC_BIT);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   886
    __ bfalse(CCR0, method_is_not_static);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   887
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   888
    // constants = method->constants();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   889
    __ ld(R11_scratch1, in_bytes(Method::const_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   890
    __ ld(R11_scratch1, in_bytes(ConstMethod::constants_offset()), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   891
    // pool_holder = method->constants()->pool_holder();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   892
    __ ld(R11_scratch1/*pool_holder*/, ConstantPool::pool_holder_offset_in_bytes(),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   893
          R11_scratch1/*constants*/);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   894
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   895
    const int mirror_offset = in_bytes(Klass::java_mirror_offset());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   896
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   897
    // mirror = pool_holder->klass_part()->java_mirror();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   898
    __ ld(R0/*mirror*/, mirror_offset, R11_scratch1/*pool_holder*/);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   899
    // state->_native_mirror = mirror;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   900
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   901
    __ ld(R11_scratch1, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   902
    __ std(R0/*mirror*/, _ijava_state_neg(oop_tmp), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   903
    // R4_ARG2 = &state->_oop_temp;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   904
    __ addi(R4_ARG2, R11_scratch1, _ijava_state_neg(oop_tmp));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   905
    __ BIND(method_is_not_static);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   906
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   907
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   908
  // At this point, arguments have been copied off the stack into
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   909
  // their JNI positions. Oops are boxed in-place on the stack, with
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   910
  // handles copied to arguments. The result handler address is in a
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   911
  // register.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   912
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   913
  // Pass JNIEnv address as first parameter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   914
  __ addir(R3_ARG1, thread_(jni_environment));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   915
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   916
  // Load the native_method entry before we change the thread state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   917
  __ ld(native_method_fd, method_(native_function));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   918
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   919
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   920
  // Transition from _thread_in_Java to _thread_in_native. As soon as
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   921
  // we make this change the safepoint code needs to be certain that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   922
  // the last Java frame we established is good. The pc in that frame
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   923
  // just needs to be near here not an actual return address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   924
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   925
  // We use release_store_fence to update values like the thread state, where
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   926
  // we don't want the current thread to continue until all our prior memory
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   927
  // accesses (including the new thread state) are visible to other threads.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   928
  __ li(R0, _thread_in_native);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   929
  __ release();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   930
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   931
  // TODO PPC port assert(4 == JavaThread::sz_thread_state(), "unexpected field size");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   932
  __ stw(R0, thread_(thread_state));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   933
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   934
  if (UseMembar) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   935
    __ fence();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   936
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   937
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   938
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   939
  // Call the native method. Argument registers must not have been
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   940
  // overwritten since "__ call_stub(signature_handler);" (except for
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   941
  // ARG1 and ARG2 for static methods).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   942
  __ call_c(native_method_fd);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   943
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   944
  __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   945
  __ ld(R11_scratch1, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   946
  __ std(R3_RET, _ijava_state_neg(lresult), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   947
  __ stfd(F1_RET, _ijava_state_neg(fresult), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   948
  __ std(R0/*mirror*/, _ijava_state_neg(oop_tmp), R11_scratch1); // reset
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   949
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   950
  // Note: C++ interpreter needs the following here:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   951
  // The frame_manager_lr field, which we use for setting the last
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   952
  // java frame, gets overwritten by the signature handler. Restore
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   953
  // it now.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   954
  //__ get_PC_trash_LR(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   955
  //__ std(R11_scratch1, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   956
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   957
  // Because of GC R19_method may no longer be valid.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   958
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   959
  // Block, if necessary, before resuming in _thread_in_Java state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   960
  // In order for GC to work, don't clear the last_Java_sp until after
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   961
  // blocking.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   962
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   963
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   964
  // Switch thread to "native transition" state before reading the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   965
  // synchronization state. This additional state is necessary
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   966
  // because reading and testing the synchronization state is not
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   967
  // atomic w.r.t. GC, as this scenario demonstrates: Java thread A,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   968
  // in _thread_in_native state, loads _not_synchronized and is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   969
  // preempted. VM thread changes sync state to synchronizing and
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   970
  // suspends threads for GC. Thread A is resumed to finish this
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   971
  // native method, but doesn't block here since it didn't see any
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   972
  // synchronization in progress, and escapes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   973
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   974
  // We use release_store_fence to update values like the thread state, where
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   975
  // we don't want the current thread to continue until all our prior memory
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   976
  // accesses (including the new thread state) are visible to other threads.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   977
  __ li(R0/*thread_state*/, _thread_in_native_trans);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   978
  __ release();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   979
  __ stw(R0/*thread_state*/, thread_(thread_state));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   980
  if (UseMembar) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   981
    __ fence();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   982
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   983
  // Write serialization page so that the VM thread can do a pseudo remote
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   984
  // membar. We use the current thread pointer to calculate a thread
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   985
  // specific offset to write to within the page. This minimizes bus
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   986
  // traffic due to cache line collision.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   987
  else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   988
    __ serialize_memory(R16_thread, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   989
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   990
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   991
  // Now before we return to java we must look for a current safepoint
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   992
  // (a new safepoint can not start since we entered native_trans).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   993
  // We must check here because a current safepoint could be modifying
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   994
  // the callers registers right this moment.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   995
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   996
  // Acquire isn't strictly necessary here because of the fence, but
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   997
  // sync_state is declared to be volatile, so we do it anyway
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   998
  // (cmp-br-isync on one path, release (same as acquire on PPC64) on the other path).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   999
  int sync_state_offs = __ load_const_optimized(sync_state_addr, SafepointSynchronize::address_of_state(), /*temp*/R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1000
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1001
  // TODO PPC port assert(4 == SafepointSynchronize::sz_state(), "unexpected field size");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1002
  __ lwz(sync_state, sync_state_offs, sync_state_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1003
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1004
  // TODO PPC port assert(4 == Thread::sz_suspend_flags(), "unexpected field size");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1005
  __ lwz(suspend_flags, thread_(suspend_flags));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1006
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1007
  Label sync_check_done;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1008
  Label do_safepoint;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1009
  // No synchronization in progress nor yet synchronized.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1010
  __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1011
  // Not suspended.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1012
  __ cmpwi(CCR1, suspend_flags, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1013
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1014
  __ bne(CCR0, do_safepoint);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1015
  __ beq(CCR1, sync_check_done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1016
  __ bind(do_safepoint);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1017
  __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1018
  // Block. We do the call directly and leave the current
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1019
  // last_Java_frame setup undisturbed. We must save any possible
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1020
  // native result across the call. No oop is present.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1021
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1022
  __ mr(R3_ARG1, R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1023
  __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, JavaThread::check_special_condition_for_native_trans),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1024
            relocInfo::none);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1025
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1026
  __ bind(sync_check_done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1027
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1028
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1029
  // <<<<<< Back in Interpreter Frame >>>>>
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1030
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1031
  // We are in thread_in_native_trans here and back in the normal
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1032
  // interpreter frame. We don't have to do anything special about
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1033
  // safepoints and we can switch to Java mode anytime we are ready.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1034
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1035
  // Note: frame::interpreter_frame_result has a dependency on how the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1036
  // method result is saved across the call to post_method_exit. For
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1037
  // native methods it assumes that the non-FPU/non-void result is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1038
  // saved in _native_lresult and a FPU result in _native_fresult. If
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1039
  // this changes then the interpreter_frame_result implementation
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1040
  // will need to be updated too.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1041
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1042
  // On PPC64, we have stored the result directly after the native call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1043
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1044
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1045
  // Back in Java
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1046
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1047
  // We use release_store_fence to update values like the thread state, where
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1048
  // we don't want the current thread to continue until all our prior memory
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1049
  // accesses (including the new thread state) are visible to other threads.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1050
  __ li(R0/*thread_state*/, _thread_in_Java);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1051
  __ release();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1052
  __ stw(R0/*thread_state*/, thread_(thread_state));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1053
  if (UseMembar) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1054
    __ fence();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1055
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1056
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1057
  __ reset_last_Java_frame();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1058
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1059
  // Jvmdi/jvmpi support. Whether we've got an exception pending or
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1060
  // not, and whether unlocking throws an exception or not, we notify
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1061
  // on native method exit. If we do have an exception, we'll end up
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1062
  // in the caller's context to handle it, so if we don't do the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1063
  // notify here, we'll drop it on the floor.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1064
  __ notify_method_exit(true/*native method*/,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1065
                        ilgl /*illegal state (not used for native methods)*/,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1066
                        InterpreterMacroAssembler::NotifyJVMTI,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1067
                        false /*check_exceptions*/);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1068
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1069
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1070
  // Handle exceptions
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1071
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1072
  if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1073
    // Don't check for exceptions since we're still in the i2n frame. Do that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1074
    // manually afterwards.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1075
    unlock_method(false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1076
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1077
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1078
  // Reset active handles after returning from native.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1079
  // thread->active_handles()->clear();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1080
  __ ld(active_handles, thread_(active_handles));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1081
  // TODO PPC port assert(4 == JNIHandleBlock::top_size_in_bytes(), "unexpected field size");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1082
  __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1083
  __ stw(R0, JNIHandleBlock::top_offset_in_bytes(), active_handles);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1084
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1085
  Label exception_return_sync_check_already_unlocked;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1086
  __ ld(R0/*pending_exception*/, thread_(pending_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1087
  __ cmpdi(CCR0, R0/*pending_exception*/, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1088
  __ bne(CCR0, exception_return_sync_check_already_unlocked);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1089
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1090
  //-----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1091
  // No exception pending.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1092
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1093
  // Move native method result back into proper registers and return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1094
  // Invoke result handler (may unbox/promote).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1095
  __ ld(R11_scratch1, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1096
  __ ld(R3_RET, _ijava_state_neg(lresult), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1097
  __ lfd(F1_RET, _ijava_state_neg(fresult), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1098
  __ call_stub(result_handler_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1099
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1100
  __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ R0, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1101
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1102
  // Must use the return pc which was loaded from the caller's frame
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1103
  // as the VM uses return-pc-patching for deoptimization.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1104
  __ mtlr(R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1105
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1106
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1107
  //-----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1108
  // An exception is pending. We call into the runtime only if the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1109
  // caller was not interpreted. If it was interpreted the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1110
  // interpreter will do the correct thing. If it isn't interpreted
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1111
  // (call stub/compiled code) we will change our return and continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1112
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1113
  __ BIND(exception_return_sync_check);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1114
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1115
  if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1116
    // Don't check for exceptions since we're still in the i2n frame. Do that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1117
    // manually afterwards.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1118
    unlock_method(false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1119
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1120
  __ BIND(exception_return_sync_check_already_unlocked);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1121
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1122
  const Register return_pc = R31;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1123
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1124
  __ ld(return_pc, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1125
  __ ld(return_pc, _abi(lr), return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1126
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1127
  // Get the address of the exception handler.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1128
  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1129
                  R16_thread,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1130
                  return_pc /* return pc */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1131
  __ merge_frames(/*top_frame_sp*/ R21_sender_SP, noreg, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1132
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1133
  // Load the PC of the the exception handler into LR.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1134
  __ mtlr(R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1135
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1136
  // Load exception into R3_ARG1 and clear pending exception in thread.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1137
  __ ld(R3_ARG1/*exception*/, thread_(pending_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1138
  __ li(R4_ARG2, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1139
  __ std(R4_ARG2, thread_(pending_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1140
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1141
  // Load the original return pc into R4_ARG2.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1142
  __ mr(R4_ARG2/*issuing_pc*/, return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1143
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1144
  // Return to exception handler.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1145
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1146
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1147
  //=============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1148
  // Counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1149
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1150
  if (inc_counter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1151
    // Handle invocation counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1152
    __ bind(invocation_counter_overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1153
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1154
    generate_counter_overflow(continue_after_compile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1155
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1156
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1157
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1158
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1159
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1160
// Generic interpreted method entry to (asm) interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1161
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1162
address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1163
  bool inc_counter = UseCompiler || CountCompiledCalls;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1164
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1165
  // Generate the code to allocate the interpreter stack frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1166
  Register Rsize_of_parameters = R4_ARG2, // Written by generate_fixed_frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1167
           Rsize_of_locals     = R5_ARG3; // Written by generate_fixed_frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1168
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1169
  generate_fixed_frame(false, Rsize_of_parameters, Rsize_of_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1170
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1171
#ifdef FAST_DISPATCH
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1172
  __ unimplemented("Fast dispatch in generate_normal_entry");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1173
#if 0
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1174
  __ set((intptr_t)Interpreter::dispatch_table(), IdispatchTables);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1175
  // Set bytecode dispatch table base.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1176
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1177
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1178
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1179
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1180
  // Zero out non-parameter locals.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1181
  // Note: *Always* zero out non-parameter locals as Sparc does. It's not
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1182
  // worth to ask the flag, just do it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1183
  Register Rslot_addr = R6_ARG4,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1184
           Rnum       = R7_ARG5;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1185
  Label Lno_locals, Lzero_loop;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1186
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1187
  // Set up the zeroing loop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1188
  __ subf(Rnum, Rsize_of_parameters, Rsize_of_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1189
  __ subf(Rslot_addr, Rsize_of_parameters, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1190
  __ srdi_(Rnum, Rnum, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1191
  __ beq(CCR0, Lno_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1192
  __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1193
  __ mtctr(Rnum);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1194
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1195
  // The zero locals loop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1196
  __ bind(Lzero_loop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1197
  __ std(R0, 0, Rslot_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1198
  __ addi(Rslot_addr, Rslot_addr, -Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1199
  __ bdnz(Lzero_loop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1200
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1201
  __ bind(Lno_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1202
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1203
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1204
  // Counter increment and overflow check.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1205
  Label invocation_counter_overflow,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1206
        profile_method,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1207
        profile_method_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1208
  if (inc_counter || ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1209
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1210
    Register Rdo_not_unlock_if_synchronized_addr = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1211
    if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1212
      // Since at this point in the method invocation the exception handler
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1213
      // would try to exit the monitor of synchronized methods which hasn't
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1214
      // been entered yet, we set the thread local variable
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1215
      // _do_not_unlock_if_synchronized to true. If any exception was thrown by
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1216
      // runtime, exception handling i.e. unlock_if_synchronized_method will
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1217
      // check this thread local flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1218
      // This flag has two effects, one is to force an unwind in the topmost
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1219
      // interpreter frame and not perform an unlock while doing so.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1220
      __ li(R0, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1221
      __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1222
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1223
    // Increment invocation counter and check for overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1224
    if (inc_counter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1225
      generate_counter_incr(&invocation_counter_overflow, &profile_method, &profile_method_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1226
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1227
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1228
    __ bind(profile_method_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1229
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1230
    // Reset the _do_not_unlock_if_synchronized flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1231
    if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1232
      __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1233
      __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1234
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1235
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1236
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1237
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1238
  // Locking of synchronized methods. Must happen AFTER invocation_counter
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1239
  // check and stack overflow check, so method is not locked if overflows.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1240
  if (synchronized) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1241
    lock_method(R3_ARG1, R4_ARG2, R5_ARG3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1242
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1243
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1244
  else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1245
    Label Lok;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1246
    __ lwz(R0, in_bytes(Method::access_flags_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1247
    __ andi_(R0, R0, JVM_ACC_SYNCHRONIZED);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1248
    __ asm_assert_eq("method needs synchronization", 0x8521);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1249
    __ bind(Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1250
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1251
#endif // ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1252
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1253
  __ verify_thread();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1254
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1255
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1256
  // JVMTI support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1257
  __ notify_method_entry();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1258
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1259
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1260
  // Start executing instructions.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1261
  __ dispatch_next(vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1262
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1263
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1264
  // Out of line counter overflow and MDO creation code.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1265
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1266
    // We have decided to profile this method in the interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1267
    __ bind(profile_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1268
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1269
    __ set_method_data_pointer_for_bcp();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1270
    __ b(profile_method_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1271
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1272
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1273
  if (inc_counter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1274
    // Handle invocation counter overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1275
    __ bind(invocation_counter_overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1276
    generate_counter_overflow(profile_method_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1277
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1278
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1279
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1280
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1281
// =============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1282
// Entry points
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1283
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1284
address AbstractInterpreterGenerator::generate_method_entry(
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1285
                                        AbstractInterpreter::MethodKind kind) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1286
  // Determine code generation flags.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1287
  bool synchronized = false;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1288
  address entry_point = NULL;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1289
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1290
  switch (kind) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1291
  case Interpreter::zerolocals             :                                                                             break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1292
  case Interpreter::zerolocals_synchronized: synchronized = true;                                                        break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1293
  case Interpreter::native                 : entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1294
  case Interpreter::native_synchronized    : entry_point = ((InterpreterGenerator*) this)->generate_native_entry(true);  break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1295
  case Interpreter::empty                  : entry_point = ((InterpreterGenerator*) this)->generate_empty_entry();       break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1296
  case Interpreter::accessor               : entry_point = ((InterpreterGenerator*) this)->generate_accessor_entry();    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1297
  case Interpreter::abstract               : entry_point = ((InterpreterGenerator*) this)->generate_abstract_entry();    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1298
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1299
  case Interpreter::java_lang_math_sin     : // fall thru
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1300
  case Interpreter::java_lang_math_cos     : // fall thru
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1301
  case Interpreter::java_lang_math_tan     : // fall thru
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1302
  case Interpreter::java_lang_math_abs     : // fall thru
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1303
  case Interpreter::java_lang_math_log     : // fall thru
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1304
  case Interpreter::java_lang_math_log10   : // fall thru
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1305
  case Interpreter::java_lang_math_sqrt    : // fall thru
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1306
  case Interpreter::java_lang_math_pow     : // fall thru
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1307
  case Interpreter::java_lang_math_exp     : entry_point = ((InterpreterGenerator*) this)->generate_math_entry(kind);    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1308
  case Interpreter::java_lang_ref_reference_get
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1309
                                           : entry_point = ((InterpreterGenerator*)this)->generate_Reference_get_entry(); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1310
  default                                  : ShouldNotReachHere();                                                       break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1311
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1312
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1313
  if (entry_point) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1314
    return entry_point;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1315
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1316
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1317
  return ((InterpreterGenerator*) this)->generate_normal_entry(synchronized);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1318
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1319
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1320
// These should never be compiled since the interpreter will prefer
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1321
// the compiled version to the intrinsic version.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1322
bool AbstractInterpreter::can_be_compiled(methodHandle m) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1323
  return !math_entry_available(method_kind(m));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1324
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1325
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1326
// How much stack a method activation needs in stack slots.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1327
// We must calc this exactly like in generate_fixed_frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1328
// Note: This returns the conservative size assuming maximum alignment.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1329
int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1330
  const int max_alignment_size = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1331
  const int abi_scratch = frame::abi_reg_args_size;
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1332
  return method->max_locals() + method->max_stack() +
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1333
         frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1334
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1335
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1336
// Returns number of stackElementWords needed for the interpreter frame with the
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1337
// given sections.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1338
// This overestimates the stack by one slot in case of alignments.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1339
int AbstractInterpreter::size_activation(int max_stack,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1340
                                         int temps,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1341
                                         int extra_args,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1342
                                         int monitors,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1343
                                         int callee_params,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1344
                                         int callee_locals,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1345
                                         bool is_top_frame) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1346
  // Note: This calculation must exactly parallel the frame setup
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1347
  // in AbstractInterpreterGenerator::generate_method_entry.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1348
  assert(Interpreter::stackElementWords == 1, "sanity");
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1349
  const int max_alignment_space = StackAlignmentInBytes / Interpreter::stackElementSize;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1350
  const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1351
                                         (frame::abi_minframe_size / Interpreter::stackElementSize);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1352
  const int size =
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1353
    max_stack                                                +
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1354
    (callee_locals - callee_params)                          +
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1355
    monitors * frame::interpreter_frame_monitor_size()       +
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1356
    max_alignment_space                                      +
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1357
    abi_scratch                                              +
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1358
    frame::ijava_state_size / Interpreter::stackElementSize;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1359
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1360
  // Fixed size of an interpreter frame, align to 16-byte.
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1361
  return (size & -2);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1362
}
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1363
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1364
// Fills a sceletal interpreter frame generated during deoptimizations.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1365
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1366
// Parameters:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1367
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1368
// interpreter_frame != NULL:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1369
//   set up the method, locals, and monitors.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1370
//   The frame interpreter_frame, if not NULL, is guaranteed to be the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1371
//   right size, as determined by a previous call to this method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1372
//   It is also guaranteed to be walkable even though it is in a skeletal state
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1373
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1374
// is_top_frame == true:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1375
//   We're processing the *oldest* interpreter frame!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1376
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1377
// pop_frame_extra_args:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1378
//   If this is != 0 we are returning to a deoptimized frame by popping
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1379
//   off the callee frame. We want to re-execute the call that called the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1380
//   callee interpreted, but since the return to the interpreter would pop
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1381
//   the arguments off advance the esp by dummy popframe_extra_args slots.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1382
//   Popping off those will establish the stack layout as it was before the call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1383
//
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1384
void AbstractInterpreter::layout_activation(Method* method,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1385
                                            int tempcount,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1386
                                            int popframe_extra_args,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1387
                                            int moncount,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1388
                                            int caller_actual_parameters,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1389
                                            int callee_param_count,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1390
                                            int callee_locals_count,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1391
                                            frame* caller,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1392
                                            frame* interpreter_frame,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1393
                                            bool is_top_frame,
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1394
                                            bool is_bottom_frame) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1395
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1396
  const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1397
                                         (frame::abi_minframe_size / Interpreter::stackElementSize);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1398
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1399
  intptr_t* locals_base  = (caller->is_interpreted_frame()) ?
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1400
    caller->interpreter_frame_esp() + caller_actual_parameters :
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1401
    caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize) ;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1402
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1403
  intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize ;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1404
  intptr_t* monitor      = monitor_base - (moncount * frame::interpreter_frame_monitor_size());
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1405
  intptr_t* esp_base     = monitor - 1;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1406
  intptr_t* esp          = esp_base - tempcount - popframe_extra_args;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1407
  intptr_t* sp           = (intptr_t *) (((intptr_t) (esp_base - callee_locals_count + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1408
  intptr_t* sender_sp    = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1409
  intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1410
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1411
  interpreter_frame->interpreter_frame_set_method(method);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1412
  interpreter_frame->interpreter_frame_set_locals(locals_base);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1413
  interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache());
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1414
  interpreter_frame->interpreter_frame_set_esp(esp);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1415
  interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1416
  interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp);
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1417
  if (!is_bottom_frame) {
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23522
diff changeset
  1418
    interpreter_frame->interpreter_frame_set_sender_sp(sender_sp);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1419
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1420
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1421
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1422
// =============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1423
// Exceptions
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1424
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1425
void TemplateInterpreterGenerator::generate_throw_exception() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1426
  Register Rexception    = R17_tos,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1427
           Rcontinuation = R3_RET;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1428
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1429
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1430
  // Entry point if an method returns with a pending exception (rethrow).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1431
  Interpreter::_rethrow_exception_entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1432
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1433
    __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1434
    __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1435
    __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1436
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1437
    // Compiled code destroys templateTableBase, reload.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1438
    __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1439
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1440
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1441
  // Entry point if a interpreted method throws an exception (throw).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1442
  Interpreter::_throw_exception_entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1443
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1444
    __ mr(Rexception, R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1445
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1446
    __ verify_thread();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1447
    __ verify_oop(Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1448
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1449
    // Expression stack must be empty before entering the VM in case of an exception.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1450
    __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1451
    // Find exception handler address and preserve exception oop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1452
    // Call C routine to find handler and jump to it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1453
    __ call_VM(Rexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::exception_handler_for_exception), Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1454
    __ mtctr(Rcontinuation);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1455
    // Push exception for exception handler bytecodes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1456
    __ push_ptr(Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1457
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1458
    // Jump to exception handler (may be remove activation entry!).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1459
    __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1460
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1461
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1462
  // If the exception is not handled in the current frame the frame is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1463
  // removed and the exception is rethrown (i.e. exception
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1464
  // continuation is _rethrow_exception).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1465
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1466
  // Note: At this point the bci is still the bxi for the instruction
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1467
  // which caused the exception and the expression stack is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1468
  // empty. Thus, for any VM calls at this point, GC will find a legal
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1469
  // oop map (with empty expression stack).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1470
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1471
  // In current activation
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1472
  // tos: exception
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1473
  // bcp: exception bcp
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1474
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1475
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1476
  // JVMTI PopFrame support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1477
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1478
  Interpreter::_remove_activation_preserving_args_entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1479
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1480
    // Set the popframe_processing bit in popframe_condition indicating that we are
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1481
    // currently handling popframe, so that call_VMs that may happen later do not
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1482
    // trigger new popframe handling cycles.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1483
    __ lwz(R11_scratch1, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1484
    __ ori(R11_scratch1, R11_scratch1, JavaThread::popframe_processing_bit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1485
    __ stw(R11_scratch1, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1486
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1487
    // Empty the expression stack, as in normal exception handling.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1488
    __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1489
    __ unlock_if_synchronized_method(vtos, /* throw_monitor_exception */ false, /* install_monitor_exception */ false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1490
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1491
    // Check to see whether we are returning to a deoptimized frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1492
    // (The PopFrame call ensures that the caller of the popped frame is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1493
    // either interpreted or compiled and deoptimizes it if compiled.)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1494
    // Note that we don't compare the return PC against the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1495
    // deoptimization blob's unpack entry because of the presence of
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1496
    // adapter frames in C2.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1497
    Label Lcaller_not_deoptimized;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1498
    Register return_pc = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1499
    __ ld(return_pc, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1500
    __ ld(return_pc, _abi(lr), return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1501
    __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::interpreter_contains), return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1502
    __ cmpdi(CCR0, R3_RET, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1503
    __ bne(CCR0, Lcaller_not_deoptimized);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1504
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1505
    // The deoptimized case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1506
    // In this case, we can't call dispatch_next() after the frame is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1507
    // popped, but instead must save the incoming arguments and restore
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1508
    // them after deoptimization has occurred.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1509
    __ ld(R4_ARG2, in_bytes(Method::const_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1510
    __ lhz(R4_ARG2 /* number of params */, in_bytes(ConstMethod::size_of_parameters_offset()), R4_ARG2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1511
    __ slwi(R4_ARG2, R4_ARG2, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1512
    __ addi(R5_ARG3, R18_locals, Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1513
    __ subf(R5_ARG3, R4_ARG2, R5_ARG3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1514
    // Save these arguments.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1515
    __ call_VM_leaf(CAST_FROM_FN_PTR(address, Deoptimization::popframe_preserve_args), R16_thread, R4_ARG2, R5_ARG3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1516
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1517
    // Inform deoptimization that it is responsible for restoring these arguments.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1518
    __ load_const_optimized(R11_scratch1, JavaThread::popframe_force_deopt_reexecution_bit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1519
    __ stw(R11_scratch1, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1520
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1521
    // Return from the current method into the deoptimization blob. Will eventually
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1522
    // end up in the deopt interpeter entry, deoptimization prepared everything that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1523
    // we will reexecute the call that called us.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1524
    __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*reload return_pc*/ return_pc, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1525
    __ mtlr(return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1526
    __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1527
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1528
    // The non-deoptimized case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1529
    __ bind(Lcaller_not_deoptimized);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1530
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1531
    // Clear the popframe condition flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1532
    __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1533
    __ stw(R0, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1534
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1535
    // Get out of the current method and re-execute the call that called us.
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1536
    __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ noreg, R11_scratch1, R12_scratch2);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1537
    __ restore_interpreter_state(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1538
    __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1539
    __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1540
    if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1541
      __ set_method_data_pointer_for_bcp();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1542
    }
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1543
#if INCLUDE_JVMTI
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1544
    Label L_done;
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1545
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1546
    __ lbz(R11_scratch1, 0, R14_bcp);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1547
    __ cmpwi(CCR0, R11_scratch1, Bytecodes::_invokestatic);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1548
    __ bne(CCR0, L_done);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1549
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1550
    // The member name argument must be restored if _invokestatic is re-executed after a PopFrame call.
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1551
    // Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL.
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1552
    __ ld(R4_ARG2, 0, R18_locals);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1553
    __ call_VM(R11_scratch1, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null),
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1554
               R4_ARG2, R19_method, R14_bcp);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1555
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1556
    __ cmpdi(CCR0, R11_scratch1, 0);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1557
    __ beq(CCR0, L_done);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1558
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1559
    __ std(R11_scratch1, wordSize, R15_esp);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1560
    __ bind(L_done);
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24018
diff changeset
  1561
#endif // INCLUDE_JVMTI
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1562
    __ dispatch_next(vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1563
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1564
  // end of JVMTI PopFrame support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1565
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1566
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1567
  // Remove activation exception entry.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1568
  // This is jumped to if an interpreted method can't handle an exception itself
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1569
  // (we come from the throw/rethrow exception entry above). We're going to call
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1570
  // into the VM to find the exception handler in the caller, pop the current
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1571
  // frame and return the handler we calculated.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1572
  Interpreter::_remove_activation_entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1573
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1574
    __ pop_ptr(Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1575
    __ verify_thread();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1576
    __ verify_oop(Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1577
    __ std(Rexception, in_bytes(JavaThread::vm_result_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1578
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1579
    __ unlock_if_synchronized_method(vtos, /* throw_monitor_exception */ false, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1580
    __ notify_method_exit(false, vtos, InterpreterMacroAssembler::SkipNotifyJVMTI, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1581
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1582
    __ get_vm_result(Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1583
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1584
    // We are done with this activation frame; find out where to go next.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1585
    // The continuation point will be an exception handler, which expects
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1586
    // the following registers set up:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1587
    //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1588
    // RET:  exception oop
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1589
    // ARG2: Issuing PC (see generate_exception_blob()), only used if the caller is compiled.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1590
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1591
    Register return_pc = R31; // Needs to survive the runtime call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1592
    __ ld(return_pc, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1593
    __ ld(return_pc, _abi(lr), return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1594
    __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), R16_thread, return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1595
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1596
    // Remove the current activation.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1597
    __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ noreg, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1598
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1599
    __ mr(R4_ARG2, return_pc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1600
    __ mtlr(R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1601
    __ mr(R3_RET, Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1602
    __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1603
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1604
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1605
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1606
// JVMTI ForceEarlyReturn support.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1607
// Returns "in the middle" of a method with a "fake" return value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1608
address TemplateInterpreterGenerator::generate_earlyret_entry_for(TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1609
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1610
  Register Rscratch1 = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1611
           Rscratch2 = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1612
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1613
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1614
  __ empty_expression_stack();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1615
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1616
  __ load_earlyret_value(state, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1617
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1618
  __ ld(Rscratch1, in_bytes(JavaThread::jvmti_thread_state_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1619
  // Clear the earlyret state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1620
  __ li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1621
  __ stw(R0, in_bytes(JvmtiThreadState::earlyret_state_offset()), Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1622
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1623
  __ remove_activation(state, false, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1624
  // Copied from TemplateTable::_return.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1625
  // Restoration of lr done by remove_activation.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1626
  switch (state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1627
    case ltos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1628
    case btos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1629
    case ctos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1630
    case stos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1631
    case atos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1632
    case itos: __ mr(R3_RET, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1633
    case ftos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1634
    case dtos: __ fmr(F1_RET, F15_ftos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1635
    case vtos: // This might be a constructor. Final fields (and volatile fields on PPC64) need
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1636
               // to get visible before the reference to the object gets stored anywhere.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1637
               __ membar(Assembler::StoreStore); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1638
    default  : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1639
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1640
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1641
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1642
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1643
} // end of ForceEarlyReturn support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1644
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1645
//-----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1646
// Helper for vtos entry point generation
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1647
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1648
void TemplateInterpreterGenerator::set_vtos_entry_points(Template* t,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1649
                                                         address& bep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1650
                                                         address& cep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1651
                                                         address& sep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1652
                                                         address& aep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1653
                                                         address& iep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1654
                                                         address& lep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1655
                                                         address& fep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1656
                                                         address& dep,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1657
                                                         address& vep) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1658
  assert(t->is_valid() && t->tos_in() == vtos, "illegal template");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1659
  Label L;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1660
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1661
  aep = __ pc();  __ push_ptr();  __ b(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1662
  fep = __ pc();  __ push_f();    __ b(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1663
  dep = __ pc();  __ push_d();    __ b(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1664
  lep = __ pc();  __ push_l();    __ b(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1665
  __ align(32, 12, 24); // align L
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1666
  bep = cep = sep =
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1667
  iep = __ pc();  __ push_i();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1668
  vep = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1669
  __ bind(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1670
  generate_and_dispatch(t);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1671
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1672
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1673
//-----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1674
// Generation of individual instructions
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1675
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1676
// helpers for generate_and_dispatch
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1677
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1678
InterpreterGenerator::InterpreterGenerator(StubQueue* code)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1679
  : TemplateInterpreterGenerator(code) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1680
  generate_all(); // Down here so it can be "virtual".
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1681
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1682
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1683
//-----------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1684
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1685
// Non-product code
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1686
#ifndef PRODUCT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1687
address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1688
  //__ flush_bundle();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1689
  address entry = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1690
23522
217a6a90aad3 8038201: Clean up misleading usage of malloc() in init_system_properties_values()
goetz
parents: 23221
diff changeset
  1691
  const char *bname = NULL;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1692
  uint tsize = 0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1693
  switch(state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1694
  case ftos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1695
    bname = "trace_code_ftos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1696
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1697
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1698
  case btos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1699
    bname = "trace_code_btos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1700
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1701
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1702
  case ctos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1703
    bname = "trace_code_ctos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1704
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1705
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1706
  case stos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1707
    bname = "trace_code_stos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1708
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1709
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1710
  case itos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1711
    bname = "trace_code_itos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1712
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1713
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1714
  case ltos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1715
    bname = "trace_code_ltos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1716
    tsize = 3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1717
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1718
  case atos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1719
    bname = "trace_code_atos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1720
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1721
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1722
  case vtos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1723
    // Note: In case of vtos, the topmost of stack value could be a int or doubl
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1724
    // In case of a double (2 slots) we won't see the 2nd stack value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1725
    // Maybe we simply should print the topmost 3 stack slots to cope with the problem.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1726
    bname = "trace_code_vtos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1727
    tsize = 2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1728
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1729
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1730
  case dtos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1731
    bname = "trace_code_dtos {";
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1732
    tsize = 3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1733
    break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1734
  default:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1735
    ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1736
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1737
  BLOCK_COMMENT(bname);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1738
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1739
  // Support short-cut for TraceBytecodesAt.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1740
  // Don't call into the VM if we don't want to trace to speed up things.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1741
  Label Lskip_vm_call;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1742
  if (TraceBytecodesAt > 0 && TraceBytecodesAt < max_intx) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1743
    int offs1 = __ load_const_optimized(R11_scratch1, (address) &TraceBytecodesAt, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1744
    int offs2 = __ load_const_optimized(R12_scratch2, (address) &BytecodeCounter::_counter_value, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1745
    __ ld(R11_scratch1, offs1, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1746
    __ lwa(R12_scratch2, offs2, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1747
    __ cmpd(CCR0, R12_scratch2, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1748
    __ blt(CCR0, Lskip_vm_call);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1749
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1750
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1751
  __ push(state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1752
  // Load 2 topmost expression stack values.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1753
  __ ld(R6_ARG4, tsize*Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1754
  __ ld(R5_ARG3, Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1755
  __ mflr(R31);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1756
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::trace_bytecode), /* unused */ R4_ARG2, R5_ARG3, R6_ARG4, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1757
  __ mtlr(R31);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1758
  __ pop(state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1759
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1760
  if (TraceBytecodesAt > 0 && TraceBytecodesAt < max_intx) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1761
    __ bind(Lskip_vm_call);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1762
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1763
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1764
  BLOCK_COMMENT("} trace_code");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1765
  return entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1766
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1767
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1768
void TemplateInterpreterGenerator::count_bytecode() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1769
  int offs = __ load_const_optimized(R11_scratch1, (address) &BytecodeCounter::_counter_value, R12_scratch2, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1770
  __ lwz(R12_scratch2, offs, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1771
  __ addi(R12_scratch2, R12_scratch2, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1772
  __ stw(R12_scratch2, offs, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1773
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1774
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1775
void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1776
  int offs = __ load_const_optimized(R11_scratch1, (address) &BytecodeHistogram::_counters[t->bytecode()], R12_scratch2, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1777
  __ lwz(R12_scratch2, offs, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1778
  __ addi(R12_scratch2, R12_scratch2, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1779
  __ stw(R12_scratch2, offs, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1780
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1781
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1782
void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1783
  const Register addr = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1784
                 tmp  = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1785
  // Get index, shift out old bytecode, bring in new bytecode, and store it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1786
  // _index = (_index >> log2_number_of_codes) |
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1787
  //          (bytecode << log2_number_of_codes);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1788
  int offs1 = __ load_const_optimized(addr, (address)&BytecodePairHistogram::_index, tmp, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1789
  __ lwz(tmp, offs1, addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1790
  __ srwi(tmp, tmp, BytecodePairHistogram::log2_number_of_codes);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1791
  __ ori(tmp, tmp, ((int) t->bytecode()) << BytecodePairHistogram::log2_number_of_codes);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1792
  __ stw(tmp, offs1, addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1793
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1794
  // Bump bucket contents.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1795
  // _counters[_index] ++;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1796
  int offs2 = __ load_const_optimized(addr, (address)&BytecodePairHistogram::_counters, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1797
  __ sldi(tmp, tmp, LogBytesPerInt);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1798
  __ add(addr, tmp, addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1799
  __ lwz(tmp, offs2, addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1800
  __ addi(tmp, tmp, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1801
  __ stw(tmp, offs2, addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1802
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1803
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1804
void TemplateInterpreterGenerator::trace_bytecode(Template* t) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1805
  // Call a little run-time stub to avoid blow-up for each bytecode.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1806
  // The run-time runtime saves the right registers, depending on
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1807
  // the tosca in-state for the given template.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1808
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1809
  assert(Interpreter::trace_code(t->tos_in()) != NULL,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1810
         "entry must have been generated");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1811
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1812
  // Note: we destroy LR here.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1813
  __ bl(Interpreter::trace_code(t->tos_in()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1814
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1815
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1816
void TemplateInterpreterGenerator::stop_interpreter_at() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1817
  Label L;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1818
  int offs1 = __ load_const_optimized(R11_scratch1, (address) &StopInterpreterAt, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1819
  int offs2 = __ load_const_optimized(R12_scratch2, (address) &BytecodeCounter::_counter_value, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1820
  __ ld(R11_scratch1, offs1, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1821
  __ lwa(R12_scratch2, offs2, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1822
  __ cmpd(CCR0, R12_scratch2, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1823
  __ bne(CCR0, L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1824
  __ illtrap();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1825
  __ bind(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1826
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1827
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1828
#endif // !PRODUCT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1829
#endif // !CC_INTERP