hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp
author duke
Wed, 05 Jul 2017 20:10:48 +0200
changeset 27963 88d7c7c376e9
parent 27012 f8fdfab4757b
child 28187 fc19df82d6ee
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     1
/*
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     2
 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
     3
 * Copyright 2012, 2014 SAP AG. All rights reserved.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     5
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     9
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    14
 * accompanied this code).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    15
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    19
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    22
 * questions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    23
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    24
 */
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    25
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    26
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    27
#include "precompiled.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    28
#include "asm/macroAssembler.inline.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    29
#include "interp_masm_ppc_64.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    30
#include "interpreter/interpreterRuntime.hpp"
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    31
#include "prims/jvmtiThreadState.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    32
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    33
#ifdef PRODUCT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    34
#define BLOCK_COMMENT(str) // nothing
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    35
#else
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    36
#define BLOCK_COMMENT(str) block_comment(str)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    37
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    38
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
    39
void InterpreterMacroAssembler::null_check_throw(Register a, int offset, Register temp_reg) {
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
    40
#ifdef CC_INTERP
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
    41
  address exception_entry = StubRoutines::throw_NullPointerException_at_call_entry();
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
    42
#else
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
    43
  address exception_entry = Interpreter::throw_NullPointerException_entry();
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
    44
#endif
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
    45
  MacroAssembler::null_check_throw(a, offset, temp_reg, exception_entry);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
    46
}
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
    47
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    48
void InterpreterMacroAssembler::branch_to_entry(address entry, Register Rscratch) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    49
  assert(entry, "Entry must have been generated by now");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    50
  if (is_within_range_of_b(entry, pc())) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    51
    b(entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    52
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    53
    load_const_optimized(Rscratch, entry, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    54
    mtctr(Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    55
    bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    56
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    57
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    58
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    59
#ifndef CC_INTERP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    60
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    61
void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    62
  Register bytecode = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    63
  if (bcp_incr != 0) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    64
    lbzu(bytecode, bcp_incr, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    65
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    66
    lbz(bytecode, 0, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    67
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    68
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    69
  dispatch_Lbyte_code(state, bytecode, Interpreter::dispatch_table(state));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    70
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    71
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    72
void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    73
  // Load current bytecode.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    74
  Register bytecode = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    75
  lbz(bytecode, 0, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    76
  dispatch_Lbyte_code(state, bytecode, table);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    77
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    78
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    79
// Dispatch code executed in the prolog of a bytecode which does not do it's
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    80
// own dispatch. The dispatch address is computed and placed in R24_dispatch_addr.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    81
void InterpreterMacroAssembler::dispatch_prolog(TosState state, int bcp_incr) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    82
  Register bytecode = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    83
  lbz(bytecode, bcp_incr, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    84
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    85
  load_dispatch_table(R24_dispatch_addr, Interpreter::dispatch_table(state));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    86
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    87
  sldi(bytecode, bytecode, LogBytesPerWord);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    88
  ldx(R24_dispatch_addr, R24_dispatch_addr, bytecode);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    89
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    90
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    91
// Dispatch code executed in the epilog of a bytecode which does not do it's
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    92
// own dispatch. The dispatch address in R24_dispatch_addr is used for the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    93
// dispatch.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    94
void InterpreterMacroAssembler::dispatch_epilog(TosState state, int bcp_incr) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    95
  mtctr(R24_dispatch_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    96
  addi(R14_bcp, R14_bcp, bcp_incr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    97
  bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    98
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
    99
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   100
void InterpreterMacroAssembler::check_and_handle_popframe(Register scratch_reg) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   101
  assert(scratch_reg != R0, "can't use R0 as scratch_reg here");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   102
  if (JvmtiExport::can_pop_frame()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   103
    Label L;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   104
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   105
    // Check the "pending popframe condition" flag in the current thread.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   106
    lwz(scratch_reg, in_bytes(JavaThread::popframe_condition_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   107
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   108
    // Initiate popframe handling only if it is not already being
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   109
    // processed. If the flag has the popframe_processing bit set, it
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   110
    // means that this code is called *during* popframe handling - we
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   111
    // don't want to reenter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   112
    andi_(R0, scratch_reg, JavaThread::popframe_pending_bit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   113
    beq(CCR0, L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   114
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   115
    andi_(R0, scratch_reg, JavaThread::popframe_processing_bit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   116
    bne(CCR0, L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   117
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   118
    // Call the Interpreter::remove_activation_preserving_args_entry()
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   119
    // func to get the address of the same-named entrypoint in the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   120
    // generated interpreter code.
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   121
#if defined(ABI_ELFv2)
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   122
    call_c(CAST_FROM_FN_PTR(address,
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   123
                            Interpreter::remove_activation_preserving_args_entry),
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   124
           relocInfo::none);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   125
#else
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   126
    call_c(CAST_FROM_FN_PTR(FunctionDescriptor*,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   127
                            Interpreter::remove_activation_preserving_args_entry),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   128
           relocInfo::none);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   129
#endif
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   130
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   131
    // Jump to Interpreter::_remove_activation_preserving_args_entry.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   132
    mtctr(R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   133
    bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   134
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   135
    align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   136
    bind(L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   137
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   138
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   139
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   140
void InterpreterMacroAssembler::check_and_handle_earlyret(Register scratch_reg) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   141
  const Register Rthr_state_addr = scratch_reg;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   142
  if (JvmtiExport::can_force_early_return()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   143
    Label Lno_early_ret;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   144
    ld(Rthr_state_addr, in_bytes(JavaThread::jvmti_thread_state_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   145
    cmpdi(CCR0, Rthr_state_addr, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   146
    beq(CCR0, Lno_early_ret);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   147
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   148
    lwz(R0, in_bytes(JvmtiThreadState::earlyret_state_offset()), Rthr_state_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   149
    cmpwi(CCR0, R0, JvmtiThreadState::earlyret_pending);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   150
    bne(CCR0, Lno_early_ret);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   151
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   152
    // Jump to Interpreter::_earlyret_entry.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   153
    lwz(R3_ARG1, in_bytes(JvmtiThreadState::earlyret_tos_offset()), Rthr_state_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   154
    call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   155
    mtlr(R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   156
    blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   157
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   158
    align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   159
    bind(Lno_early_ret);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   160
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   161
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   162
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   163
void InterpreterMacroAssembler::load_earlyret_value(TosState state, Register Rscratch1) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   164
  const Register RjvmtiState = Rscratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   165
  const Register Rscratch2   = R0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   166
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   167
  ld(RjvmtiState, in_bytes(JavaThread::jvmti_thread_state_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   168
  li(Rscratch2, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   169
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   170
  switch (state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   171
    case atos: ld(R17_tos, in_bytes(JvmtiThreadState::earlyret_oop_offset()), RjvmtiState);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   172
               std(Rscratch2, in_bytes(JvmtiThreadState::earlyret_oop_offset()), RjvmtiState);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   173
               break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   174
    case ltos: ld(R17_tos, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   175
               break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   176
    case btos: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   177
    case ctos: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   178
    case stos: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   179
    case itos: lwz(R17_tos, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   180
               break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   181
    case ftos: lfs(F15_ftos, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   182
               break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   183
    case dtos: lfd(F15_ftos, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   184
               break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   185
    case vtos: break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   186
    default  : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   187
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   188
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   189
  // Clean up tos value in the jvmti thread state.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   190
  std(Rscratch2, in_bytes(JvmtiThreadState::earlyret_value_offset()), RjvmtiState);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   191
  // Set tos state field to illegal value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   192
  li(Rscratch2, ilgl);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   193
  stw(Rscratch2, in_bytes(JvmtiThreadState::earlyret_tos_offset()), RjvmtiState);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   194
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   195
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   196
// Common code to dispatch and dispatch_only.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   197
// Dispatch value in Lbyte_code and increment Lbcp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   198
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   199
void InterpreterMacroAssembler::load_dispatch_table(Register dst, address* table) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   200
  address table_base = (address)Interpreter::dispatch_table((TosState)0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   201
  intptr_t table_offs = (intptr_t)table - (intptr_t)table_base;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   202
  if (is_simm16(table_offs)) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   203
    addi(dst, R25_templateTableBase, (int)table_offs);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   204
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   205
    load_const_optimized(dst, table, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   206
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   207
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   208
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   209
void InterpreterMacroAssembler::dispatch_Lbyte_code(TosState state, Register bytecode, address* table, bool verify) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   210
  if (verify) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   211
    unimplemented("dispatch_Lbyte_code: verify"); // See Sparc Implementation to implement this
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   212
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   213
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   214
#ifdef FAST_DISPATCH
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   215
  unimplemented("dispatch_Lbyte_code FAST_DISPATCH");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   216
#else
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   217
  assert_different_registers(bytecode, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   218
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   219
  // Calc dispatch table address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   220
  load_dispatch_table(R11_scratch1, table);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   222
  sldi(R12_scratch2, bytecode, LogBytesPerWord);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   223
  ldx(R11_scratch1, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   224
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   225
  // Jump off!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   226
  mtctr(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   227
  bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   228
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   229
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   230
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   231
void InterpreterMacroAssembler::load_receiver(Register Rparam_count, Register Rrecv_dst) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   232
  sldi(Rrecv_dst, Rparam_count, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   233
  ldx(Rrecv_dst, Rrecv_dst, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   234
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   235
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   236
// helpers for expression stack
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   237
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   238
void InterpreterMacroAssembler::pop_i(Register r) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   239
  lwzu(r, Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   240
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   241
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   242
void InterpreterMacroAssembler::pop_ptr(Register r) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   243
  ldu(r, Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   244
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   245
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   246
void InterpreterMacroAssembler::pop_l(Register r) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   247
  ld(r, Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   248
  addi(R15_esp, R15_esp, 2 * Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   249
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   250
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   251
void InterpreterMacroAssembler::pop_f(FloatRegister f) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   252
  lfsu(f, Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   253
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   254
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   255
void InterpreterMacroAssembler::pop_d(FloatRegister f) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   256
  lfd(f, Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   257
  addi(R15_esp, R15_esp, 2 * Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   258
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   259
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   260
void InterpreterMacroAssembler::push_i(Register r) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   261
  stw(r, 0, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   262
  addi(R15_esp, R15_esp, - Interpreter::stackElementSize );
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   263
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   264
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   265
void InterpreterMacroAssembler::push_ptr(Register r) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   266
  std(r, 0, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   267
  addi(R15_esp, R15_esp, - Interpreter::stackElementSize );
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   268
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   269
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   270
void InterpreterMacroAssembler::push_l(Register r) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   271
  std(r, - Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   272
  addi(R15_esp, R15_esp, - 2 * Interpreter::stackElementSize );
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   273
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   274
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   275
void InterpreterMacroAssembler::push_f(FloatRegister f) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   276
  stfs(f, 0, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   277
  addi(R15_esp, R15_esp, - Interpreter::stackElementSize );
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   278
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   279
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   280
void InterpreterMacroAssembler::push_d(FloatRegister f)   {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   281
  stfd(f, - Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   282
  addi(R15_esp, R15_esp, - 2 * Interpreter::stackElementSize );
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   283
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   284
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   285
void InterpreterMacroAssembler::push_2ptrs(Register first, Register second) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   286
  std(first, 0, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   287
  std(second, -Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   288
  addi(R15_esp, R15_esp, - 2 * Interpreter::stackElementSize );
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   289
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   290
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   291
void InterpreterMacroAssembler::push_l_pop_d(Register l, FloatRegister d) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   292
  std(l, 0, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   293
  lfd(d, 0, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   294
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   295
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   296
void InterpreterMacroAssembler::push_d_pop_l(FloatRegister d, Register l) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   297
  stfd(d, 0, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   298
  ld(l, 0, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   299
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   300
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   301
void InterpreterMacroAssembler::push(TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   302
  switch (state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   303
    case atos: push_ptr();                break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   304
    case btos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   305
    case ctos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   306
    case stos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   307
    case itos: push_i();                  break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   308
    case ltos: push_l();                  break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   309
    case ftos: push_f();                  break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   310
    case dtos: push_d();                  break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   311
    case vtos: /* nothing to do */        break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   312
    default  : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   313
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   314
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   315
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   316
void InterpreterMacroAssembler::pop(TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   317
  switch (state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   318
    case atos: pop_ptr();            break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   319
    case btos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   320
    case ctos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   321
    case stos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   322
    case itos: pop_i();              break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   323
    case ltos: pop_l();              break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   324
    case ftos: pop_f();              break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   325
    case dtos: pop_d();              break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   326
    case vtos: /* nothing to do */   break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   327
    default  : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   328
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   329
  verify_oop(R17_tos, state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   330
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   331
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   332
void InterpreterMacroAssembler::empty_expression_stack() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   333
  addi(R15_esp, R26_monitor, - Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   334
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   335
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   336
void InterpreterMacroAssembler::get_2_byte_integer_at_bcp(int         bcp_offset,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   337
                                                          Register    Rdst,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   338
                                                          signedOrNot is_signed) {
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   339
#if defined(VM_LITTLE_ENDIAN)
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   340
  if (bcp_offset) {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   341
    load_const_optimized(Rdst, bcp_offset);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   342
    lhbrx(Rdst, R14_bcp, Rdst);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   343
  } else {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   344
    lhbrx(Rdst, R14_bcp);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   345
  }
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   346
  if (is_signed == Signed) {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   347
    extsh(Rdst, Rdst);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   348
  }
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   349
#else
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   350
  // Read Java big endian format.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   351
  if (is_signed == Signed) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   352
    lha(Rdst, bcp_offset, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   353
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   354
    lhz(Rdst, bcp_offset, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   355
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   356
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   357
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   358
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   359
void InterpreterMacroAssembler::get_4_byte_integer_at_bcp(int         bcp_offset,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   360
                                                          Register    Rdst,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   361
                                                          signedOrNot is_signed) {
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   362
#if defined(VM_LITTLE_ENDIAN)
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   363
  if (bcp_offset) {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   364
    load_const_optimized(Rdst, bcp_offset);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   365
    lwbrx(Rdst, R14_bcp, Rdst);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   366
  } else {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   367
    lwbrx(Rdst, R14_bcp);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   368
  }
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   369
  if (is_signed == Signed) {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   370
    extsw(Rdst, Rdst);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   371
  }
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   372
#else
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   373
  // Read Java big endian format.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   374
  if (bcp_offset & 3) { // Offset unaligned?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   375
    load_const_optimized(Rdst, bcp_offset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   376
    if (is_signed == Signed) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   377
      lwax(Rdst, R14_bcp, Rdst);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   378
    } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   379
      lwzx(Rdst, R14_bcp, Rdst);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   380
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   381
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   382
    if (is_signed == Signed) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   383
      lwa(Rdst, bcp_offset, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   384
    } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   385
      lwz(Rdst, bcp_offset, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   386
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   387
  }
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   388
#endif
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   389
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   390
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   391
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   392
// Load the constant pool cache index from the bytecode stream.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   393
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   394
// Kills / writes:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   395
//   - Rdst, Rscratch
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   396
void InterpreterMacroAssembler::get_cache_index_at_bcp(Register Rdst, int bcp_offset, size_t index_size) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   397
  assert(bcp_offset > 0, "bcp is still pointing to start of bytecode");
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   398
  // Cache index is always in the native format, courtesy of Rewriter.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   399
  if (index_size == sizeof(u2)) {
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   400
    lhz(Rdst, bcp_offset, R14_bcp);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   401
  } else if (index_size == sizeof(u4)) {
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   402
    if (bcp_offset & 3) {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   403
      load_const_optimized(Rdst, bcp_offset);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   404
      lwax(Rdst, R14_bcp, Rdst);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   405
    } else {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   406
      lwa(Rdst, bcp_offset, R14_bcp);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   407
    }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   408
    assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   409
    nand(Rdst, Rdst, Rdst); // convert to plain index
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   410
  } else if (index_size == sizeof(u1)) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   411
    lbz(Rdst, bcp_offset, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   412
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   413
    ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   414
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   415
  // Rdst now contains cp cache index.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   416
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   417
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   418
void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, int bcp_offset, size_t index_size) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   419
  get_cache_index_at_bcp(cache, bcp_offset, index_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   420
  sldi(cache, cache, exact_log2(in_words(ConstantPoolCacheEntry::size()) * BytesPerWord));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   421
  add(cache, R27_constPoolCache, cache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   422
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   423
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   424
// Load 4-byte signed or unsigned integer in Java format (that is, big-endian format)
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   425
// from (Rsrc)+offset.
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   426
void InterpreterMacroAssembler::get_u4(Register Rdst, Register Rsrc, int offset,
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   427
                                       signedOrNot is_signed) {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   428
#if defined(VM_LITTLE_ENDIAN)
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   429
  if (offset) {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   430
    load_const_optimized(Rdst, offset);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   431
    lwbrx(Rdst, Rdst, Rsrc);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   432
  } else {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   433
    lwbrx(Rdst, Rsrc);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   434
  }
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   435
  if (is_signed == Signed) {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   436
    extsw(Rdst, Rdst);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   437
  }
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   438
#else
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   439
  if (is_signed == Signed) {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   440
    lwa(Rdst, offset, Rsrc);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   441
  } else {
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   442
    lwz(Rdst, offset, Rsrc);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   443
  }
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   444
#endif
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   445
}
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 24322
diff changeset
   446
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   447
// Load object from cpool->resolved_references(index).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   448
void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   449
  assert_different_registers(result, index);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   450
  get_constant_pool(result);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   451
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   452
  // Convert from field index to resolved_references() index and from
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   453
  // word index to byte offset. Since this is a java object, it can be compressed.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   454
  Register tmp = index;  // reuse
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   455
  sldi(tmp, index, LogBytesPerHeapOop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   456
  // Load pointer for resolved_references[] objArray.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   457
  ld(result, ConstantPool::resolved_references_offset_in_bytes(), result);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   458
  // JNIHandles::resolve(result)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   459
  ld(result, 0, result);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   460
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   461
  Label index_ok;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   462
  lwa(R0, arrayOopDesc::length_offset_in_bytes(), result);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   463
  sldi(R0, R0, LogBytesPerHeapOop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   464
  cmpd(CCR0, tmp, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   465
  blt(CCR0, index_ok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   466
  stop("resolved reference index out of bounds", 0x09256);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   467
  bind(index_ok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   468
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   469
  // Add in the index.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   470
  add(result, tmp, result);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   471
  load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   472
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   473
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   474
// Generate a subtype check: branch to ok_is_subtype if sub_klass is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   475
// a subtype of super_klass. Blows registers Rsub_klass, tmp1, tmp2.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   476
void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass, Register Rsuper_klass, Register Rtmp1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   477
                                                  Register Rtmp2, Register Rtmp3, Label &ok_is_subtype) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   478
  // Profile the not-null value's klass.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   479
  profile_typecheck(Rsub_klass, Rtmp1, Rtmp2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   480
  check_klass_subtype(Rsub_klass, Rsuper_klass, Rtmp1, Rtmp2, ok_is_subtype);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   481
  profile_typecheck_failed(Rtmp1, Rtmp2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   482
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   483
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   484
void InterpreterMacroAssembler::generate_stack_overflow_check_with_compare_and_throw(Register Rmem_frame_size, Register Rscratch1) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   485
  Label done;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   486
  sub(Rmem_frame_size, R1_SP, Rmem_frame_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   487
  ld(Rscratch1, thread_(stack_overflow_limit));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   488
  cmpld(CCR0/*is_stack_overflow*/, Rmem_frame_size, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   489
  bgt(CCR0/*is_stack_overflow*/, done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   490
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   491
  // Load target address of the runtime stub.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   492
  assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "generated in wrong order");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   493
  load_const_optimized(Rscratch1, (StubRoutines::throw_StackOverflowError_entry()), R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   494
  mtctr(Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   495
  // Restore caller_sp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   496
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   497
  ld(Rscratch1, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   498
  ld(R0, 0, R21_sender_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   499
  cmpd(CCR0, R0, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   500
  asm_assert_eq("backlink", 0x547);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   501
#endif // ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   502
  mr(R1_SP, R21_sender_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   503
  bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   504
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   505
  align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   506
  bind(done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   507
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   508
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   509
// Separate these two to allow for delay slot in middle.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   510
// These are used to do a test and full jump to exception-throwing code.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   511
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   512
// Check that index is in range for array, then shift index by index_shift,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   513
// and put arrayOop + shifted_index into res.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   514
// Note: res is still shy of address by array offset into object.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   515
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   516
void InterpreterMacroAssembler::index_check_without_pop(Register Rarray, Register Rindex, int index_shift, Register Rtmp, Register Rres) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   517
  // Check that index is in range for array, then shift index by index_shift,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   518
  // and put arrayOop + shifted_index into res.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   519
  // Note: res is still shy of address by array offset into object.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   520
  // Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   521
  //   - Rindex
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   522
  // Writes:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   523
  //   - Rres: Address that corresponds to the array index if check was successful.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   524
  verify_oop(Rarray);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   525
  const Register Rlength   = R0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   526
  const Register RsxtIndex = Rtmp;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   527
  Label LisNull, LnotOOR;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   528
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   529
  // Array nullcheck
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   530
  if (!ImplicitNullChecks) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   531
    cmpdi(CCR0, Rarray, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   532
    beq(CCR0, LisNull);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   533
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   534
    null_check_throw(Rarray, arrayOopDesc::length_offset_in_bytes(), /*temp*/RsxtIndex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   535
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   536
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   537
  // Rindex might contain garbage in upper bits (remember that we don't sign extend
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   538
  // during integer arithmetic operations). So kill them and put value into same register
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   539
  // where ArrayIndexOutOfBounds would expect the index in.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   540
  rldicl(RsxtIndex, Rindex, 0, 32); // zero extend 32 bit -> 64 bit
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   541
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   542
  // Index check
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   543
  lwz(Rlength, arrayOopDesc::length_offset_in_bytes(), Rarray);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   544
  cmplw(CCR0, Rindex, Rlength);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   545
  sldi(RsxtIndex, RsxtIndex, index_shift);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   546
  blt(CCR0, LnotOOR);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   547
  load_dispatch_table(Rtmp, (address*)Interpreter::_throw_ArrayIndexOutOfBoundsException_entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   548
  mtctr(Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   549
  bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   550
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   551
  if (!ImplicitNullChecks) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   552
    bind(LisNull);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   553
    load_dispatch_table(Rtmp, (address*)Interpreter::_throw_NullPointerException_entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   554
    mtctr(Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   555
    bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   556
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   557
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   558
  align(32, 16);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   559
  bind(LnotOOR);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   560
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   561
  // Calc address
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   562
  add(Rres, RsxtIndex, Rarray);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   563
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   564
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   565
void InterpreterMacroAssembler::index_check(Register array, Register index, int index_shift, Register tmp, Register res) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   566
  // pop array
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   567
  pop_ptr(array);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   568
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   569
  // check array
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   570
  index_check_without_pop(array, index, index_shift, tmp, res);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   571
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   572
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   573
void InterpreterMacroAssembler::get_const(Register Rdst) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   574
  ld(Rdst, in_bytes(Method::const_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   575
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   576
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   577
void InterpreterMacroAssembler::get_constant_pool(Register Rdst) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   578
  get_const(Rdst);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   579
  ld(Rdst, in_bytes(ConstMethod::constants_offset()), Rdst);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   580
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   581
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   582
void InterpreterMacroAssembler::get_constant_pool_cache(Register Rdst) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   583
  get_constant_pool(Rdst);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   584
  ld(Rdst, ConstantPool::cache_offset_in_bytes(), Rdst);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   585
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   586
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   587
void InterpreterMacroAssembler::get_cpool_and_tags(Register Rcpool, Register Rtags) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   588
  get_constant_pool(Rcpool);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   589
  ld(Rtags, ConstantPool::tags_offset_in_bytes(), Rcpool);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   590
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   591
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   592
// Unlock if synchronized method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   593
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   594
// Unlock the receiver if this is a synchronized method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   595
// Unlock any Java monitors from synchronized blocks.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   596
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   597
// If there are locked Java monitors
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   598
//   If throw_monitor_exception
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   599
//     throws IllegalMonitorStateException
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   600
//   Else if install_monitor_exception
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   601
//     installs IllegalMonitorStateException
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   602
//   Else
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   603
//     no error processing
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   604
void InterpreterMacroAssembler::unlock_if_synchronized_method(TosState state,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   605
                                                              bool throw_monitor_exception,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   606
                                                              bool install_monitor_exception) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   607
  Label Lunlocked, Lno_unlock;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   608
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   609
    Register Rdo_not_unlock_flag = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   610
    Register Raccess_flags       = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   611
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   612
    // Check if synchronized method or unlocking prevented by
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   613
    // JavaThread::do_not_unlock_if_synchronized flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   614
    lbz(Rdo_not_unlock_flag, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   615
    lwz(Raccess_flags, in_bytes(Method::access_flags_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   616
    li(R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   617
    stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread); // reset flag
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   618
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   619
    push(state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   620
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   621
    // Skip if we don't have to unlock.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   622
    rldicl_(R0, Raccess_flags, 64-JVM_ACC_SYNCHRONIZED_BIT, 63); // Extract bit and compare to 0.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   623
    beq(CCR0, Lunlocked);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   624
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   625
    cmpwi(CCR0, Rdo_not_unlock_flag, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   626
    bne(CCR0, Lno_unlock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   627
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   628
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   629
  // Unlock
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   630
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   631
    Register Rmonitor_base = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   632
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   633
    Label Lunlock;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   634
    // If it's still locked, everything is ok, unlock it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   635
    ld(Rmonitor_base, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   636
    addi(Rmonitor_base, Rmonitor_base, - (frame::ijava_state_size + frame::interpreter_frame_monitor_size_in_bytes())); // Monitor base
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   637
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   638
    ld(R0, BasicObjectLock::obj_offset_in_bytes(), Rmonitor_base);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   639
    cmpdi(CCR0, R0, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   640
    bne(CCR0, Lunlock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   641
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   642
    // If it's already unlocked, throw exception.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   643
    if (throw_monitor_exception) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   644
      call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   645
      should_not_reach_here();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   646
    } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   647
      if (install_monitor_exception) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   648
        call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::new_illegal_monitor_state_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   649
        b(Lunlocked);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   650
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   651
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   652
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   653
    bind(Lunlock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   654
    unlock_object(Rmonitor_base);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   655
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   656
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   657
  // Check that all other monitors are unlocked. Throw IllegelMonitorState exception if not.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   658
  bind(Lunlocked);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   659
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   660
    Label Lexception, Lrestart;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   661
    Register Rcurrent_obj_addr = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   662
    const int delta = frame::interpreter_frame_monitor_size_in_bytes();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   663
    assert((delta & LongAlignmentMask) == 0, "sizeof BasicObjectLock must be even number of doublewords");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   664
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   665
    bind(Lrestart);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   666
    // Set up search loop: Calc num of iterations.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   667
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   668
      Register Riterations = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   669
      Register Rmonitor_base = Rcurrent_obj_addr;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   670
      ld(Rmonitor_base, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   671
      addi(Rmonitor_base, Rmonitor_base, - frame::ijava_state_size);  // Monitor base
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   672
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   673
      subf_(Riterations, R26_monitor, Rmonitor_base);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   674
      ble(CCR0, Lno_unlock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   675
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   676
      addi(Rcurrent_obj_addr, Rmonitor_base, BasicObjectLock::obj_offset_in_bytes() - frame::interpreter_frame_monitor_size_in_bytes());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   677
      // Check if any monitor is on stack, bail out if not
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   678
      srdi(Riterations, Riterations, exact_log2(delta));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   679
      mtctr(Riterations);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   680
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   681
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   682
    // The search loop: Look for locked monitors.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   683
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   684
      const Register Rcurrent_obj = R0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   685
      Label Lloop;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   686
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   687
      ld(Rcurrent_obj, 0, Rcurrent_obj_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   688
      addi(Rcurrent_obj_addr, Rcurrent_obj_addr, -delta);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   689
      bind(Lloop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   690
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   691
      // Check if current entry is used.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   692
      cmpdi(CCR0, Rcurrent_obj, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   693
      bne(CCR0, Lexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   694
      // Preload next iteration's compare value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   695
      ld(Rcurrent_obj, 0, Rcurrent_obj_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   696
      addi(Rcurrent_obj_addr, Rcurrent_obj_addr, -delta);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   697
      bdnz(Lloop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   698
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   699
    // Fell through: Everything's unlocked => finish.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   700
    b(Lno_unlock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   701
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   702
    // An object is still locked => need to throw exception.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   703
    bind(Lexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   704
    if (throw_monitor_exception) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   705
      call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   706
      should_not_reach_here();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   707
    } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   708
      // Stack unrolling. Unlock object and if requested, install illegal_monitor_exception.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   709
      // Unlock does not block, so don't have to worry about the frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   710
      Register Rmonitor_addr = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   711
      addi(Rmonitor_addr, Rcurrent_obj_addr, -BasicObjectLock::obj_offset_in_bytes() + delta);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   712
      unlock_object(Rmonitor_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   713
      if (install_monitor_exception) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   714
        call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::new_illegal_monitor_state_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   715
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   716
      b(Lrestart);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   717
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   718
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   719
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   720
  align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   721
  bind(Lno_unlock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   722
  pop(state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   723
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   724
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   725
// Support function for remove_activation & Co.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   726
void InterpreterMacroAssembler::merge_frames(Register Rsender_sp, Register return_pc, Register Rscratch1, Register Rscratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   727
  // Pop interpreter frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   728
  ld(Rscratch1, 0, R1_SP); // *SP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   729
  ld(Rsender_sp, _ijava_state_neg(sender_sp), Rscratch1); // top_frame_sp
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   730
  ld(Rscratch2, 0, Rscratch1); // **SP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   731
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   732
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   733
    Label Lok;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   734
    ld(R0, _ijava_state_neg(ijava_reserved), Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   735
    cmpdi(CCR0, R0, 0x5afe);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   736
    beq(CCR0, Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   737
    stop("frame corrupted (remove activation)", 0x5afe);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   738
    bind(Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   739
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   740
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   741
  if (return_pc!=noreg) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   742
    ld(return_pc, _abi(lr), Rscratch1); // LR
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   743
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   744
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   745
  // Merge top frames.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   746
  subf(Rscratch1, R1_SP, Rsender_sp); // top_frame_sp - SP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   747
  stdux(Rscratch2, R1_SP, Rscratch1); // atomically set *(SP = top_frame_sp) = **SP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   748
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   749
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   750
// Remove activation.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   751
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   752
// Unlock the receiver if this is a synchronized method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   753
// Unlock any Java monitors from synchronized blocks.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   754
// Remove the activation from the stack.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   755
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   756
// If there are locked Java monitors
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   757
//    If throw_monitor_exception
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   758
//       throws IllegalMonitorStateException
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   759
//    Else if install_monitor_exception
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   760
//       installs IllegalMonitorStateException
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   761
//    Else
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   762
//       no error processing
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   763
void InterpreterMacroAssembler::remove_activation(TosState state,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   764
                                                  bool throw_monitor_exception,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   765
                                                  bool install_monitor_exception) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   766
  unlock_if_synchronized_method(state, throw_monitor_exception, install_monitor_exception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   767
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   768
  // Save result (push state before jvmti call and pop it afterwards) and notify jvmti.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   769
  notify_method_exit(false, state, NotifyJVMTI, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   770
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   771
  verify_oop(R17_tos, state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   772
  verify_thread();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   773
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   774
  merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ R0, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   775
  mtlr(R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   776
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   777
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   778
#endif // !CC_INTERP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   779
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   780
// Lock object
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   781
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   782
// Registers alive
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   783
//   monitor - Address of the BasicObjectLock to be used for locking,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   784
//             which must be initialized with the object to lock.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   785
//   object  - Address of the object to be locked.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   786
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   787
void InterpreterMacroAssembler::lock_object(Register monitor, Register object) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   788
  if (UseHeavyMonitors) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   789
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   790
            monitor, /*check_for_exceptions=*/true CC_INTERP_ONLY(&& false));
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   791
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   792
    // template code:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   793
    //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   794
    // markOop displaced_header = obj->mark().set_unlocked();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   795
    // monitor->lock()->set_displaced_header(displaced_header);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   796
    // if (Atomic::cmpxchg_ptr(/*ex=*/monitor, /*addr*/obj->mark_addr(), /*cmp*/displaced_header) == displaced_header) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   797
    //   // We stored the monitor address into the object's mark word.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   798
    // } else if (THREAD->is_lock_owned((address)displaced_header))
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   799
    //   // Simple recursive case.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   800
    //   monitor->lock()->set_displaced_header(NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   801
    // } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   802
    //   // Slow path.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   803
    //   InterpreterRuntime::monitorenter(THREAD, monitor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   804
    // }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   805
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   806
    const Register displaced_header = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   807
    const Register object_mark_addr = R8_ARG6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   808
    const Register current_header   = R9_ARG7;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   809
    const Register tmp              = R10_ARG8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   810
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   811
    Label done;
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   812
    Label cas_failed, slow_case;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   813
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   814
    assert_different_registers(displaced_header, object_mark_addr, current_header, tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   815
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   816
    // markOop displaced_header = obj->mark().set_unlocked();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   817
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   818
    // Load markOop from object into displaced_header.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   819
    ld(displaced_header, oopDesc::mark_offset_in_bytes(), object);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   820
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   821
    if (UseBiasedLocking) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   822
      biased_locking_enter(CCR0, object, displaced_header, tmp, current_header, done, &slow_case);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   823
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   825
    // Set displaced_header to be (markOop of object | UNLOCK_VALUE).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   826
    ori(displaced_header, displaced_header, markOopDesc::unlocked_value);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   827
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   828
    // monitor->lock()->set_displaced_header(displaced_header);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   829
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   830
    // Initialize the box (Must happen before we update the object mark!).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   831
    std(displaced_header, BasicObjectLock::lock_offset_in_bytes() +
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   832
        BasicLock::displaced_header_offset_in_bytes(), monitor);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   833
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   834
    // if (Atomic::cmpxchg_ptr(/*ex=*/monitor, /*addr*/obj->mark_addr(), /*cmp*/displaced_header) == displaced_header) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   835
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   836
    // Store stack address of the BasicObjectLock (this is monitor) into object.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   837
    addi(object_mark_addr, object, oopDesc::mark_offset_in_bytes());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   838
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   839
    // Must fence, otherwise, preceding store(s) may float below cmpxchg.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   840
    // CmpxchgX sets CCR0 to cmpX(current, displaced).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   841
    fence(); // TODO: replace by MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq ?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   842
    cmpxchgd(/*flag=*/CCR0,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   843
             /*current_value=*/current_header,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   844
             /*compare_value=*/displaced_header, /*exchange_value=*/monitor,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   845
             /*where=*/object_mark_addr,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   846
             MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   847
             MacroAssembler::cmpxchgx_hint_acquire_lock(),
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   848
             noreg,
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   849
             &cas_failed);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   850
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   851
    // If the compare-and-exchange succeeded, then we found an unlocked
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   852
    // object and we have now locked it.
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   853
    b(done);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   854
    bind(cas_failed);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   855
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   856
    // } else if (THREAD->is_lock_owned((address)displaced_header))
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   857
    //   // Simple recursive case.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   858
    //   monitor->lock()->set_displaced_header(NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   859
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   860
    // We did not see an unlocked object so try the fast recursive case.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   861
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   862
    // Check if owner is self by comparing the value in the markOop of object
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   863
    // (current_header) with the stack pointer.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   864
    sub(current_header, current_header, R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   865
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   866
    assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   867
    load_const_optimized(tmp,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   868
                         (address) (~(os::vm_page_size()-1) |
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   869
                                    markOopDesc::lock_mask_in_place));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   870
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   871
    and_(R0/*==0?*/, current_header, tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   872
    // If condition is true we are done and hence we can store 0 in the displaced
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   873
    // header indicating it is a recursive lock.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   874
    bne(CCR0, slow_case);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   875
    release();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   876
    std(R0/*==0!*/, BasicObjectLock::lock_offset_in_bytes() +
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   877
        BasicLock::displaced_header_offset_in_bytes(), monitor);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   878
    b(done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   879
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   880
    // } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   881
    //   // Slow path.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   882
    //   InterpreterRuntime::monitorenter(THREAD, monitor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   883
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   884
    // None of the above fast optimizations worked so we have to get into the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   885
    // slow case of monitor enter.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   886
    bind(slow_case);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   887
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   888
            monitor, /*check_for_exceptions=*/true CC_INTERP_ONLY(&& false));
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   889
    // }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   890
    align(32, 12);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   891
    bind(done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   892
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   893
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   894
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   895
// Unlocks an object. Used in monitorexit bytecode and remove_activation.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   896
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   897
// Registers alive
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   898
//   monitor - Address of the BasicObjectLock to be used for locking,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   899
//             which must be initialized with the object to lock.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   900
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   901
// Throw IllegalMonitorException if object is not locked by current thread.
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   902
void InterpreterMacroAssembler::unlock_object(Register monitor, bool check_for_exceptions) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   903
  if (UseHeavyMonitors) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   904
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit),
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   905
            monitor, check_for_exceptions CC_INTERP_ONLY(&& false));
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   906
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   907
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   908
    // template code:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   909
    //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   910
    // if ((displaced_header = monitor->displaced_header()) == NULL) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   911
    //   // Recursive unlock. Mark the monitor unlocked by setting the object field to NULL.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   912
    //   monitor->set_obj(NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   913
    // } else if (Atomic::cmpxchg_ptr(displaced_header, obj->mark_addr(), monitor) == monitor) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   914
    //   // We swapped the unlocked mark in displaced_header into the object's mark word.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   915
    //   monitor->set_obj(NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   916
    // } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   917
    //   // Slow path.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   918
    //   InterpreterRuntime::monitorexit(THREAD, monitor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   919
    // }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   920
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   921
    const Register object           = R7_ARG5;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   922
    const Register displaced_header = R8_ARG6;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   923
    const Register object_mark_addr = R9_ARG7;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   924
    const Register current_header   = R10_ARG8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   925
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   926
    Label free_slot;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   927
    Label slow_case;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   928
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   929
    assert_different_registers(object, displaced_header, object_mark_addr, current_header);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   930
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   931
    if (UseBiasedLocking) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   932
      // The object address from the monitor is in object.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   933
      ld(object, BasicObjectLock::obj_offset_in_bytes(), monitor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   934
      assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   935
      biased_locking_exit(CCR0, object, displaced_header, free_slot);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   936
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   937
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   938
    // Test first if we are in the fast recursive case.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   939
    ld(displaced_header, BasicObjectLock::lock_offset_in_bytes() +
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   940
           BasicLock::displaced_header_offset_in_bytes(), monitor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   941
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   942
    // If the displaced header is zero, we have a recursive unlock.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   943
    cmpdi(CCR0, displaced_header, 0);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   944
    beq(CCR0, free_slot); // recursive unlock
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   945
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   946
    // } else if (Atomic::cmpxchg_ptr(displaced_header, obj->mark_addr(), monitor) == monitor) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   947
    //   // We swapped the unlocked mark in displaced_header into the object's mark word.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   948
    //   monitor->set_obj(NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   949
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   950
    // If we still have a lightweight lock, unlock the object and be done.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   951
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   952
    // The object address from the monitor is in object.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   953
    if (!UseBiasedLocking) { ld(object, BasicObjectLock::obj_offset_in_bytes(), monitor); }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   954
    addi(object_mark_addr, object, oopDesc::mark_offset_in_bytes());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   955
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   956
    // We have the displaced header in displaced_header. If the lock is still
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   957
    // lightweight, it will contain the monitor address and we'll store the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   958
    // displaced header back into the object's mark word.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   959
    // CmpxchgX sets CCR0 to cmpX(current, monitor).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   960
    cmpxchgd(/*flag=*/CCR0,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   961
             /*current_value=*/current_header,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   962
             /*compare_value=*/monitor, /*exchange_value=*/displaced_header,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   963
             /*where=*/object_mark_addr,
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   964
             MacroAssembler::MemBarRel,
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   965
             MacroAssembler::cmpxchgx_hint_release_lock(),
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   966
             noreg,
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   967
             &slow_case);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   968
    b(free_slot);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   969
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   970
    // } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   971
    //   // Slow path.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   972
    //   InterpreterRuntime::monitorexit(THREAD, monitor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   973
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   974
    // The lock has been converted into a heavy lock and hence
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   975
    // we need to get into the slow case.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   976
    bind(slow_case);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   977
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit),
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   978
            monitor, check_for_exceptions CC_INTERP_ONLY(&& false));
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   979
    // }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   980
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   981
    Label done;
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   982
    b(done); // Monitor register may be overwritten! Runtime has already freed the slot.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   983
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   984
    // Exchange worked, do monitor->set_obj(NULL);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   985
    align(32, 12);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   986
    bind(free_slot);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   987
    li(R0, 0);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   988
    std(R0, BasicObjectLock::obj_offset_in_bytes(), monitor);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   989
    bind(done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   990
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   991
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   992
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   993
#ifndef CC_INTERP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   994
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   995
// Load compiled (i2c) or interpreter entry when calling from interpreted and
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   996
// do the call. Centralized so that all interpreter calls will do the same actions.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   997
// If jvmti single stepping is on for a thread we must not call compiled code.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   998
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
   999
// Input:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1000
//   - Rtarget_method: method to call
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1001
//   - Rret_addr:      return address
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1002
//   - 2 scratch regs
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1003
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1004
void InterpreterMacroAssembler::call_from_interpreter(Register Rtarget_method, Register Rret_addr, Register Rscratch1, Register Rscratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1005
  assert_different_registers(Rscratch1, Rscratch2, Rtarget_method, Rret_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1006
  // Assume we want to go compiled if available.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1007
  const Register Rtarget_addr = Rscratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1008
  const Register Rinterp_only = Rscratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1009
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1010
  ld(Rtarget_addr, in_bytes(Method::from_interpreted_offset()), Rtarget_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1011
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1012
  if (JvmtiExport::can_post_interpreter_events()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1013
    lwz(Rinterp_only, in_bytes(JavaThread::interp_only_mode_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1014
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1015
    // JVMTI events, such as single-stepping, are implemented partly by avoiding running
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1016
    // compiled code in threads for which the event is enabled. Check here for
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1017
    // interp_only_mode if these events CAN be enabled.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1018
    Label done;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1019
    verify_thread();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1020
    cmpwi(CCR0, Rinterp_only, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1021
    beq(CCR0, done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1022
    ld(Rtarget_addr, in_bytes(Method::interpreter_entry_offset()), Rtarget_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1023
    align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1024
    bind(done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1025
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1026
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1027
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1028
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1029
    Label Lok;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1030
    cmpdi(CCR0, Rtarget_addr, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1031
    bne(CCR0, Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1032
    stop("null entry point");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1033
    bind(Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1034
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1035
#endif // ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1036
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1037
  mr(R21_sender_SP, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1038
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1039
  // Calc a precise SP for the call. The SP value we calculated in
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1040
  // generate_fixed_frame() is based on the max_stack() value, so we would waste stack space
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1041
  // if esp is not max. Also, the i2c adapter extends the stack space without restoring
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1042
  // our pre-calced value, so repeating calls via i2c would result in stack overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1043
  // Since esp already points to an empty slot, we just have to sub 1 additional slot
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1044
  // to meet the abi scratch requirements.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1045
  // The max_stack pointer will get restored by means of the GR_Lmax_stack local in
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1046
  // the return entry of the interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1047
  addi(Rscratch2, R15_esp, Interpreter::stackElementSize - frame::abi_reg_args_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1048
  clrrdi(Rscratch2, Rscratch2, exact_log2(frame::alignment_in_bytes)); // round towards smaller address
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1049
  resize_frame_absolute(Rscratch2, Rscratch2, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1050
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1051
  mr_if_needed(R19_method, Rtarget_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1052
  mtctr(Rtarget_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1053
  mtlr(Rret_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1054
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1055
  save_interpreter_state(Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1056
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1057
  ld(Rscratch1, _ijava_state_neg(top_frame_sp), Rscratch2); // Rscratch2 contains fp
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1058
  cmpd(CCR0, R21_sender_SP, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1059
  asm_assert_eq("top_frame_sp incorrect", 0x951);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1060
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1061
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1062
  bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1063
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1064
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1065
// Set the method data pointer for the current bcp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1066
void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1067
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1068
  Label get_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1069
  ld(R28_mdx, in_bytes(Method::method_data_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1070
  test_method_data_pointer(get_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1071
  call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), R19_method, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1072
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1073
  addi(R28_mdx, R28_mdx, in_bytes(MethodData::data_offset()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1074
  add(R28_mdx, R28_mdx, R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1075
  bind(get_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1076
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1077
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1078
// Test ImethodDataPtr. If it is null, continue at the specified label.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1079
void InterpreterMacroAssembler::test_method_data_pointer(Label& zero_continue) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1080
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1081
  cmpdi(CCR0, R28_mdx, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1082
  beq(CCR0, zero_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1083
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1084
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1085
void InterpreterMacroAssembler::verify_method_data_pointer() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1086
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1087
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1088
  Label verify_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1089
  test_method_data_pointer(verify_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1090
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1091
  // If the mdp is valid, it will point to a DataLayout header which is
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1092
  // consistent with the bcp. The converse is highly probable also.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1093
  lhz(R11_scratch1, in_bytes(DataLayout::bci_offset()), R28_mdx);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1094
  ld(R12_scratch2, in_bytes(Method::const_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1095
  addi(R11_scratch1, R11_scratch1, in_bytes(ConstMethod::codes_offset()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1096
  add(R11_scratch1, R12_scratch2, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1097
  cmpd(CCR0, R11_scratch1, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1098
  beq(CCR0, verify_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1099
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1100
  call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp ), R19_method, R14_bcp, R28_mdx);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1101
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1102
  bind(verify_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1103
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1104
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1105
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1106
void InterpreterMacroAssembler::test_invocation_counter_for_mdp(Register invocation_count,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1107
                                                                Register Rscratch,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1108
                                                                Label &profile_continue) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1109
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1110
  // Control will flow to "profile_continue" if the counter is less than the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1111
  // limit or if we call profile_method().
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1112
  Label done;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1113
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1114
  // If no method data exists, and the counter is high enough, make one.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1115
  int ipl_offs = load_const_optimized(Rscratch, &InvocationCounter::InterpreterProfileLimit, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1116
  lwz(Rscratch, ipl_offs, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1117
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1118
  cmpdi(CCR0, R28_mdx, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1119
  // Test to see if we should create a method data oop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1120
  cmpd(CCR1, Rscratch /* InterpreterProfileLimit */, invocation_count);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1121
  bne(CCR0, done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1122
  bge(CCR1, profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1123
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1124
  // Build it now.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1125
  call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1126
  set_method_data_pointer_for_bcp();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1127
  b(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1128
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1129
  align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1130
  bind(done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1131
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1132
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1133
void InterpreterMacroAssembler::test_backedge_count_for_osr(Register backedge_count, Register branch_bcp, Register Rtmp) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1134
  assert_different_registers(backedge_count, Rtmp, branch_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1135
  assert(UseOnStackReplacement,"Must UseOnStackReplacement to test_backedge_count_for_osr");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1136
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1137
  Label did_not_overflow;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1138
  Label overflow_with_error;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1139
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1140
  int ibbl_offs = load_const_optimized(Rtmp, &InvocationCounter::InterpreterBackwardBranchLimit, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1141
  lwz(Rtmp, ibbl_offs, Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1142
  cmpw(CCR0, backedge_count, Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1143
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1144
  blt(CCR0, did_not_overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1145
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1146
  // When ProfileInterpreter is on, the backedge_count comes from the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1147
  // methodDataOop, which value does not get reset on the call to
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1148
  // frequency_counter_overflow(). To avoid excessive calls to the overflow
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1149
  // routine while the method is being compiled, add a second test to make sure
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1150
  // the overflow function is called only once every overflow_frequency.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1151
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1152
    const int overflow_frequency = 1024;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1153
    li(Rtmp, overflow_frequency-1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1154
    andr(Rtmp, Rtmp, backedge_count);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1155
    cmpwi(CCR0, Rtmp, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1156
    bne(CCR0, did_not_overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1157
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1158
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1159
  // Overflow in loop, pass branch bytecode.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1160
  call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), branch_bcp, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1161
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1162
  // Was an OSR adapter generated?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1163
  // O0 = osr nmethod
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1164
  cmpdi(CCR0, R3_RET, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1165
  beq(CCR0, overflow_with_error);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1166
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1167
  // Has the nmethod been invalidated already?
26705
fca1785e7084 8048721: -XX:+PrintCompilation prints negative bci for non entrant OSR methods
thartmann
parents: 25916
diff changeset
  1168
  lbz(Rtmp, nmethod::state_offset(), R3_RET);
fca1785e7084 8048721: -XX:+PrintCompilation prints negative bci for non entrant OSR methods
thartmann
parents: 25916
diff changeset
  1169
  cmpwi(CCR0, Rtmp, nmethod::in_use);
fca1785e7084 8048721: -XX:+PrintCompilation prints negative bci for non entrant OSR methods
thartmann
parents: 25916
diff changeset
  1170
  bne(CCR0, overflow_with_error);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1171
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1172
  // Migrate the interpreter frame off of the stack.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1173
  // We can use all registers because we will not return to interpreter from this point.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1174
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1175
  // Save nmethod.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1176
  const Register osr_nmethod = R31;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1177
  mr(osr_nmethod, R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1178
  set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1179
  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_begin), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1180
  reset_last_Java_frame();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1181
  // OSR buffer is in ARG1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1182
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1183
  // Remove the interpreter frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1184
  merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ R0, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1185
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1186
  // Jump to the osr code.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1187
  ld(R11_scratch1, nmethod::osr_entry_point_offset(), osr_nmethod);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1188
  mtlr(R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1189
  mtctr(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1190
  bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1191
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1192
  align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1193
  bind(overflow_with_error);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1194
  bind(did_not_overflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1195
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1196
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1197
// Store a value at some constant offset from the method data pointer.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1198
void InterpreterMacroAssembler::set_mdp_data_at(int constant, Register value) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1199
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1200
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1201
  std(value, constant, R28_mdx);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1202
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1203
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1204
// Increment the value at some constant offset from the method data pointer.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1205
void InterpreterMacroAssembler::increment_mdp_data_at(int constant,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1206
                                                      Register counter_addr,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1207
                                                      Register Rbumped_count,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1208
                                                      bool decrement) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1209
  // Locate the counter at a fixed offset from the mdp:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1210
  addi(counter_addr, R28_mdx, constant);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1211
  increment_mdp_data_at(counter_addr, Rbumped_count, decrement);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1212
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1213
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1214
// Increment the value at some non-fixed (reg + constant) offset from
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1215
// the method data pointer.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1216
void InterpreterMacroAssembler::increment_mdp_data_at(Register reg,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1217
                                                      int constant,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1218
                                                      Register scratch,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1219
                                                      Register Rbumped_count,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1220
                                                      bool decrement) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1221
  // Add the constant to reg to get the offset.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1222
  add(scratch, R28_mdx, reg);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1223
  // Then calculate the counter address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1224
  addi(scratch, scratch, constant);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1225
  increment_mdp_data_at(scratch, Rbumped_count, decrement);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1226
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1227
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1228
void InterpreterMacroAssembler::increment_mdp_data_at(Register counter_addr,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1229
                                                      Register Rbumped_count,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1230
                                                      bool decrement) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1231
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1232
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1233
  // Load the counter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1234
  ld(Rbumped_count, 0, counter_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1235
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1236
  if (decrement) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1237
    // Decrement the register. Set condition codes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1238
    addi(Rbumped_count, Rbumped_count, - DataLayout::counter_increment);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1239
    // Store the decremented counter, if it is still negative.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1240
    std(Rbumped_count, 0, counter_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1241
    // Note: add/sub overflow check are not ported, since 64 bit
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1242
    // calculation should never overflow.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1243
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1244
    // Increment the register. Set carry flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1245
    addi(Rbumped_count, Rbumped_count, DataLayout::counter_increment);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1246
    // Store the incremented counter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1247
    std(Rbumped_count, 0, counter_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1248
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1249
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1250
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1251
// Set a flag value at the current method data pointer position.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1252
void InterpreterMacroAssembler::set_mdp_flag_at(int flag_constant,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1253
                                                Register scratch) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1254
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1255
  // Load the data header.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1256
  lbz(scratch, in_bytes(DataLayout::flags_offset()), R28_mdx);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1257
  // Set the flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1258
  ori(scratch, scratch, flag_constant);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1259
  // Store the modified header.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1260
  stb(scratch, in_bytes(DataLayout::flags_offset()), R28_mdx);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1261
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1262
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1263
// Test the location at some offset from the method data pointer.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1264
// If it is not equal to value, branch to the not_equal_continue Label.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1265
void InterpreterMacroAssembler::test_mdp_data_at(int offset,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1266
                                                 Register value,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1267
                                                 Label& not_equal_continue,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1268
                                                 Register test_out) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1269
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1270
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1271
  ld(test_out, offset, R28_mdx);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1272
  cmpd(CCR0,  value, test_out);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1273
  bne(CCR0, not_equal_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1274
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1275
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1276
// Update the method data pointer by the displacement located at some fixed
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1277
// offset from the method data pointer.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1278
void InterpreterMacroAssembler::update_mdp_by_offset(int offset_of_disp,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1279
                                                     Register scratch) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1280
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1281
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1282
  ld(scratch, offset_of_disp, R28_mdx);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1283
  add(R28_mdx, scratch, R28_mdx);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1284
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1285
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1286
// Update the method data pointer by the displacement located at the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1287
// offset (reg + offset_of_disp).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1288
void InterpreterMacroAssembler::update_mdp_by_offset(Register reg,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1289
                                                     int offset_of_disp,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1290
                                                     Register scratch) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1291
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1292
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1293
  add(scratch, reg, R28_mdx);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1294
  ld(scratch, offset_of_disp, scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1295
  add(R28_mdx, scratch, R28_mdx);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1296
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1297
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1298
// Update the method data pointer by a simple constant displacement.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1299
void InterpreterMacroAssembler::update_mdp_by_constant(int constant) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1300
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1301
  addi(R28_mdx, R28_mdx, constant);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1302
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1303
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1304
// Update the method data pointer for a _ret bytecode whose target
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1305
// was not among our cached targets.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1306
void InterpreterMacroAssembler::update_mdp_for_ret(TosState state,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1307
                                                   Register return_bci) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1308
  assert(ProfileInterpreter, "must be profiling interpreter");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1309
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1310
  push(state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1311
  assert(return_bci->is_nonvolatile(), "need to protect return_bci");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1312
  call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret), return_bci);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1313
  pop(state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1314
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1315
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1316
// Increments the backedge counter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1317
// Returns backedge counter + invocation counter in Rdst.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1318
void InterpreterMacroAssembler::increment_backedge_counter(const Register Rcounters, const Register Rdst,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1319
                                                           const Register Rtmp1, Register Rscratch) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1320
  assert(UseCompiler, "incrementing must be useful");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1321
  assert_different_registers(Rdst, Rtmp1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1322
  const Register invocation_counter = Rtmp1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1323
  const Register counter = Rdst;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1324
  // TODO ppc port assert(4 == InvocationCounter::sz_counter(), "unexpected field size.");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1325
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1326
  // Load backedge counter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1327
  lwz(counter, in_bytes(MethodCounters::backedge_counter_offset()) +
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1328
               in_bytes(InvocationCounter::counter_offset()), Rcounters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1329
  // Load invocation counter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1330
  lwz(invocation_counter, in_bytes(MethodCounters::invocation_counter_offset()) +
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1331
                          in_bytes(InvocationCounter::counter_offset()), Rcounters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1332
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1333
  // Add the delta to the backedge counter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1334
  addi(counter, counter, InvocationCounter::count_increment);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1335
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1336
  // Mask the invocation counter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1337
  li(Rscratch, InvocationCounter::count_mask_value);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1338
  andr(invocation_counter, invocation_counter, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1339
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1340
  // Store new counter value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1341
  stw(counter, in_bytes(MethodCounters::backedge_counter_offset()) +
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1342
               in_bytes(InvocationCounter::counter_offset()), Rcounters);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1343
  // Return invocation counter + backedge counter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1344
  add(counter, counter, invocation_counter);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1345
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1346
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1347
// Count a taken branch in the bytecodes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1348
void InterpreterMacroAssembler::profile_taken_branch(Register scratch, Register bumped_count) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1349
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1350
    Label profile_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1351
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1352
    // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1353
    test_method_data_pointer(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1354
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1355
    // We are taking a branch. Increment the taken count.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1356
    increment_mdp_data_at(in_bytes(JumpData::taken_offset()), scratch, bumped_count);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1357
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1358
    // The method data pointer needs to be updated to reflect the new target.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1359
    update_mdp_by_offset(in_bytes(JumpData::displacement_offset()), scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1360
    bind (profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1361
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1362
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1363
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1364
// Count a not-taken branch in the bytecodes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1365
void InterpreterMacroAssembler::profile_not_taken_branch(Register scratch1, Register scratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1366
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1367
    Label profile_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1368
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1369
    // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1370
    test_method_data_pointer(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1371
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1372
    // We are taking a branch. Increment the not taken count.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1373
    increment_mdp_data_at(in_bytes(BranchData::not_taken_offset()), scratch1, scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1374
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1375
    // The method data pointer needs to be updated to correspond to the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1376
    // next bytecode.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1377
    update_mdp_by_constant(in_bytes(BranchData::branch_data_size()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1378
    bind (profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1379
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1380
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1381
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1382
// Count a non-virtual call in the bytecodes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1383
void InterpreterMacroAssembler::profile_call(Register scratch1, Register scratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1384
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1385
    Label profile_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1386
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1387
    // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1388
    test_method_data_pointer(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1389
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1390
    // We are making a call. Increment the count.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1391
    increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch1, scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1392
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1393
    // The method data pointer needs to be updated to reflect the new target.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1394
    update_mdp_by_constant(in_bytes(CounterData::counter_data_size()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1395
    bind (profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1396
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1397
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1398
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1399
// Count a final call in the bytecodes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1400
void InterpreterMacroAssembler::profile_final_call(Register scratch1, Register scratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1401
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1402
    Label profile_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1403
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1404
    // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1405
    test_method_data_pointer(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1406
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1407
    // We are making a call. Increment the count.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1408
    increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch1, scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1409
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1410
    // The method data pointer needs to be updated to reflect the new target.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1411
    update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1412
    bind (profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1413
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1414
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1415
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1416
// Count a virtual call in the bytecodes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1417
void InterpreterMacroAssembler::profile_virtual_call(Register Rreceiver,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1418
                                                     Register Rscratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1419
                                                     Register Rscratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1420
                                                     bool receiver_can_be_null) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1421
  if (!ProfileInterpreter) { return; }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1422
  Label profile_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1423
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1424
  // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1425
  test_method_data_pointer(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1426
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1427
  Label skip_receiver_profile;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1428
  if (receiver_can_be_null) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1429
    Label not_null;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1430
    cmpdi(CCR0, Rreceiver, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1431
    bne(CCR0, not_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1432
    // We are making a call. Increment the count for null receiver.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1433
    increment_mdp_data_at(in_bytes(CounterData::count_offset()), Rscratch1, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1434
    b(skip_receiver_profile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1435
    bind(not_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1436
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1437
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1438
  // Record the receiver type.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1439
  record_klass_in_profile(Rreceiver, Rscratch1, Rscratch2, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1440
  bind(skip_receiver_profile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1441
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1442
  // The method data pointer needs to be updated to reflect the new target.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1443
  update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1444
  bind (profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1445
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1446
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1447
void InterpreterMacroAssembler::profile_typecheck(Register Rklass, Register Rscratch1, Register Rscratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1448
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1449
    Label profile_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1450
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1451
    // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1452
    test_method_data_pointer(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1453
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1454
    int mdp_delta = in_bytes(BitData::bit_data_size());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1455
    if (TypeProfileCasts) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1456
      mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1457
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1458
      // Record the object type.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1459
      record_klass_in_profile(Rklass, Rscratch1, Rscratch2, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1460
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1461
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1462
    // The method data pointer needs to be updated.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1463
    update_mdp_by_constant(mdp_delta);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1464
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1465
    bind (profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1466
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1467
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1468
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1469
void InterpreterMacroAssembler::profile_typecheck_failed(Register Rscratch1, Register Rscratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1470
  if (ProfileInterpreter && TypeProfileCasts) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1471
    Label profile_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1472
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1473
    // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1474
    test_method_data_pointer(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1475
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1476
    int count_offset = in_bytes(CounterData::count_offset());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1477
    // Back up the address, since we have already bumped the mdp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1478
    count_offset -= in_bytes(VirtualCallData::virtual_call_data_size());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1479
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1480
    // *Decrement* the counter. We expect to see zero or small negatives.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1481
    increment_mdp_data_at(count_offset, Rscratch1, Rscratch2, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1482
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1483
    bind (profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1484
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1485
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1486
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1487
// Count a ret in the bytecodes.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1488
void InterpreterMacroAssembler::profile_ret(TosState state, Register return_bci, Register scratch1, Register scratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1489
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1490
    Label profile_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1491
    uint row;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1492
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1493
    // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1494
    test_method_data_pointer(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1495
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1496
    // Update the total ret count.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1497
    increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch1, scratch2 );
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1498
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1499
    for (row = 0; row < RetData::row_limit(); row++) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1500
      Label next_test;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1501
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1502
      // See if return_bci is equal to bci[n]:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1503
      test_mdp_data_at(in_bytes(RetData::bci_offset(row)), return_bci, next_test, scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1504
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1505
      // return_bci is equal to bci[n]. Increment the count.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1506
      increment_mdp_data_at(in_bytes(RetData::bci_count_offset(row)), scratch1, scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1507
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1508
      // The method data pointer needs to be updated to reflect the new target.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1509
      update_mdp_by_offset(in_bytes(RetData::bci_displacement_offset(row)), scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1510
      b(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1511
      bind(next_test);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1512
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1513
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1514
    update_mdp_for_ret(state, return_bci);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1515
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1516
    bind (profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1517
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1518
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1519
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1520
// Count the default case of a switch construct.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1521
void InterpreterMacroAssembler::profile_switch_default(Register scratch1,  Register scratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1522
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1523
    Label profile_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1524
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1525
    // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1526
    test_method_data_pointer(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1527
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1528
    // Update the default case count
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1529
    increment_mdp_data_at(in_bytes(MultiBranchData::default_count_offset()),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1530
                          scratch1, scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1531
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1532
    // The method data pointer needs to be updated.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1533
    update_mdp_by_offset(in_bytes(MultiBranchData::default_displacement_offset()),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1534
                         scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1535
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1536
    bind (profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1537
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1538
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1539
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1540
// Count the index'th case of a switch construct.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1541
void InterpreterMacroAssembler::profile_switch_case(Register index,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1542
                                                    Register scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1543
                                                    Register scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1544
                                                    Register scratch3) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1545
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1546
    assert_different_registers(index, scratch1, scratch2, scratch3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1547
    Label profile_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1548
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1549
    // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1550
    test_method_data_pointer(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1551
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1552
    // Build the base (index * per_case_size_in_bytes()) + case_array_offset_in_bytes().
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1553
    li(scratch3, in_bytes(MultiBranchData::case_array_offset()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1554
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1555
    assert (in_bytes(MultiBranchData::per_case_size()) == 16, "so that shladd works");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1556
    sldi(scratch1, index, exact_log2(in_bytes(MultiBranchData::per_case_size())));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1557
    add(scratch1, scratch1, scratch3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1558
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1559
    // Update the case count.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1560
    increment_mdp_data_at(scratch1, in_bytes(MultiBranchData::relative_count_offset()), scratch2, scratch3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1561
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1562
    // The method data pointer needs to be updated.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1563
    update_mdp_by_offset(scratch1, in_bytes(MultiBranchData::relative_displacement_offset()), scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1564
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1565
    bind (profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1566
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1567
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1568
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1569
void InterpreterMacroAssembler::profile_null_seen(Register Rscratch1, Register Rscratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1570
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1571
    assert_different_registers(Rscratch1, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1572
    Label profile_continue;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1573
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1574
    // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1575
    test_method_data_pointer(profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1576
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1577
    set_mdp_flag_at(BitData::null_seen_byte_constant(), Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1578
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1579
    // The method data pointer needs to be updated.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1580
    int mdp_delta = in_bytes(BitData::bit_data_size());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1581
    if (TypeProfileCasts) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1582
      mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1583
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1584
    update_mdp_by_constant(mdp_delta);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1585
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1586
    bind (profile_continue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1587
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1588
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1589
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1590
void InterpreterMacroAssembler::record_klass_in_profile(Register Rreceiver,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1591
                                                        Register Rscratch1, Register Rscratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1592
                                                        bool is_virtual_call) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1593
  assert(ProfileInterpreter, "must be profiling");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1594
  assert_different_registers(Rreceiver, Rscratch1, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1595
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1596
  Label done;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1597
  record_klass_in_profile_helper(Rreceiver, Rscratch1, Rscratch2, 0, done, is_virtual_call);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1598
  bind (done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1599
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1600
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1601
void InterpreterMacroAssembler::record_klass_in_profile_helper(
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1602
                                        Register receiver, Register scratch1, Register scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1603
                                        int start_row, Label& done, bool is_virtual_call) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1604
  if (TypeProfileWidth == 0) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1605
    if (is_virtual_call) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1606
      increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch1, scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1607
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1608
    return;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1609
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1610
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1611
  int last_row = VirtualCallData::row_limit() - 1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1612
  assert(start_row <= last_row, "must be work left to do");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1613
  // Test this row for both the receiver and for null.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1614
  // Take any of three different outcomes:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1615
  //   1. found receiver => increment count and goto done
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1616
  //   2. found null => keep looking for case 1, maybe allocate this cell
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1617
  //   3. found something else => keep looking for cases 1 and 2
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1618
  // Case 3 is handled by a recursive call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1619
  for (int row = start_row; row <= last_row; row++) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1620
    Label next_test;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1621
    bool test_for_null_also = (row == start_row);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1622
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1623
    // See if the receiver is receiver[n].
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1624
    int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1625
    test_mdp_data_at(recvr_offset, receiver, next_test, scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1626
    // delayed()->tst(scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1627
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1628
    // The receiver is receiver[n]. Increment count[n].
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1629
    int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1630
    increment_mdp_data_at(count_offset, scratch1, scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1631
    b(done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1632
    bind(next_test);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1633
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1634
    if (test_for_null_also) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1635
      Label found_null;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1636
      // Failed the equality check on receiver[n]... Test for null.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1637
      if (start_row == last_row) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1638
        // The only thing left to do is handle the null case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1639
        if (is_virtual_call) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1640
          // Scratch1 contains test_out from test_mdp_data_at.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1641
          cmpdi(CCR0, scratch1, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1642
          beq(CCR0, found_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1643
          // Receiver did not match any saved receiver and there is no empty row for it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1644
          // Increment total counter to indicate polymorphic case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1645
          increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch1, scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1646
          b(done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1647
          bind(found_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1648
        } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1649
          cmpdi(CCR0, scratch1, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1650
          bne(CCR0, done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1651
        }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1652
        break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1653
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1654
      // Since null is rare, make it be the branch-taken case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1655
      cmpdi(CCR0, scratch1, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1656
      beq(CCR0, found_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1657
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1658
      // Put all the "Case 3" tests here.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1659
      record_klass_in_profile_helper(receiver, scratch1, scratch2, start_row + 1, done, is_virtual_call);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1660
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1661
      // Found a null. Keep searching for a matching receiver,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1662
      // but remember that this is an empty (unused) slot.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1663
      bind(found_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1664
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1665
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1666
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1667
  // In the fall-through case, we found no matching receiver, but we
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1668
  // observed the receiver[start_row] is NULL.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1669
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1670
  // Fill in the receiver field and increment the count.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1671
  int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1672
  set_mdp_data_at(recvr_offset, receiver);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1673
  int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1674
  li(scratch1, DataLayout::counter_increment);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1675
  set_mdp_data_at(count_offset, scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1676
  if (start_row > 0) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1677
    b(done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1678
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1679
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1680
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1681
// Add a InterpMonitorElem to stack (see frame_sparc.hpp).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1682
void InterpreterMacroAssembler::add_monitor_to_stack(bool stack_is_empty, Register Rtemp1, Register Rtemp2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1683
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1684
  // Very-local scratch registers.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1685
  const Register esp  = Rtemp1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1686
  const Register slot = Rtemp2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1687
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1688
  // Extracted monitor_size.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1689
  int monitor_size = frame::interpreter_frame_monitor_size_in_bytes();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1690
  assert(Assembler::is_aligned((unsigned int)monitor_size,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1691
                               (unsigned int)frame::alignment_in_bytes),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1692
         "size of a monitor must respect alignment of SP");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1693
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1694
  resize_frame(-monitor_size, /*temp*/esp); // Allocate space for new monitor
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1695
  std(R1_SP, _ijava_state_neg(top_frame_sp), esp); // esp contains fp
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1696
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1697
  // Shuffle expression stack down. Recall that stack_base points
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1698
  // just above the new expression stack bottom. Old_tos and new_tos
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1699
  // are used to scan thru the old and new expression stacks.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1700
  if (!stack_is_empty) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1701
    Label copy_slot, copy_slot_finished;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1702
    const Register n_slots = slot;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1703
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1704
    addi(esp, R15_esp, Interpreter::stackElementSize); // Point to first element (pre-pushed stack).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1705
    subf(n_slots, esp, R26_monitor);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1706
    srdi_(n_slots, n_slots, LogBytesPerWord);          // Compute number of slots to copy.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1707
    assert(LogBytesPerWord == 3, "conflicts assembler instructions");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1708
    beq(CCR0, copy_slot_finished);                     // Nothing to copy.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1709
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1710
    mtctr(n_slots);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1711
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1712
    // loop
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1713
    bind(copy_slot);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1714
    ld(slot, 0, esp);              // Move expression stack down.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1715
    std(slot, -monitor_size, esp); // distance = monitor_size
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1716
    addi(esp, esp, BytesPerWord);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1717
    bdnz(copy_slot);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1718
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1719
    bind(copy_slot_finished);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1720
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1721
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1722
  addi(R15_esp, R15_esp, -monitor_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1723
  addi(R26_monitor, R26_monitor, -monitor_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1724
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1725
  // Restart interpreter
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1726
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1727
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1728
// ============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1729
// Java locals access
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1730
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1731
// Load a local variable at index in Rindex into register Rdst_value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1732
// Also puts address of local into Rdst_address as a service.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1733
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1734
//   - Rdst_value
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1735
//   - Rdst_address
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1736
void InterpreterMacroAssembler::load_local_int(Register Rdst_value, Register Rdst_address, Register Rindex) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1737
  sldi(Rdst_address, Rindex, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1738
  subf(Rdst_address, Rdst_address, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1739
  lwz(Rdst_value, 0, Rdst_address);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1740
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1741
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1742
// Load a local variable at index in Rindex into register Rdst_value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1743
// Also puts address of local into Rdst_address as a service.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1744
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1745
//   - Rdst_value
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1746
//   - Rdst_address
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1747
void InterpreterMacroAssembler::load_local_long(Register Rdst_value, Register Rdst_address, Register Rindex) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1748
  sldi(Rdst_address, Rindex, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1749
  subf(Rdst_address, Rdst_address, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1750
  ld(Rdst_value, -8, Rdst_address);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1751
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1752
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1753
// Load a local variable at index in Rindex into register Rdst_value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1754
// Also puts address of local into Rdst_address as a service.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1755
// Input:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1756
//   - Rindex:      slot nr of local variable
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1757
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1758
//   - Rdst_value
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1759
//   - Rdst_address
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1760
void InterpreterMacroAssembler::load_local_ptr(Register Rdst_value, Register Rdst_address, Register Rindex) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1761
  sldi(Rdst_address, Rindex, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1762
  subf(Rdst_address, Rdst_address, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1763
  ld(Rdst_value, 0, Rdst_address);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1764
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1765
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1766
// Load a local variable at index in Rindex into register Rdst_value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1767
// Also puts address of local into Rdst_address as a service.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1768
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1769
//   - Rdst_value
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1770
//   - Rdst_address
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1771
void InterpreterMacroAssembler::load_local_float(FloatRegister Rdst_value, Register Rdst_address, Register Rindex) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1772
  sldi(Rdst_address, Rindex, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1773
  subf(Rdst_address, Rdst_address, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1774
  lfs(Rdst_value, 0, Rdst_address);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1775
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1776
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1777
// Load a local variable at index in Rindex into register Rdst_value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1778
// Also puts address of local into Rdst_address as a service.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1779
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1780
//   - Rdst_value
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1781
//   - Rdst_address
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1782
void InterpreterMacroAssembler::load_local_double(FloatRegister Rdst_value, Register Rdst_address, Register Rindex) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1783
  sldi(Rdst_address, Rindex, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1784
  subf(Rdst_address, Rdst_address, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1785
  lfd(Rdst_value, -8, Rdst_address);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1786
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1787
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1788
// Store an int value at local variable slot Rindex.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1789
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1790
//   - Rindex
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1791
void InterpreterMacroAssembler::store_local_int(Register Rvalue, Register Rindex) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1792
  sldi(Rindex, Rindex, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1793
  subf(Rindex, Rindex, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1794
  stw(Rvalue, 0, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1795
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1796
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1797
// Store a long value at local variable slot Rindex.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1798
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1799
//   - Rindex
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1800
void InterpreterMacroAssembler::store_local_long(Register Rvalue, Register Rindex) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1801
  sldi(Rindex, Rindex, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1802
  subf(Rindex, Rindex, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1803
  std(Rvalue, -8, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1804
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1805
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1806
// Store an oop value at local variable slot Rindex.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1807
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1808
//   - Rindex
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1809
void InterpreterMacroAssembler::store_local_ptr(Register Rvalue, Register Rindex) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1810
  sldi(Rindex, Rindex, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1811
  subf(Rindex, Rindex, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1812
  std(Rvalue, 0, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1813
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1814
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1815
// Store an int value at local variable slot Rindex.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1816
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1817
//   - Rindex
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1818
void InterpreterMacroAssembler::store_local_float(FloatRegister Rvalue, Register Rindex) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1819
  sldi(Rindex, Rindex, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1820
  subf(Rindex, Rindex, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1821
  stfs(Rvalue, 0, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1822
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1823
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1824
// Store an int value at local variable slot Rindex.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1825
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1826
//   - Rindex
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1827
void InterpreterMacroAssembler::store_local_double(FloatRegister Rvalue, Register Rindex) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1828
  sldi(Rindex, Rindex, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1829
  subf(Rindex, Rindex, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1830
  stfd(Rvalue, -8, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1831
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1832
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1833
// Read pending exception from thread and jump to interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1834
// Throw exception entry if one if pending. Fall through otherwise.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1835
void InterpreterMacroAssembler::check_and_forward_exception(Register Rscratch1, Register Rscratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1836
  assert_different_registers(Rscratch1, Rscratch2, R3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1837
  Register Rexception = Rscratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1838
  Register Rtmp       = Rscratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1839
  Label Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1840
  // Get pending exception oop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1841
  ld(Rexception, thread_(pending_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1842
  cmpdi(CCR0, Rexception, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1843
  beq(CCR0, Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1844
  li(Rtmp, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1845
  mr_if_needed(R3, Rexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1846
  std(Rtmp, thread_(pending_exception)); // Clear exception in thread
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1847
  if (Interpreter::rethrow_exception_entry() != NULL) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1848
    // Already got entry address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1849
    load_dispatch_table(Rtmp, (address*)Interpreter::rethrow_exception_entry());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1850
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1851
    // Dynamically load entry address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1852
    int simm16_rest = load_const_optimized(Rtmp, &Interpreter::_rethrow_exception_entry, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1853
    ld(Rtmp, simm16_rest, Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1854
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1855
  mtctr(Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1856
  save_interpreter_state(Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1857
  bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1858
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1859
  align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1860
  bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1861
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1862
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1863
void InterpreterMacroAssembler::call_VM(Register oop_result, address entry_point, bool check_exceptions) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1864
  save_interpreter_state(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1865
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1866
  MacroAssembler::call_VM(oop_result, entry_point, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1867
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1868
  restore_interpreter_state(R11_scratch1, /*bcp_and_mdx_only*/ true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1869
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1870
  check_and_handle_popframe(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1871
  check_and_handle_earlyret(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1872
  // Now check exceptions manually.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1873
  if (check_exceptions) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1874
    check_and_forward_exception(R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1875
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1876
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1877
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1878
void InterpreterMacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1879
  // ARG1 is reserved for the thread.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1880
  mr_if_needed(R4_ARG2, arg_1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1881
  call_VM(oop_result, entry_point, check_exceptions);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1882
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1883
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1884
void InterpreterMacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1885
  // ARG1 is reserved for the thread.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1886
  mr_if_needed(R4_ARG2, arg_1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1887
  assert(arg_2 != R4_ARG2, "smashed argument");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1888
  mr_if_needed(R5_ARG3, arg_2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1889
  call_VM(oop_result, entry_point, check_exceptions);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1890
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1891
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1892
void InterpreterMacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1893
  // ARG1 is reserved for the thread.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1894
  mr_if_needed(R4_ARG2, arg_1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1895
  assert(arg_2 != R4_ARG2, "smashed argument");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1896
  mr_if_needed(R5_ARG3, arg_2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1897
  assert(arg_3 != R4_ARG2 && arg_3 != R5_ARG3, "smashed argument");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1898
  mr_if_needed(R6_ARG4, arg_3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1899
  call_VM(oop_result, entry_point, check_exceptions);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1900
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1901
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1902
void InterpreterMacroAssembler::save_interpreter_state(Register scratch) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1903
  ld(scratch, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1904
  std(R15_esp, _ijava_state_neg(esp), scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1905
  std(R14_bcp, _ijava_state_neg(bcp), scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1906
  std(R26_monitor, _ijava_state_neg(monitors), scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1907
  if (ProfileInterpreter) { std(R28_mdx, _ijava_state_neg(mdx), scratch); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1908
  // Other entries should be unchanged.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1909
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1910
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1911
void InterpreterMacroAssembler::restore_interpreter_state(Register scratch, bool bcp_and_mdx_only) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1912
  ld(scratch, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1913
  ld(R14_bcp, _ijava_state_neg(bcp), scratch); // Changed by VM code (exception).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1914
  if (ProfileInterpreter) { ld(R28_mdx, _ijava_state_neg(mdx), scratch); } // Changed by VM code.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1915
  if (!bcp_and_mdx_only) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1916
    // Following ones are Metadata.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1917
    ld(R19_method, _ijava_state_neg(method), scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1918
    ld(R27_constPoolCache, _ijava_state_neg(cpoolCache), scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1919
    // Following ones are stack addresses and don't require reload.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1920
    ld(R15_esp, _ijava_state_neg(esp), scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1921
    ld(R18_locals, _ijava_state_neg(locals), scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1922
    ld(R26_monitor, _ijava_state_neg(monitors), scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1923
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1924
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1925
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1926
    Label Lok;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1927
    subf(R0, R1_SP, scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1928
    cmpdi(CCR0, R0, frame::abi_reg_args_size + frame::ijava_state_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1929
    bge(CCR0, Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1930
    stop("frame too small (restore istate)", 0x5432);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1931
    bind(Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1932
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1933
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1934
    Label Lok;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1935
    ld(R0, _ijava_state_neg(ijava_reserved), scratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1936
    cmpdi(CCR0, R0, 0x5afe);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1937
    beq(CCR0, Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1938
    stop("frame corrupted (restore istate)", 0x5afe);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1939
    bind(Lok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1940
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1941
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1942
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1943
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1944
#endif // !CC_INTERP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  1945
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1946
void InterpreterMacroAssembler::get_method_counters(Register method,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1947
                                                    Register Rcounters,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1948
                                                    Label& skip) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1949
  BLOCK_COMMENT("Load and ev. allocate counter object {");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1950
  Label has_counters;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1951
  ld(Rcounters, in_bytes(Method::method_counters_offset()), method);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1952
  cmpdi(CCR0, Rcounters, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1953
  bne(CCR0, has_counters);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1954
  call_VM(noreg, CAST_FROM_FN_PTR(address,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1955
                                  InterpreterRuntime::build_method_counters), method, false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1956
  ld(Rcounters, in_bytes(Method::method_counters_offset()), method);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1957
  cmpdi(CCR0, Rcounters, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1958
  beq(CCR0, skip); // No MethodCounters, OutOfMemory.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1959
  BLOCK_COMMENT("} Load and ev. allocate counter object");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1960
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1961
  bind(has_counters);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1962
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1963
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1964
void InterpreterMacroAssembler::increment_invocation_counter(Register Rcounters, Register iv_be_count, Register Rtmp_r0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1965
  assert(UseCompiler, "incrementing must be useful");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1966
  Register invocation_count = iv_be_count;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1967
  Register backedge_count   = Rtmp_r0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1968
  int delta = InvocationCounter::count_increment;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1969
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1970
  // Load each counter in a register.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1971
  //  ld(inv_counter, Rtmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1972
  //  ld(be_counter, Rtmp2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1973
  int inv_counter_offset = in_bytes(MethodCounters::invocation_counter_offset() +
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1974
                                    InvocationCounter::counter_offset());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1975
  int be_counter_offset  = in_bytes(MethodCounters::backedge_counter_offset() +
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1976
                                    InvocationCounter::counter_offset());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1977
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1978
  BLOCK_COMMENT("Increment profiling counters {");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1979
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1980
  // Load the backedge counter.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1981
  lwz(backedge_count, be_counter_offset, Rcounters); // is unsigned int
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1982
  // Mask the backedge counter.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1983
  Register tmp = invocation_count;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1984
  li(tmp, InvocationCounter::count_mask_value);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1985
  andr(backedge_count, tmp, backedge_count); // Cannot use andi, need sign extension of count_mask_value.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1986
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1987
  // Load the invocation counter.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1988
  lwz(invocation_count, inv_counter_offset, Rcounters); // is unsigned int
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1989
  // Add the delta to the invocation counter and store the result.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1990
  addi(invocation_count, invocation_count, delta);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1991
  // Store value.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1992
  stw(invocation_count, inv_counter_offset, Rcounters);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1993
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1994
  // Add invocation counter + backedge counter.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1995
  add(iv_be_count, backedge_count, invocation_count);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1996
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1997
  // Note that this macro must leave the backedge_count + invocation_count in
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1998
  // register iv_be_count!
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1999
  BLOCK_COMMENT("} Increment profiling counters");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2000
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2001
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2002
void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2003
  if (state == atos) { MacroAssembler::verify_oop(reg); }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2004
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2005
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2006
#ifndef CC_INTERP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2007
// Local helper function for the verify_oop_or_return_address macro.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2008
static bool verify_return_address(Method* m, int bci) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2009
#ifndef PRODUCT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2010
  address pc = (address)(m->constMethod()) + in_bytes(ConstMethod::codes_offset()) + bci;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2011
  // Assume it is a valid return address if it is inside m and is preceded by a jsr.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2012
  if (!m->contains(pc))                                            return false;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2013
  address jsr_pc;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2014
  jsr_pc = pc - Bytecodes::length_for(Bytecodes::_jsr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2015
  if (*jsr_pc == Bytecodes::_jsr   && jsr_pc >= m->code_base())    return true;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2016
  jsr_pc = pc - Bytecodes::length_for(Bytecodes::_jsr_w);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2017
  if (*jsr_pc == Bytecodes::_jsr_w && jsr_pc >= m->code_base())    return true;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2018
#endif // PRODUCT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2019
  return false;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2020
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2021
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2022
void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2023
  if (VerifyFPU) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2024
    unimplemented("verfiyFPU");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2025
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2026
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2027
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2028
void InterpreterMacroAssembler::verify_oop_or_return_address(Register reg, Register Rtmp) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2029
  if (!VerifyOops) return;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2030
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2031
  // The VM documentation for the astore[_wide] bytecode allows
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2032
  // the TOS to be not only an oop but also a return address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2033
  Label test;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2034
  Label skip;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2035
  // See if it is an address (in the current method):
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2036
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2037
  const int log2_bytecode_size_limit = 16;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2038
  srdi_(Rtmp, reg, log2_bytecode_size_limit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2039
  bne(CCR0, test);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2040
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2041
  address fd = CAST_FROM_FN_PTR(address, verify_return_address);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2042
  unsigned int nbytes_save = 10*8; // 10 volatile gprs
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2043
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2044
  save_LR_CR(Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2045
  push_frame_reg_args(nbytes_save, Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2046
  save_volatile_gprs(R1_SP, 112); // except R0
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2047
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2048
  load_const_optimized(Rtmp, fd, R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2049
  mr_if_needed(R4_ARG2, reg);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2050
  mr(R3_ARG1, R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2051
  call_c(Rtmp); // call C
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2052
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2053
  restore_volatile_gprs(R1_SP, 112); // except R0
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2054
  pop_frame();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2055
  restore_LR_CR(Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2056
  b(skip);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2057
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2058
  // Perform a more elaborate out-of-line call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2059
  // Not an address; verify it:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2060
  bind(test);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2061
  verify_oop(reg);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2062
  bind(skip);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2063
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2064
#endif // !CC_INTERP
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2065
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2066
// Inline assembly for:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2067
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2068
// if (thread is in interp_only_mode) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2069
//   InterpreterRuntime::post_method_entry();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2070
// }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2071
// if (*jvmpi::event_flags_array_at_addr(JVMPI_EVENT_METHOD_ENTRY ) ||
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2072
//     *jvmpi::event_flags_array_at_addr(JVMPI_EVENT_METHOD_ENTRY2)   ) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2073
//   SharedRuntime::jvmpi_method_entry(method, receiver);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2074
// }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2075
void InterpreterMacroAssembler::notify_method_entry() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2076
  // JVMTI
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2077
  // Whenever JVMTI puts a thread in interp_only_mode, method
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2078
  // entry/exit events are sent for that thread to track stack
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2079
  // depth. If it is possible to enter interp_only_mode we add
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2080
  // the code to check if the event should be sent.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2081
  if (JvmtiExport::can_post_interpreter_events()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2082
    Label jvmti_post_done;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2083
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2084
    lwz(R0, in_bytes(JavaThread::interp_only_mode_offset()), R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2085
    cmpwi(CCR0, R0, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2086
    beq(CCR0, jvmti_post_done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2087
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_entry),
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2088
            /*check_exceptions=*/true CC_INTERP_ONLY(&& false));
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2089
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2090
    bind(jvmti_post_done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2091
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2092
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2093
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2094
// Inline assembly for:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2095
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2096
// if (thread is in interp_only_mode) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2097
//   // save result
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2098
//   InterpreterRuntime::post_method_exit();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2099
//   // restore result
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2100
// }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2101
// if (*jvmpi::event_flags_array_at_addr(JVMPI_EVENT_METHOD_EXIT)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2102
//   // save result
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2103
//   SharedRuntime::jvmpi_method_exit();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2104
//   // restore result
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2105
// }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2106
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2107
// Native methods have their result stored in d_tmp and l_tmp.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2108
// Java methods have their result stored in the expression stack.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2109
void InterpreterMacroAssembler::notify_method_exit(bool is_native_method, TosState state,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2110
                                                   NotifyMethodExitMode mode, bool check_exceptions) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2111
  // JVMTI
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2112
  // Whenever JVMTI puts a thread in interp_only_mode, method
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2113
  // entry/exit events are sent for that thread to track stack
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2114
  // depth. If it is possible to enter interp_only_mode we add
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2115
  // the code to check if the event should be sent.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2116
  if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2117
    Label jvmti_post_done;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2118
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2119
    lwz(R0, in_bytes(JavaThread::interp_only_mode_offset()), R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2120
    cmpwi(CCR0, R0, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2121
    beq(CCR0, jvmti_post_done);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2122
    CC_INTERP_ONLY(assert(is_native_method && !check_exceptions, "must not push state"));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2123
    if (!is_native_method) push(state); // Expose tos to GC.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2124
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit),
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2125
            /*check_exceptions=*/check_exceptions);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2126
    if (!is_native_method) pop(state);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2127
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
  2128
    align(32, 12);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2129
    bind(jvmti_post_done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2130
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2131
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2132
  // Dtrace support not implemented.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2133
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2134
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 22861
diff changeset
  2135
#ifdef CC_INTERP
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2136
// Convert the current TOP_IJAVA_FRAME into a PARENT_IJAVA_FRAME
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2137
// (using parent_frame_resize) and push a new interpreter
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2138
// TOP_IJAVA_FRAME (using frame_size).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2139
void InterpreterMacroAssembler::push_interpreter_frame(Register top_frame_size, Register parent_frame_resize,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2140
                                                       Register tmp1, Register tmp2, Register tmp3,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2141
                                                       Register tmp4, Register pc) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2142
  assert_different_registers(top_frame_size, parent_frame_resize, tmp1, tmp2, tmp3, tmp4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2143
  ld(tmp1, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2144
  mr(tmp2/*top_frame_sp*/, R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2145
  // Move initial_caller_sp.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2146
  ld(tmp4, _top_ijava_frame_abi(initial_caller_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2147
  neg(parent_frame_resize, parent_frame_resize);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2148
  resize_frame(parent_frame_resize/*-parent_frame_resize*/, tmp3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2149
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2150
  // Set LR in new parent frame.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2151
  std(tmp1, _abi(lr), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2152
  // Set top_frame_sp info for new parent frame.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2153
  std(tmp2, _parent_ijava_frame_abi(top_frame_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2154
  std(tmp4, _parent_ijava_frame_abi(initial_caller_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2155
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2156
  // Push new TOP_IJAVA_FRAME.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2157
  push_frame(top_frame_size, tmp2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2158
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2159
  get_PC_trash_LR(tmp3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2160
  std(tmp3, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2161
  // Used for non-initial callers by unextended_sp().
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2162
  std(R1_SP, _top_ijava_frame_abi(initial_caller_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2163
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2164
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2165
// Pop the topmost TOP_IJAVA_FRAME and convert the previous
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2166
// PARENT_IJAVA_FRAME back into a TOP_IJAVA_FRAME.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2167
void InterpreterMacroAssembler::pop_interpreter_frame(Register tmp1, Register tmp2, Register tmp3, Register tmp4) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2168
  assert_different_registers(tmp1, tmp2, tmp3, tmp4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2169
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2170
  ld(tmp1/*caller's sp*/, _abi(callers_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2171
  ld(tmp3, _abi(lr), tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2172
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2173
  ld(tmp4, _parent_ijava_frame_abi(initial_caller_sp), tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2174
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2175
  ld(tmp2/*caller's caller's sp*/, _abi(callers_sp), tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2176
  // Merge top frame.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2177
  std(tmp2, _abi(callers_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2178
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2179
  ld(tmp2, _parent_ijava_frame_abi(top_frame_sp), tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2180
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2181
  // Update C stack pointer to caller's top_abi.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2182
  resize_frame_absolute(tmp2/*addr*/, tmp1/*tmp*/, tmp2/*tmp*/);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2183
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2184
  // Update LR in top_frame.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2185
  std(tmp3, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2186
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2187
  std(tmp4, _top_ijava_frame_abi(initial_caller_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2188
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2189
  // Store the top-frame stack-pointer for c2i adapters.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2190
  std(R1_SP, _top_ijava_frame_abi(top_frame_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2191
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2192
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2193
// Turn state's interpreter frame into the current TOP_IJAVA_FRAME.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2194
void InterpreterMacroAssembler::pop_interpreter_frame_to_state(Register state, Register tmp1, Register tmp2, Register tmp3) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2195
  assert_different_registers(R14_state, R15_prev_state, tmp1, tmp2, tmp3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2196
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2197
  if (state == R14_state) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2198
    ld(tmp1/*state's fp*/, state_(_last_Java_fp));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2199
    ld(tmp2/*state's sp*/, state_(_last_Java_sp));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2200
  } else if (state == R15_prev_state) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2201
    ld(tmp1/*state's fp*/, prev_state_(_last_Java_fp));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2202
    ld(tmp2/*state's sp*/, prev_state_(_last_Java_sp));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2203
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2204
    ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2205
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2206
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2207
  // Merge top frames.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2208
  std(tmp1, _abi(callers_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2209
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2210
  // Tmp2 is new SP.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2211
  // Tmp1 is parent's SP.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2212
  resize_frame_absolute(tmp2/*addr*/, tmp1/*tmp*/, tmp2/*tmp*/);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2213
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2214
  // Update LR in top_frame.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2215
  // Must be interpreter frame.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2216
  get_PC_trash_LR(tmp3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2217
  std(tmp3, _top_ijava_frame_abi(frame_manager_lr), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2218
  // Used for non-initial callers by unextended_sp().
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2219
  std(R1_SP, _top_ijava_frame_abi(initial_caller_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2220
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2221
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2222
// Set SP to initial caller's sp, but before fix the back chain.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2223
void InterpreterMacroAssembler::resize_frame_to_initial_caller(Register tmp1, Register tmp2) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2224
  ld(tmp1, _parent_ijava_frame_abi(initial_caller_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2225
  ld(tmp2, _parent_ijava_frame_abi(callers_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2226
  std(tmp2, _parent_ijava_frame_abi(callers_sp), tmp1); // Fix back chain ...
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2227
  mr(R1_SP, tmp1); // ... and resize to initial caller.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2228
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2229
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2230
// Pop the current interpreter state (without popping the correspoding
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2231
// frame) and restore R14_state and R15_prev_state accordingly.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2232
// Use prev_state_may_be_0 to indicate whether prev_state may be 0
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2233
// in order to generate an extra check before retrieving prev_state_(_prev_link).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2234
void InterpreterMacroAssembler::pop_interpreter_state(bool prev_state_may_be_0)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2235
{
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2236
  // Move prev_state to state and restore prev_state from state_(_prev_link).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2237
  Label prev_state_is_0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2238
  mr(R14_state, R15_prev_state);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2239
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2240
  // Don't retrieve /*state==*/prev_state_(_prev_link)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2241
  // if /*state==*/prev_state is 0.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2242
  if (prev_state_may_be_0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2243
    cmpdi(CCR0, R15_prev_state, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2244
    beq(CCR0, prev_state_is_0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2245
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2246
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2247
  ld(R15_prev_state, /*state==*/prev_state_(_prev_link));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2248
  bind(prev_state_is_0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2249
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2250
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2251
void InterpreterMacroAssembler::restore_prev_state() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2252
  // _prev_link is private, but cInterpreter is a friend.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2253
  ld(R15_prev_state, state_(_prev_link));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2254
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2255
#endif // CC_INTERP