hotspot/src/cpu/s390/vm/interp_masm_s390.cpp
author coleenp
Thu, 01 Dec 2016 14:21:31 -0500
changeset 44738 11431bbc9549
parent 43420 a056d6465ef9
child 46427 54713555867e
permissions -rw-r--r--
8168699: Validate special case invocations Reviewed-by: acorn, kvn, lfoltan, ctornqvi, ahgross, vlivanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     3
 * Copyright (c) 2016 SAP SE. All rights reserved.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     5
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     9
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    14
 * accompanied this code).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    15
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    19
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    22
 * questions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    23
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    24
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    25
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    26
// Major contributions by AHa, AS, JL, ML.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    27
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
#include "precompiled.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
#include "asm/macroAssembler.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    30
#include "interp_masm_s390.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    31
#include "interpreter/interpreter.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
#include "interpreter/interpreterRuntime.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
#include "oops/arrayOop.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
#include "oops/markOop.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
#include "prims/jvmtiExport.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
#include "prims/jvmtiThreadState.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
#include "runtime/basicLock.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
#include "runtime/biasedLocking.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
#include "runtime/sharedRuntime.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
#include "runtime/thread.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
// Implementation of InterpreterMacroAssembler.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
// This file specializes the assember with interpreter-specific macros.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
#ifdef PRODUCT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
#define BLOCK_COMMENT(str)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    47
#define BIND(label)        bind(label);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
#else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
#define BLOCK_COMMENT(str) block_comment(str)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
#define BIND(label)        bind(label); BLOCK_COMMENT(#label ":")
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
void InterpreterMacroAssembler::jump_to_entry(address entry, Register Rscratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
  assert(entry != NULL, "Entry must have been generated by now");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
  assert(Rscratch != Z_R0, "Can't use R0 for addressing");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
  branch_optimized(Assembler::bcondAlways, entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    57
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
void InterpreterMacroAssembler::empty_expression_stack(void) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
  get_monitors(Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
  add2reg(Z_esp, -Interpreter::stackElementSize, Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
// Dispatch code executed in the prolog of a bytecode which does not do it's
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
// own dispatch.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
void InterpreterMacroAssembler::dispatch_prolog(TosState state, int bcp_incr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
  // On z/Architecture we are short on registers, therefore we do not preload the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
  // dispatch address of the next bytecode.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
// Dispatch code executed in the epilog of a bytecode which does not do it's
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
// own dispatch.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
void InterpreterMacroAssembler::dispatch_epilog(TosState state, int step) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
  dispatch_next(state, step);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
void InterpreterMacroAssembler::dispatch_next(TosState state, int bcp_incr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
  z_llgc(Z_bytecode, bcp_incr, Z_R0, Z_bcp);  // Load next bytecode.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
  add2reg(Z_bcp, bcp_incr);                   // Advance bcp. Add2reg produces optimal code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    80
  dispatch_base(state, Interpreter::dispatch_table(state));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    81
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
// Common code to dispatch and dispatch_only.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
// Dispatch value in Lbyte_code and increment Lbcp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
void InterpreterMacroAssembler::dispatch_base(TosState state, address* table) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
  verify_FPU(1, state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
  address reentry = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    91
  { Label OK;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    92
    // Check if the frame pointer in Z_fp is correct.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    93
    z_cg(Z_fp, 0, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    94
    z_bre(OK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
    reentry = stop_chain_static(reentry, "invalid frame pointer Z_fp: " FILE_AND_LINE);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
    bind(OK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
  { Label OK;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    99
    // check if the locals pointer in Z_locals is correct
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   100
    z_cg(Z_locals, _z_ijava_state_neg(locals), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   101
    z_bre(OK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
    reentry = stop_chain_static(reentry, "invalid locals pointer Z_locals: " FILE_AND_LINE);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
    bind(OK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   105
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   106
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
  // TODO: Maybe implement +VerifyActivationFrameSize here.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
  // verify_thread(); // Too slow. We will just verify on method entry & exit.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
  verify_oop(Z_tos, state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   110
#ifdef FAST_DISPATCH
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
  if (table == Interpreter::dispatch_table(state)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
    // Use IdispatchTables.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
    add(Lbyte_code, Interpreter::distance_from_dispatch_table(state), Lbyte_code);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
                                                        // Add offset to correct dispatch table.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
    sll(Lbyte_code, LogBytesPerWord, Lbyte_code);       // Multiply by wordSize.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
    ld_ptr(IdispatchTables, Lbyte_code, G3_scratch);    // Get entry addr.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
  } else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
    // Dispatch table to use.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
    load_absolute_address(Z_tmp_1, (address) table);  // Z_tmp_1 = table;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
    // 0 <= Z_bytecode < 256 => Use a 32 bit shift, because it is shorter than sllg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
    // Z_bytecode must have been loaded zero-extended for this approach to be correct.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   125
    z_sll(Z_bytecode, LogBytesPerWord, Z_R0);   // Multiply by wordSize.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
    z_lg(Z_tmp_1, 0, Z_bytecode, Z_tmp_1);      // Get entry addr.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
  z_br(Z_tmp_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
void InterpreterMacroAssembler::dispatch_only(TosState state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
  dispatch_base(state, Interpreter::dispatch_table(state));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   133
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   135
void InterpreterMacroAssembler::dispatch_only_normal(TosState state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
  dispatch_base(state, Interpreter::normal_table(state));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
void InterpreterMacroAssembler::dispatch_via(TosState state, address *table) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
  // Load current bytecode.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
  z_llgc(Z_bytecode, Address(Z_bcp, (intptr_t)0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   142
  dispatch_base(state, table);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   143
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   144
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   145
// The following call_VM*_base() methods overload and mask the respective
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   146
// declarations/definitions in class MacroAssembler. They are meant as a "detour"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   147
// to perform additional, template interpreter specific tasks before actually
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   148
// calling their MacroAssembler counterparts.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   149
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   150
void InterpreterMacroAssembler::call_VM_leaf_base(address entry_point) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   151
  bool allow_relocation = true; // Fenerally valid variant. Assume code is relocated.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   152
  // interpreter specific
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   153
  // Note: No need to save/restore bcp (Z_R13) pointer since these are callee
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   154
  // saved registers and no blocking/ GC can happen in leaf calls.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   155
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   156
  // super call
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   157
  MacroAssembler::call_VM_leaf_base(entry_point, allow_relocation);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   158
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   159
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   160
void InterpreterMacroAssembler::call_VM_leaf_base(address entry_point, bool allow_relocation) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   161
  // interpreter specific
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   162
  // Note: No need to save/restore bcp (Z_R13) pointer since these are callee
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   163
  // saved registers and no blocking/ GC can happen in leaf calls.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   164
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   165
  // super call
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   166
  MacroAssembler::call_VM_leaf_base(entry_point, allow_relocation);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   167
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   168
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   169
void InterpreterMacroAssembler::call_VM_base(Register oop_result, Register last_java_sp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   170
                                             address entry_point, bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   171
  bool allow_relocation = true; // Fenerally valid variant. Assume code is relocated.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   172
  // interpreter specific
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   173
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   174
  save_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   175
  save_esp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   176
  // super call
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   177
  MacroAssembler::call_VM_base(oop_result, last_java_sp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   178
                               entry_point, allow_relocation, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   179
  restore_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   180
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   181
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   182
void InterpreterMacroAssembler::call_VM_base(Register oop_result, Register last_java_sp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   183
                                             address entry_point, bool allow_relocation,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   184
                                             bool check_exceptions) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   185
  // interpreter specific
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   186
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   187
  save_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   188
  save_esp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   189
  // super call
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   190
  MacroAssembler::call_VM_base(oop_result, last_java_sp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   191
                               entry_point, allow_relocation, check_exceptions);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   192
  restore_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   193
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   194
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   195
void InterpreterMacroAssembler::check_and_handle_popframe(Register scratch_reg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   196
  if (JvmtiExport::can_pop_frame()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   197
    BLOCK_COMMENT("check_and_handle_popframe {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   198
    Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   199
    // Initiate popframe handling only if it is not already being
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   200
    // processed. If the flag has the popframe_processing bit set, it
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   201
    // means that this code is called *during* popframe handling - we
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   202
    // don't want to reenter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   203
    // TODO: Check if all four state combinations could be visible.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   204
    // If (processing and !pending) is an invisible/impossible state,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   205
    // there is optimization potential by testing both bits at once.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   206
    // Then, All_Zeroes and All_Ones means skip, Mixed means doit.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   207
    testbit(Address(Z_thread, JavaThread::popframe_condition_offset()),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   208
            exact_log2(JavaThread::popframe_pending_bit));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   209
    z_bfalse(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   210
    testbit(Address(Z_thread, JavaThread::popframe_condition_offset()),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   211
            exact_log2(JavaThread::popframe_processing_bit));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   212
    z_btrue(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   213
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   214
    // Call Interpreter::remove_activation_preserving_args_entry() to get the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   215
    // address of the same-named entrypoint in the generated interpreter code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   216
    call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   217
    // The above call should (as its only effect) return the contents of the field
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   218
    // _remove_activation_preserving_args_entry in Z_RET.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   219
    // We just jump there to have the work done.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   220
    z_br(Z_RET);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   221
    // There is no way for control to fall thru here.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   222
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   223
    bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   224
    BLOCK_COMMENT("} check_and_handle_popframe");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   225
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   226
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   227
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   228
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   229
void InterpreterMacroAssembler::load_earlyret_value(TosState state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   230
  Register RjvmtiState = Z_R1_scratch;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   231
  int      tos_off     = in_bytes(JvmtiThreadState::earlyret_tos_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   232
  int      oop_off     = in_bytes(JvmtiThreadState::earlyret_oop_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   233
  int      val_off     = in_bytes(JvmtiThreadState::earlyret_value_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   234
  int      state_off   = in_bytes(JavaThread::jvmti_thread_state_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   235
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   236
  z_lg(RjvmtiState, state_off, Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   237
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   238
  switch (state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   239
    case atos: z_lg(Z_tos, oop_off, RjvmtiState);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   240
      store_const(Address(RjvmtiState, oop_off), 0L, 8, 8, Z_R0_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   241
                                                    break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   242
    case ltos: z_lg(Z_tos, val_off, RjvmtiState);   break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   243
    case btos: // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   244
    case ztos: // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   245
    case ctos: // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   246
    case stos: // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   247
    case itos: z_llgf(Z_tos, val_off, RjvmtiState); break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   248
    case ftos: z_le(Z_ftos, val_off, RjvmtiState);  break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   249
    case dtos: z_ld(Z_ftos, val_off, RjvmtiState);  break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   250
    case vtos:   /* nothing to do */                break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   251
    default  : ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   252
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   253
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   254
  // Clean up tos value in the jvmti thread state.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   255
  store_const(Address(RjvmtiState, val_off),   0L, 8, 8, Z_R0_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   256
  // Set tos state field to illegal value.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   257
  store_const(Address(RjvmtiState, tos_off), ilgl, 4, 1, Z_R0_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   258
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   259
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   260
void InterpreterMacroAssembler::check_and_handle_earlyret(Register scratch_reg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   261
  if (JvmtiExport::can_force_early_return()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   262
    BLOCK_COMMENT("check_and_handle_earlyret {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   263
    Label L;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   264
    // arg regs are save, because we are just behind the call in call_VM_base
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   265
    Register jvmti_thread_state = Z_ARG2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   266
    Register tmp                = Z_ARG3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   267
    load_and_test_long(jvmti_thread_state, Address(Z_thread, JavaThread::jvmti_thread_state_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   268
    z_bre(L); // if (thread->jvmti_thread_state() == NULL) exit;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   269
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   270
    // Initiate earlyret handling only if it is not already being processed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   271
    // If the flag has the earlyret_processing bit set, it means that this code
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   272
    // is called *during* earlyret handling - we don't want to reenter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   273
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   274
    assert((JvmtiThreadState::earlyret_pending != 0) && (JvmtiThreadState::earlyret_inactive == 0),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   275
          "must fix this check, when changing the values of the earlyret enum");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   276
    assert(JvmtiThreadState::earlyret_pending == 1, "must fix this check, when changing the values of the earlyret enum");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   277
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   278
    load_and_test_int(tmp, Address(jvmti_thread_state, JvmtiThreadState::earlyret_state_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   279
    z_brz(L); // if (thread->jvmti_thread_state()->_earlyret_state != JvmtiThreadState::earlyret_pending) exit;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   280
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   281
    // Call Interpreter::remove_activation_early_entry() to get the address of the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   282
    // same-named entrypoint in the generated interpreter code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   283
    assert(sizeof(TosState) == 4, "unexpected size");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   284
    z_l(Z_ARG1, Address(jvmti_thread_state, JvmtiThreadState::earlyret_tos_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   285
    call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry), Z_ARG1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   286
    // The above call should (as its only effect) return the contents of the field
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   287
    // _remove_activation_preserving_args_entry in Z_RET.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   288
    // We just jump there to have the work done.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   289
    z_br(Z_RET);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   290
    // There is no way for control to fall thru here.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   291
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   292
    bind(L);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   293
    BLOCK_COMMENT("} check_and_handle_earlyret");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   294
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   295
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   296
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   297
void InterpreterMacroAssembler::super_call_VM_leaf(address entry_point, Register arg_1, Register arg_2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   298
  lgr_if_needed(Z_ARG1, arg_1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   299
  assert(arg_2 != Z_ARG1, "smashed argument");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   300
  lgr_if_needed(Z_ARG2, arg_2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   301
  MacroAssembler::call_VM_leaf_base(entry_point, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   302
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   303
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   304
void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index, int bcp_offset, size_t index_size) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   305
  Address param(Z_bcp, bcp_offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   306
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   307
  BLOCK_COMMENT("get_cache_index_at_bcp {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   308
  assert(bcp_offset > 0, "bcp is still pointing to start of bytecode");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   309
  if (index_size == sizeof(u2)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   310
    load_sized_value(index, param, 2, false /*signed*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   311
  } else if (index_size == sizeof(u4)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   312
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   313
    load_sized_value(index, param, 4, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   314
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   315
    // Check if the secondary index definition is still ~x, otherwise
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   316
    // we have to change the following assembler code to calculate the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   317
    // plain index.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   318
    assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   319
    not_(index);  // Convert to plain index.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   320
  } else if (index_size == sizeof(u1)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   321
    z_llgc(index, param);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   322
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   323
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   324
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   325
  BLOCK_COMMENT("}");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   326
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   327
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   328
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   329
void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, Register cpe_offset,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   330
                                                           int bcp_offset, size_t index_size) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   331
  BLOCK_COMMENT("get_cache_and_index_at_bcp {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   332
  assert_different_registers(cache, cpe_offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   333
  get_cache_index_at_bcp(cpe_offset, bcp_offset, index_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   334
  z_lg(cache, Address(Z_fp, _z_ijava_state_neg(cpoolCache)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   335
  // Convert from field index to ConstantPoolCache offset in bytes.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   336
  z_sllg(cpe_offset, cpe_offset, exact_log2(in_words(ConstantPoolCacheEntry::size()) * BytesPerWord));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   337
  BLOCK_COMMENT("}");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   338
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   339
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   340
// Kills Z_R0_scratch.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   341
void InterpreterMacroAssembler::get_cache_and_index_and_bytecode_at_bcp(Register cache,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   342
                                                                        Register cpe_offset,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   343
                                                                        Register bytecode,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   344
                                                                        int byte_no,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   345
                                                                        int bcp_offset,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   346
                                                                        size_t index_size) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   347
  BLOCK_COMMENT("get_cache_and_index_and_bytecode_at_bcp {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   348
  get_cache_and_index_at_bcp(cache, cpe_offset, bcp_offset, index_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   349
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   350
  // We want to load (from CP cache) the bytecode that corresponds to the passed-in byte_no.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   351
  // It is located at (cache + cpe_offset + base_offset + indices_offset + (8-1) (last byte in DW) - (byte_no+1).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   352
  // Instead of loading, shifting and masking a DW, we just load that one byte of interest with z_llgc (unsigned).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   353
  const int base_ix_off = in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   354
  const int off_in_DW   = (8-1) - (1+byte_no);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   355
  assert(ConstantPoolCacheEntry::bytecode_1_mask == ConstantPoolCacheEntry::bytecode_2_mask, "common mask");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   356
  assert(ConstantPoolCacheEntry::bytecode_1_mask == 0xff, "");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   357
  load_sized_value(bytecode, Address(cache, cpe_offset, base_ix_off+off_in_DW), 1, false /*signed*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   358
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   359
  BLOCK_COMMENT("}");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   360
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   361
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   362
// Load object from cpool->resolved_references(index).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   363
void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   364
  assert_different_registers(result, index);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   365
  get_constant_pool(result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   366
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   367
  // Convert
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   368
  //  - from field index to resolved_references() index and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   369
  //  - from word index to byte offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   370
  // Since this is a java object, it is potentially compressed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   371
  Register tmp = index;  // reuse
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   372
  z_sllg(index, index, LogBytesPerHeapOop); // Offset into resolved references array.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   373
  // Load pointer for resolved_references[] objArray.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   374
  z_lg(result, ConstantPool::resolved_references_offset_in_bytes(), result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   375
  // JNIHandles::resolve(result)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   376
  z_lg(result, 0, result); // Load resolved references array itself.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   377
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   378
  NearLabel index_ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   379
  z_lgf(Z_R0, Address(result, arrayOopDesc::length_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   380
  z_sllg(Z_R0, Z_R0, LogBytesPerHeapOop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   381
  compare64_and_branch(tmp, Z_R0, Assembler::bcondLow, index_ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   382
  stop("resolved reference index out of bounds", 0x09256);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   383
  bind(index_ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   384
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   385
  z_agr(result, index);    // Address of indexed array element.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   386
  load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   387
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   388
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   389
void InterpreterMacroAssembler::get_cache_entry_pointer_at_bcp(Register cache,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   390
                                                               Register tmp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   391
                                                               int bcp_offset,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   392
                                                               size_t index_size) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   393
  BLOCK_COMMENT("get_cache_entry_pointer_at_bcp {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   394
    get_cache_and_index_at_bcp(cache, tmp, bcp_offset, index_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   395
    add2reg_with_index(cache, in_bytes(ConstantPoolCache::base_offset()), tmp, cache);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   396
  BLOCK_COMMENT("}");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   397
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   398
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   399
// Generate a subtype check: branch to ok_is_subtype if sub_klass is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   400
// a subtype of super_klass. Blows registers Rsuper_klass, Rsub_klass, tmp1, tmp2.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   401
void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   402
                                                  Register Rsuper_klass,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   403
                                                  Register Rtmp1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   404
                                                  Register Rtmp2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   405
                                                  Label &ok_is_subtype) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   406
  // Profile the not-null value's klass.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   407
  profile_typecheck(Rtmp1, Rsub_klass, Rtmp2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   408
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   409
  // Do the check.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   410
  check_klass_subtype(Rsub_klass, Rsuper_klass, Rtmp1, Rtmp2, ok_is_subtype);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   411
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   412
  // Profile the failure of the check.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   413
  profile_typecheck_failed(Rtmp1, Rtmp2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   414
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   415
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   416
// Pop topmost element from stack. It just disappears.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   417
// Useful if consumed previously by access via stackTop().
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   418
void InterpreterMacroAssembler::popx(int len) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   419
  add2reg(Z_esp, len*Interpreter::stackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   420
  debug_only(verify_esp(Z_esp, Z_R1_scratch));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   421
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   422
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   423
// Get Address object of stack top. No checks. No pop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   424
// Purpose: - Provide address of stack operand to exploit reg-mem operations.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   425
//          - Avoid RISC-like mem2reg - reg-reg-op sequence.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   426
Address InterpreterMacroAssembler::stackTop() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   427
  return Address(Z_esp, Interpreter::expr_offset_in_bytes(0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   428
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   429
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   430
void InterpreterMacroAssembler::pop_i(Register r) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   431
  z_l(r, Interpreter::expr_offset_in_bytes(0), Z_esp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   432
  add2reg(Z_esp, Interpreter::stackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   433
  assert_different_registers(r, Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   434
  debug_only(verify_esp(Z_esp, Z_R1_scratch));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   435
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   436
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   437
void InterpreterMacroAssembler::pop_ptr(Register r) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   438
  z_lg(r, Interpreter::expr_offset_in_bytes(0), Z_esp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   439
  add2reg(Z_esp, Interpreter::stackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   440
  assert_different_registers(r, Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   441
  debug_only(verify_esp(Z_esp, Z_R1_scratch));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   442
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   443
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   444
void InterpreterMacroAssembler::pop_l(Register r) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   445
  z_lg(r, Interpreter::expr_offset_in_bytes(0), Z_esp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   446
  add2reg(Z_esp, 2*Interpreter::stackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   447
  assert_different_registers(r, Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   448
  debug_only(verify_esp(Z_esp, Z_R1_scratch));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   449
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   450
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   451
void InterpreterMacroAssembler::pop_f(FloatRegister f) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   452
  mem2freg_opt(f, Address(Z_esp, Interpreter::expr_offset_in_bytes(0)), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   453
  add2reg(Z_esp, Interpreter::stackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   454
  debug_only(verify_esp(Z_esp, Z_R1_scratch));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   455
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   456
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   457
void InterpreterMacroAssembler::pop_d(FloatRegister f) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   458
  mem2freg_opt(f, Address(Z_esp, Interpreter::expr_offset_in_bytes(0)), true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   459
  add2reg(Z_esp, 2*Interpreter::stackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   460
  debug_only(verify_esp(Z_esp, Z_R1_scratch));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   461
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   462
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   463
void InterpreterMacroAssembler::push_i(Register r) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   464
  assert_different_registers(r, Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   465
  debug_only(verify_esp(Z_esp, Z_R1_scratch));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   466
  z_st(r, Address(Z_esp));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   467
  add2reg(Z_esp, -Interpreter::stackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   468
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   469
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   470
void InterpreterMacroAssembler::push_ptr(Register r) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   471
  z_stg(r, Address(Z_esp));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   472
  add2reg(Z_esp, -Interpreter::stackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   473
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   474
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   475
void InterpreterMacroAssembler::push_l(Register r) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   476
  assert_different_registers(r, Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   477
  debug_only(verify_esp(Z_esp, Z_R1_scratch));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   478
  int offset = -Interpreter::stackElementSize;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   479
  z_stg(r, Address(Z_esp, offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   480
  clear_mem(Address(Z_esp), Interpreter::stackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   481
  add2reg(Z_esp, 2 * offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   482
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   483
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   484
void InterpreterMacroAssembler::push_f(FloatRegister f) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   485
  debug_only(verify_esp(Z_esp, Z_R1_scratch));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   486
  freg2mem_opt(f, Address(Z_esp), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   487
  add2reg(Z_esp, -Interpreter::stackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   488
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   489
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   490
void InterpreterMacroAssembler::push_d(FloatRegister d) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   491
  debug_only(verify_esp(Z_esp, Z_R1_scratch));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   492
  int offset = -Interpreter::stackElementSize;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   493
  freg2mem_opt(d, Address(Z_esp, offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   494
  add2reg(Z_esp, 2 * offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   495
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   496
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   497
void InterpreterMacroAssembler::push(TosState state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   498
  verify_oop(Z_tos, state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   499
  switch (state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   500
    case atos: push_ptr();           break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   501
    case btos: push_i();             break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   502
    case ztos:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   503
    case ctos:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   504
    case stos: push_i();             break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   505
    case itos: push_i();             break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   506
    case ltos: push_l();             break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   507
    case ftos: push_f();             break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   508
    case dtos: push_d();             break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   509
    case vtos: /* nothing to do */   break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   510
    default  : ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   511
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   512
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   513
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   514
void InterpreterMacroAssembler::pop(TosState state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   515
  switch (state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   516
    case atos: pop_ptr(Z_tos);       break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   517
    case btos: pop_i(Z_tos);         break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   518
    case ztos:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   519
    case ctos:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   520
    case stos: pop_i(Z_tos);         break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   521
    case itos: pop_i(Z_tos);         break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   522
    case ltos: pop_l(Z_tos);         break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   523
    case ftos: pop_f(Z_ftos);        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   524
    case dtos: pop_d(Z_ftos);        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   525
    case vtos: /* nothing to do */   break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   526
    default  : ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   527
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   528
  verify_oop(Z_tos, state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   529
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   530
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   531
// Helpers for swap and dup.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   532
void InterpreterMacroAssembler::load_ptr(int n, Register val) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   533
  z_lg(val, Address(Z_esp, Interpreter::expr_offset_in_bytes(n)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   534
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   535
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   536
void InterpreterMacroAssembler::store_ptr(int n, Register val) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   537
  z_stg(val, Address(Z_esp, Interpreter::expr_offset_in_bytes(n)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   538
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   539
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   540
void InterpreterMacroAssembler::prepare_to_jump_from_interpreted(Register method) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   541
  // Satisfy interpreter calling convention (see generate_normal_entry()).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   542
  z_lgr(Z_R10, Z_SP); // Set sender sp (aka initial caller sp, aka unextended sp).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   543
  // Record top_frame_sp, because the callee might modify it, if it's compiled.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   544
  z_stg(Z_SP, _z_ijava_state_neg(top_frame_sp), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   545
  save_bcp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   546
  save_esp();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   547
  z_lgr(Z_method, method); // Set Z_method (kills Z_fp!).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   548
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   549
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   550
// Jump to from_interpreted entry of a call unless single stepping is possible
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   551
// in this thread in which case we must call the i2i entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   552
void InterpreterMacroAssembler::jump_from_interpreted(Register method, Register temp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   553
  assert_different_registers(method, Z_R10 /*used for initial_caller_sp*/, temp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   554
  prepare_to_jump_from_interpreted(method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   555
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   556
  if (JvmtiExport::can_post_interpreter_events()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   557
    // JVMTI events, such as single-stepping, are implemented partly by avoiding running
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   558
    // compiled code in threads for which the event is enabled. Check here for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   559
    // interp_only_mode if these events CAN be enabled.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   560
    z_lg(Z_R1_scratch, Address(method, Method::from_interpreted_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   561
    MacroAssembler::load_and_test_int(Z_R0_scratch, Address(Z_thread, JavaThread::interp_only_mode_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   562
    z_bcr(bcondEqual, Z_R1_scratch); // Run compiled code if zero.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   563
    // Run interpreted.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   564
    z_lg(Z_R1_scratch, Address(method, Method::interpreter_entry_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   565
    z_br(Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   566
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   567
    // Run compiled code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   568
    z_lg(Z_R1_scratch, Address(method, Method::from_interpreted_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   569
    z_br(Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   570
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   571
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   572
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   573
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   574
void InterpreterMacroAssembler::verify_esp(Register Resp, Register Rtemp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   575
  // About to read or write Resp[0].
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   576
  // Make sure it is not in the monitors or the TOP_IJAVA_FRAME_ABI.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   577
  address reentry = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   578
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   579
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   580
    // Check if the frame pointer in Z_fp is correct.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   581
    NearLabel OK;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   582
    z_cg(Z_fp, 0, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   583
    z_bre(OK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   584
    reentry = stop_chain_static(reentry, "invalid frame pointer Z_fp");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   585
    bind(OK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   586
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   587
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   588
    // Resp must not point into or below the operand stack,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   589
    // i.e. IJAVA_STATE.monitors > Resp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   590
    NearLabel OK;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   591
    Register Rmonitors = Rtemp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   592
    z_lg(Rmonitors, _z_ijava_state_neg(monitors), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   593
    compareU64_and_branch(Rmonitors, Resp, bcondHigh, OK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   594
    reentry = stop_chain_static(reentry, "too many pops: Z_esp points into monitor area");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   595
    bind(OK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   596
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   597
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   598
    // Resp may point to the last word of TOP_IJAVA_FRAME_ABI, but not below
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   599
    // i.e. !(Z_SP + frame::z_top_ijava_frame_abi_size - Interpreter::stackElementSize > Resp).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   600
    NearLabel OK;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   601
    Register Rabi_bottom = Rtemp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   602
    add2reg(Rabi_bottom, frame::z_top_ijava_frame_abi_size - Interpreter::stackElementSize, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   603
    compareU64_and_branch(Rabi_bottom, Resp, bcondNotHigh, OK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   604
    reentry = stop_chain_static(reentry, "too many pushes: Z_esp points into TOP_IJAVA_FRAME_ABI");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   605
    bind(OK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   606
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   607
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   608
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   609
void InterpreterMacroAssembler::asm_assert_ijava_state_magic(Register tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   610
  Label magic_ok;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   611
  load_const_optimized(tmp, frame::z_istate_magic_number);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   612
  z_cg(tmp, Address(Z_fp, _z_ijava_state_neg(magic)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   613
  z_bre(magic_ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   614
  stop_static("error: wrong magic number in ijava_state access");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   615
  bind(magic_ok);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   616
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   617
#endif // ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   618
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   619
void InterpreterMacroAssembler::save_bcp() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   620
  z_stg(Z_bcp, Address(Z_fp, _z_ijava_state_neg(bcp)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   621
  asm_assert_ijava_state_magic(Z_bcp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   622
  NOT_PRODUCT(z_lg(Z_bcp, Address(Z_fp, _z_ijava_state_neg(bcp))));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   623
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   624
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   625
void InterpreterMacroAssembler::restore_bcp() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   626
  asm_assert_ijava_state_magic(Z_bcp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   627
  z_lg(Z_bcp, Address(Z_fp, _z_ijava_state_neg(bcp)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   628
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   629
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   630
void InterpreterMacroAssembler::save_esp() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   631
  z_stg(Z_esp, Address(Z_fp, _z_ijava_state_neg(esp)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   632
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   633
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   634
void InterpreterMacroAssembler::restore_esp() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   635
  asm_assert_ijava_state_magic(Z_esp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   636
  z_lg(Z_esp, Address(Z_fp, _z_ijava_state_neg(esp)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   637
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   638
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   639
void InterpreterMacroAssembler::get_monitors(Register reg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   640
  asm_assert_ijava_state_magic(reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   641
  mem2reg_opt(reg, Address(Z_fp, _z_ijava_state_neg(monitors)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   642
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   643
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   644
void InterpreterMacroAssembler::save_monitors(Register reg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   645
  reg2mem_opt(reg, Address(Z_fp, _z_ijava_state_neg(monitors)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   646
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   647
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   648
void InterpreterMacroAssembler::get_mdp(Register mdp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   649
  z_lg(mdp, _z_ijava_state_neg(mdx), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   650
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   651
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   652
void InterpreterMacroAssembler::save_mdp(Register mdp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   653
  z_stg(mdp, _z_ijava_state_neg(mdx), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   654
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   655
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   656
// Values that are only read (besides initialization).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   657
void InterpreterMacroAssembler::restore_locals() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   658
  asm_assert_ijava_state_magic(Z_locals);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   659
  z_lg(Z_locals, Address(Z_fp, _z_ijava_state_neg(locals)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   660
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   661
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   662
void InterpreterMacroAssembler::get_method(Register reg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   663
  asm_assert_ijava_state_magic(reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   664
  z_lg(reg, Address(Z_fp, _z_ijava_state_neg(method)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   665
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   666
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   667
void InterpreterMacroAssembler::get_2_byte_integer_at_bcp(Register Rdst, int bcp_offset,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   668
                                                          signedOrNot is_signed) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   669
  // Rdst is an 8-byte return value!!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   670
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   671
  // Unaligned loads incur only a small penalty on z/Architecture. The penalty
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   672
  // is a few (2..3) ticks, even when the load crosses a cache line
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   673
  // boundary. In case of a cache miss, the stall could, of course, be
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   674
  // much longer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   675
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   676
  switch (is_signed) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   677
    case Signed:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   678
      z_lgh(Rdst, bcp_offset, Z_R0, Z_bcp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   679
     break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   680
   case Unsigned:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   681
     z_llgh(Rdst, bcp_offset, Z_R0, Z_bcp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   682
     break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   683
   default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   684
     ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   685
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   686
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   687
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   688
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   689
void InterpreterMacroAssembler::get_4_byte_integer_at_bcp(Register Rdst, int bcp_offset,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   690
                                                          setCCOrNot set_cc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   691
  // Rdst is an 8-byte return value!!!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   692
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   693
  // Unaligned loads incur only a small penalty on z/Architecture. The penalty
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   694
  // is a few (2..3) ticks, even when the load crosses a cache line
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   695
  // boundary. In case of a cache miss, the stall could, of course, be
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   696
  // much longer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   697
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   698
  // Both variants implement a sign-extending int2long load.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   699
  if (set_cc == set_CC) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   700
    load_and_test_int2long(Rdst, Address(Z_bcp, (intptr_t)bcp_offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   701
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   702
    mem2reg_signed_opt(    Rdst, Address(Z_bcp, (intptr_t)bcp_offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   703
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   704
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   705
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   706
void InterpreterMacroAssembler::get_constant_pool(Register Rdst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   707
  get_method(Rdst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   708
  mem2reg_opt(Rdst, Address(Rdst, Method::const_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   709
  mem2reg_opt(Rdst, Address(Rdst, ConstMethod::constants_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   710
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   711
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   712
void InterpreterMacroAssembler::get_cpool_and_tags(Register Rcpool, Register Rtags) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   713
  get_constant_pool(Rcpool);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   714
  mem2reg_opt(Rtags, Address(Rcpool, ConstantPool::tags_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   715
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   716
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   717
// Unlock if synchronized method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   718
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   719
// Unlock the receiver if this is a synchronized method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   720
// Unlock any Java monitors from syncronized blocks.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   721
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   722
// If there are locked Java monitors
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   723
//   If throw_monitor_exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   724
//     throws IllegalMonitorStateException
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   725
//   Else if install_monitor_exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   726
//     installs IllegalMonitorStateException
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   727
//   Else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   728
//     no error processing
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   729
void InterpreterMacroAssembler::unlock_if_synchronized_method(TosState state,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   730
                                                              bool throw_monitor_exception,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   731
                                                              bool install_monitor_exception) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   732
  NearLabel unlocked, unlock, no_unlock;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   733
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   734
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   735
    Register R_method = Z_ARG2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   736
    Register R_do_not_unlock_if_synchronized = Z_ARG3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   737
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   738
    // Get the value of _do_not_unlock_if_synchronized into G1_scratch.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   739
    const Address do_not_unlock_if_synchronized(Z_thread,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   740
                                                JavaThread::do_not_unlock_if_synchronized_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   741
    load_sized_value(R_do_not_unlock_if_synchronized, do_not_unlock_if_synchronized, 1, false /*unsigned*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   742
    z_mvi(do_not_unlock_if_synchronized, false); // Reset the flag.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   743
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   744
    // Check if synchronized method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   745
    get_method(R_method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   746
    verify_oop(Z_tos, state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   747
    push(state); // Save tos/result.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   748
    testbit(method2_(R_method, access_flags), JVM_ACC_SYNCHRONIZED_BIT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   749
    z_bfalse(unlocked);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   750
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   751
    // Don't unlock anything if the _do_not_unlock_if_synchronized flag
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   752
    // is set.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   753
    compareU64_and_branch(R_do_not_unlock_if_synchronized, (intptr_t)0L, bcondNotEqual, no_unlock);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   754
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   755
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   756
  // unlock monitor
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   757
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   758
  // BasicObjectLock will be first in list, since this is a
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   759
  // synchronized method. However, need to check that the object has
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   760
  // not been unlocked by an explicit monitorexit bytecode.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   761
  const Address monitor(Z_fp, -(frame::z_ijava_state_size + (int) sizeof(BasicObjectLock)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   762
  // We use Z_ARG2 so that if we go slow path it will be the correct
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   763
  // register for unlock_object to pass to VM directly.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   764
  load_address(Z_ARG2, monitor); // Address of first monitor.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   765
  z_lg(Z_ARG3, Address(Z_ARG2, BasicObjectLock::obj_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   766
  compareU64_and_branch(Z_ARG3, (intptr_t)0L, bcondNotEqual, unlock);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   767
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   768
  if (throw_monitor_exception) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   769
    // Entry already unlocked need to throw an exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   770
    MacroAssembler::call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   771
    should_not_reach_here();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   772
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   773
    // Monitor already unlocked during a stack unroll.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   774
    // If requested, install an illegal_monitor_state_exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   775
    // Continue with stack unrolling.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   776
    if (install_monitor_exception) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   777
      MacroAssembler::call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::new_illegal_monitor_state_exception));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   778
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   779
   z_bru(unlocked);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   780
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   781
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   782
  bind(unlock);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   783
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   784
  unlock_object(Z_ARG2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   785
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   786
  bind(unlocked);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   787
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   788
  // I0, I1: Might contain return value
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   789
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   790
  // Check that all monitors are unlocked.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   791
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   792
    NearLabel loop, exception, entry, restart;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   793
    const int entry_size = frame::interpreter_frame_monitor_size() * wordSize;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   794
    // We use Z_ARG2 so that if we go slow path it will be the correct
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   795
    // register for unlock_object to pass to VM directly.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   796
    Register R_current_monitor = Z_ARG2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   797
    Register R_monitor_block_bot = Z_ARG1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   798
    const Address monitor_block_top(Z_fp, _z_ijava_state_neg(monitors));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   799
    const Address monitor_block_bot(Z_fp, -frame::z_ijava_state_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   800
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   801
    bind(restart);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   802
    // Starting with top-most entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   803
    z_lg(R_current_monitor, monitor_block_top);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   804
    // Points to word before bottom of monitor block.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   805
    load_address(R_monitor_block_bot, monitor_block_bot);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   806
    z_bru(entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   807
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   808
    // Entry already locked, need to throw exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   809
    bind(exception);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   810
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   811
    if (throw_monitor_exception) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   812
      // Throw exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   813
      MacroAssembler::call_VM(noreg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   814
                              CAST_FROM_FN_PTR(address, InterpreterRuntime::
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   815
                                               throw_illegal_monitor_state_exception));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   816
      should_not_reach_here();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   817
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   818
      // Stack unrolling. Unlock object and install illegal_monitor_exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   819
      // Unlock does not block, so don't have to worry about the frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   820
      // We don't have to preserve c_rarg1 since we are going to throw an exception.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   821
      unlock_object(R_current_monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   822
      if (install_monitor_exception) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   823
        call_VM(noreg, CAST_FROM_FN_PTR(address,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   824
                                        InterpreterRuntime::
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   825
                                        new_illegal_monitor_state_exception));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   826
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   827
      z_bru(restart);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   828
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   829
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   830
    bind(loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   831
    // Check if current entry is used.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   832
    load_and_test_long(Z_R0_scratch, Address(R_current_monitor, BasicObjectLock::obj_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   833
    z_brne(exception);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   834
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   835
    add2reg(R_current_monitor, entry_size); // Otherwise advance to next entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   836
    bind(entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   837
    compareU64_and_branch(R_current_monitor, R_monitor_block_bot, bcondNotEqual, loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   838
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   839
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   840
  bind(no_unlock);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   841
  pop(state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   842
  verify_oop(Z_tos, state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   843
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   844
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   845
// remove activation
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   846
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   847
// Unlock the receiver if this is a synchronized method.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   848
// Unlock any Java monitors from syncronized blocks.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   849
// Remove the activation from the stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   850
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   851
// If there are locked Java monitors
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   852
//   If throw_monitor_exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   853
//     throws IllegalMonitorStateException
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   854
//   Else if install_monitor_exception
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   855
//     installs IllegalMonitorStateException
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   856
//   Else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   857
//     no error processing
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   858
void InterpreterMacroAssembler::remove_activation(TosState state,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   859
                                                  Register return_pc,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   860
                                                  bool throw_monitor_exception,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   861
                                                  bool install_monitor_exception,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   862
                                                  bool notify_jvmti) {
43420
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   863
  BLOCK_COMMENT("remove_activation {");
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   864
  unlock_if_synchronized_method(state, throw_monitor_exception, install_monitor_exception);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   865
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   866
  // Save result (push state before jvmti call and pop it afterwards) and notify jvmti.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   867
  notify_method_exit(false, state, notify_jvmti ? NotifyJVMTI : SkipNotifyJVMTI);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   868
43420
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   869
  if (StackReservedPages > 0) {
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   870
    BLOCK_COMMENT("reserved_stack_check:");
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   871
    // Test if reserved zone needs to be enabled.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   872
    Label no_reserved_zone_enabling;
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   873
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   874
    // Compare frame pointers. There is no good stack pointer, as with stack
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   875
    // frame compression we can get different SPs when we do calls. A subsequent
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   876
    // call could have a smaller SP, so that this compare succeeds for an
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   877
    // inner call of the method annotated with ReservedStack.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   878
    z_lg(Z_R0, Address(Z_SP, (intptr_t)_z_abi(callers_sp)));
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   879
    z_clg(Z_R0, Address(Z_thread, JavaThread::reserved_stack_activation_offset())); // Compare with frame pointer in memory.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   880
    z_brl(no_reserved_zone_enabling);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   881
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   882
    // Enable reserved zone again, throw stack overflow exception.
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   883
    call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), Z_thread);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   884
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_delayed_StackOverflowError));
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   885
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   886
    should_not_reach_here();
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   887
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   888
    bind(no_reserved_zone_enabling);
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   889
  }
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   890
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   891
  verify_oop(Z_tos, state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   892
  verify_thread();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   893
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   894
  pop_interpreter_frame(return_pc, Z_ARG2, Z_ARG3);
43420
a056d6465ef9 8172049: [s390] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 42065
diff changeset
   895
  BLOCK_COMMENT("} remove_activation");
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   896
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   897
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   898
// lock object
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   899
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   900
// Registers alive
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   901
//   monitor - Address of the BasicObjectLock to be used for locking,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   902
//             which must be initialized with the object to lock.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   903
//   object  - Address of the object to be locked.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   904
void InterpreterMacroAssembler::lock_object(Register monitor, Register object) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   905
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   906
  if (UseHeavyMonitors) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   907
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   908
            monitor, /*check_for_exceptions=*/false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   909
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   910
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   911
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   912
  // template code:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   913
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   914
  // markOop displaced_header = obj->mark().set_unlocked();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   915
  // monitor->lock()->set_displaced_header(displaced_header);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   916
  // if (Atomic::cmpxchg_ptr(/*ex=*/monitor, /*addr*/obj->mark_addr(), /*cmp*/displaced_header) == displaced_header) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   917
  //   // We stored the monitor address into the object's mark word.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   918
  // } else if (THREAD->is_lock_owned((address)displaced_header))
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   919
  //   // Simple recursive case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   920
  //   monitor->lock()->set_displaced_header(NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   921
  // } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   922
  //   // Slow path.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   923
  //   InterpreterRuntime::monitorenter(THREAD, monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   924
  // }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   925
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   926
  const Register displaced_header = Z_ARG5;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   927
  const Register object_mark_addr = Z_ARG4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   928
  const Register current_header   = Z_ARG5;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   929
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   930
  NearLabel done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   931
  NearLabel slow_case;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   932
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   933
  // markOop displaced_header = obj->mark().set_unlocked();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   934
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   935
  // Load markOop from object into displaced_header.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   936
  z_lg(displaced_header, oopDesc::mark_offset_in_bytes(), object);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   937
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   938
  if (UseBiasedLocking) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   939
    biased_locking_enter(object, displaced_header, Z_R1, Z_R0, done, &slow_case);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   940
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   941
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   942
  // Set displaced_header to be (markOop of object | UNLOCK_VALUE).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   943
  z_oill(displaced_header, markOopDesc::unlocked_value);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   944
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   945
  // monitor->lock()->set_displaced_header(displaced_header);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   946
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   947
  // Initialize the box (Must happen before we update the object mark!).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   948
  z_stg(displaced_header, BasicObjectLock::lock_offset_in_bytes() +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   949
                          BasicLock::displaced_header_offset_in_bytes(), monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   950
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   951
  // if (Atomic::cmpxchg_ptr(/*ex=*/monitor, /*addr*/obj->mark_addr(), /*cmp*/displaced_header) == displaced_header) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   952
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   953
  // Store stack address of the BasicObjectLock (this is monitor) into object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   954
  add2reg(object_mark_addr, oopDesc::mark_offset_in_bytes(), object);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   955
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   956
  z_csg(displaced_header, monitor, 0, object_mark_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   957
  assert(current_header==displaced_header, "must be same register"); // Identified two registers from z/Architecture.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   958
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   959
  z_bre(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   960
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   961
  // } else if (THREAD->is_lock_owned((address)displaced_header))
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   962
  //   // Simple recursive case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   963
  //   monitor->lock()->set_displaced_header(NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   964
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   965
  // We did not see an unlocked object so try the fast recursive case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   966
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   967
  // Check if owner is self by comparing the value in the markOop of object
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   968
  // (current_header) with the stack pointer.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   969
  z_sgr(current_header, Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   970
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   971
  assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   972
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   973
  // The prior sequence "LGR, NGR, LTGR" can be done better
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   974
  // (Z_R1 is temp and not used after here).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   975
  load_const_optimized(Z_R0, (~(os::vm_page_size()-1) | markOopDesc::lock_mask_in_place));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   976
  z_ngr(Z_R0, current_header); // AND sets CC (result eq/ne 0)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   977
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   978
  // If condition is true we are done and hence we can store 0 in the displaced
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   979
  // header indicating it is a recursive lock and be done.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   980
  z_brne(slow_case);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   981
  z_release();  // Membar unnecessary on zarch AND because the above csg does a sync before and after.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   982
  z_stg(Z_R0/*==0!*/, BasicObjectLock::lock_offset_in_bytes() +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   983
                      BasicLock::displaced_header_offset_in_bytes(), monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   984
  z_bru(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   985
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   986
  // } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   987
  //   // Slow path.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   988
  //   InterpreterRuntime::monitorenter(THREAD, monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   989
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   990
  // None of the above fast optimizations worked so we have to get into the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   991
  // slow case of monitor enter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   992
  bind(slow_case);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   993
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   994
  call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   995
          monitor, /*check_for_exceptions=*/false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   996
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   997
  // }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   998
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   999
  bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1000
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1001
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1002
// Unlocks an object. Used in monitorexit bytecode and remove_activation.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1003
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1004
// Registers alive
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1005
//   monitor - address of the BasicObjectLock to be used for locking,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1006
//             which must be initialized with the object to lock.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1007
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1008
// Throw IllegalMonitorException if object is not locked by current thread.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1009
void InterpreterMacroAssembler::unlock_object(Register monitor, Register object) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1010
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1011
  if (UseHeavyMonitors) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1012
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1013
            monitor, /*check_for_exceptions=*/ true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1014
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1015
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1016
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1017
// else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1018
  // template code:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1019
  //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1020
  // if ((displaced_header = monitor->displaced_header()) == NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1021
  //   // Recursive unlock. Mark the monitor unlocked by setting the object field to NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1022
  //   monitor->set_obj(NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1023
  // } else if (Atomic::cmpxchg_ptr(displaced_header, obj->mark_addr(), monitor) == monitor) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1024
  //   // We swapped the unlocked mark in displaced_header into the object's mark word.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1025
  //   monitor->set_obj(NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1026
  // } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1027
  //   // Slow path.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1028
  //   InterpreterRuntime::monitorexit(THREAD, monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1029
  // }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1030
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1031
  const Register displaced_header = Z_ARG4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1032
  const Register current_header   = Z_R1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1033
  Address obj_entry(monitor, BasicObjectLock::obj_offset_in_bytes());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1034
  Label done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1035
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1036
  if (object == noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1037
    // In the template interpreter, we must assure that the object
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1038
    // entry in the monitor is cleared on all paths. Thus we move
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1039
    // loading up to here, and clear the entry afterwards.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1040
    object = Z_ARG3; // Use Z_ARG3 if caller didn't pass object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1041
    z_lg(object, obj_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1042
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1043
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1044
  assert_different_registers(monitor, object, displaced_header, current_header);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1045
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1046
  // if ((displaced_header = monitor->displaced_header()) == NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1047
  //   // Recursive unlock. Mark the monitor unlocked by setting the object field to NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1048
  //   monitor->set_obj(NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1049
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1050
  clear_mem(obj_entry, sizeof(oop));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1051
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1052
  if (UseBiasedLocking) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1053
    // The object address from the monitor is in object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1054
    assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1055
    biased_locking_exit(object, displaced_header, done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1056
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1057
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1058
  // Test first if we are in the fast recursive case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1059
  MacroAssembler::load_and_test_long(displaced_header,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1060
                                     Address(monitor, BasicObjectLock::lock_offset_in_bytes() +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1061
                                                      BasicLock::displaced_header_offset_in_bytes()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1062
  z_bre(done); // displaced_header == 0 -> goto done
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1063
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1064
  // } else if (Atomic::cmpxchg_ptr(displaced_header, obj->mark_addr(), monitor) == monitor) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1065
  //   // We swapped the unlocked mark in displaced_header into the object's mark word.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1066
  //   monitor->set_obj(NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1067
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1068
  // If we still have a lightweight lock, unlock the object and be done.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1069
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1070
  // The markword is expected to be at offset 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1071
  assert(oopDesc::mark_offset_in_bytes() == 0, "unlock_object: review code below");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1072
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1073
  // We have the displaced header in displaced_header. If the lock is still
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1074
  // lightweight, it will contain the monitor address and we'll store the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1075
  // displaced header back into the object's mark word.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1076
  z_lgr(current_header, monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1077
  z_csg(current_header, displaced_header, 0, object);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1078
  z_bre(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1079
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1080
  // } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1081
  //   // Slow path.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1082
  //   InterpreterRuntime::monitorexit(THREAD, monitor);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1083
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1084
  // The lock has been converted into a heavy lock and hence
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1085
  // we need to get into the slow case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1086
  z_stg(object, obj_entry);   // Restore object entry, has been cleared above.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1087
  call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1088
          monitor,  /*check_for_exceptions=*/false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1089
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1090
  // }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1091
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1092
  bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1093
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1094
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1095
void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, Label& zero_continue) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1096
  assert(ProfileInterpreter, "must be profiling interpreter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1097
  load_and_test_long(mdp, Address(Z_fp, _z_ijava_state_neg(mdx)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1098
  z_brz(zero_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1099
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1100
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1101
// Set the method data pointer for the current bcp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1102
void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1103
  assert(ProfileInterpreter, "must be profiling interpreter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1104
  Label    set_mdp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1105
  Register mdp    = Z_ARG4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1106
  Register method = Z_ARG5;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1107
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1108
  get_method(method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1109
  // Test MDO to avoid the call if it is NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1110
  load_and_test_long(mdp, method2_(method, method_data));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1111
  z_brz(set_mdp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1112
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1113
  call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), method, Z_bcp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1114
  // Z_RET: mdi
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1115
  // Mdo is guaranteed to be non-zero here, we checked for it before the call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1116
  assert(method->is_nonvolatile(), "choose nonvolatile reg or reload from frame");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1117
  z_lg(mdp, method2_(method, method_data)); // Must reload, mdp is volatile reg.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1118
  add2reg_with_index(mdp, in_bytes(MethodData::data_offset()), Z_RET, mdp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1119
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1120
  bind(set_mdp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1121
  save_mdp(mdp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1122
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1123
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1124
void InterpreterMacroAssembler::verify_method_data_pointer() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1125
  assert(ProfileInterpreter, "must be profiling interpreter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1126
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1127
  NearLabel verify_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1128
  Register bcp_expected = Z_ARG3;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1129
  Register mdp    = Z_ARG4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1130
  Register method = Z_ARG5;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1131
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1132
  test_method_data_pointer(mdp, verify_continue); // If mdp is zero, continue
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1133
  get_method(method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1134
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1135
  // If the mdp is valid, it will point to a DataLayout header which is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1136
  // consistent with the bcp. The converse is highly probable also.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1137
  load_sized_value(bcp_expected, Address(mdp, DataLayout::bci_offset()), 2, false /*signed*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1138
  z_ag(bcp_expected, Address(method, Method::const_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1139
  load_address(bcp_expected, Address(bcp_expected, ConstMethod::codes_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1140
  compareU64_and_branch(bcp_expected, Z_bcp, bcondEqual, verify_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1141
  call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp), method, Z_bcp, mdp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1142
  bind(verify_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1143
#endif // ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1144
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1145
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1146
void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in, int constant, Register value) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1147
  assert(ProfileInterpreter, "must be profiling interpreter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1148
  z_stg(value, constant, mdp_in);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1149
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1150
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1151
void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1152
                                                      int constant,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1153
                                                      Register tmp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1154
                                                      bool decrement) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1155
  assert_different_registers(mdp_in, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1156
  // counter address
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1157
  Address data(mdp_in, constant);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1158
  const int delta = decrement ? -DataLayout::counter_increment : DataLayout::counter_increment;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1159
  add2mem_64(Address(mdp_in, constant), delta, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1160
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1161
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1162
void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1163
                                                int flag_byte_constant) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1164
  assert(ProfileInterpreter, "must be profiling interpreter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1165
  // Set the flag.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1166
  z_oi(Address(mdp_in, DataLayout::flags_offset()), flag_byte_constant);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1167
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1168
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1169
void InterpreterMacroAssembler::test_mdp_data_at(Register mdp_in,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1170
                                                 int offset,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1171
                                                 Register value,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1172
                                                 Register test_value_out,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1173
                                                 Label& not_equal_continue) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1174
  assert(ProfileInterpreter, "must be profiling interpreter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1175
  if (test_value_out == noreg) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1176
    z_cg(value, Address(mdp_in, offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1177
    z_brne(not_equal_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1178
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1179
    // Put the test value into a register, so caller can use it:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1180
    z_lg(test_value_out, Address(mdp_in, offset));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1181
    compareU64_and_branch(test_value_out, value, bcondNotEqual, not_equal_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1182
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1183
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1184
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1185
void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, int offset_of_disp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1186
  update_mdp_by_offset(mdp_in, noreg, offset_of_disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1187
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1188
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1189
void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1190
                                                     Register dataidx,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1191
                                                     int offset_of_disp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1192
  assert(ProfileInterpreter, "must be profiling interpreter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1193
  Address disp_address(mdp_in, dataidx, offset_of_disp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1194
  Assembler::z_ag(mdp_in, disp_address);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1195
  save_mdp(mdp_in);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1196
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1197
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1198
void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in, int constant) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1199
  assert(ProfileInterpreter, "must be profiling interpreter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1200
  add2reg(mdp_in, constant);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1201
  save_mdp(mdp_in);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1202
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1203
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1204
void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1205
  assert(ProfileInterpreter, "must be profiling interpreter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1206
  assert(return_bci->is_nonvolatile(), "choose nonvolatile reg or save/restore");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1207
  call_VM(noreg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1208
          CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1209
          return_bci);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1210
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1211
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1212
void InterpreterMacroAssembler::profile_taken_branch(Register mdp, Register bumped_count) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1213
  if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1214
    Label profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1215
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1216
    // If no method data exists, go to profile_continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1217
    // Otherwise, assign to mdp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1218
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1219
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1220
    // We are taking a branch. Increment the taken count.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1221
    // We inline increment_mdp_data_at to return bumped_count in a register
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1222
    //increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1223
    Address data(mdp, JumpData::taken_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1224
    z_lg(bumped_count, data);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1225
    // 64-bit overflow is very unlikely. Saturation to 32-bit values is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1226
    // performed when reading the counts.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1227
    add2reg(bumped_count, DataLayout::counter_increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1228
    z_stg(bumped_count, data); // Store back out
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1229
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1230
    // The method data pointer needs to be updated to reflect the new target.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1231
    update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1232
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1233
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1234
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1235
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1236
// Kills Z_R1_scratch.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1237
void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1238
  if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1239
    Label profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1240
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1241
    // If no method data exists, go to profile_continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1242
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1243
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1244
    // We are taking a branch. Increment the not taken count.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1245
    increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()), Z_R1_scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1246
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1247
    // The method data pointer needs to be updated to correspond to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1248
    // the next bytecode.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1249
    update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1250
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1251
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1252
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1253
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1254
// Kills: Z_R1_scratch.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1255
void InterpreterMacroAssembler::profile_call(Register mdp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1256
  if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1257
    Label profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1258
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1259
    // If no method data exists, go to profile_continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1260
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1261
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1262
    // We are making a call. Increment the count.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1263
    increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1264
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1265
    // The method data pointer needs to be updated to reflect the new target.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1266
    update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1267
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1268
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1269
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1270
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1271
void InterpreterMacroAssembler::profile_final_call(Register mdp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1272
  if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1273
    Label profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1274
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1275
    // If no method data exists, go to profile_continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1276
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1277
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1278
    // We are making a call. Increment the count.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1279
    increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1280
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1281
    // The method data pointer needs to be updated to reflect the new target.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1282
    update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1283
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1284
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1285
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1286
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1287
void InterpreterMacroAssembler::profile_virtual_call(Register receiver,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1288
                                                     Register mdp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1289
                                                     Register reg2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1290
                                                     bool receiver_can_be_null) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1291
  if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1292
    NearLabel profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1293
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1294
    // If no method data exists, go to profile_continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1295
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1296
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1297
    NearLabel skip_receiver_profile;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1298
    if (receiver_can_be_null) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1299
      NearLabel not_null;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1300
      compareU64_and_branch(receiver, (intptr_t)0L, bcondNotEqual, not_null);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1301
      // We are making a call. Increment the count for null receiver.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1302
      increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1303
      z_bru(skip_receiver_profile);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1304
      bind(not_null);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1305
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1306
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1307
    // Record the receiver type.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1308
    record_klass_in_profile(receiver, mdp, reg2, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1309
    bind(skip_receiver_profile);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1310
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1311
    // The method data pointer needs to be updated to reflect the new target.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1312
    update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1313
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1314
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1315
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1316
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1317
// This routine creates a state machine for updating the multi-row
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1318
// type profile at a virtual call site (or other type-sensitive bytecode).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1319
// The machine visits each row (of receiver/count) until the receiver type
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1320
// is found, or until it runs out of rows. At the same time, it remembers
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1321
// the location of the first empty row. (An empty row records null for its
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1322
// receiver, and can be allocated for a newly-observed receiver type.)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1323
// Because there are two degrees of freedom in the state, a simple linear
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1324
// search will not work; it must be a decision tree. Hence this helper
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1325
// function is recursive, to generate the required tree structured code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1326
// It's the interpreter, so we are trading off code space for speed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1327
// See below for example code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1328
void InterpreterMacroAssembler::record_klass_in_profile_helper(
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1329
                                        Register receiver, Register mdp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1330
                                        Register reg2, int start_row,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1331
                                        Label& done, bool is_virtual_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1332
  if (TypeProfileWidth == 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1333
    if (is_virtual_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1334
      increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1335
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1336
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1337
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1338
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1339
  int last_row = VirtualCallData::row_limit() - 1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1340
  assert(start_row <= last_row, "must be work left to do");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1341
  // Test this row for both the receiver and for null.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1342
  // Take any of three different outcomes:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1343
  //   1. found receiver => increment count and goto done
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1344
  //   2. found null => keep looking for case 1, maybe allocate this cell
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1345
  //   3. found something else => keep looking for cases 1 and 2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1346
  // Case 3 is handled by a recursive call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1347
  for (int row = start_row; row <= last_row; row++) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1348
    NearLabel next_test;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1349
    bool test_for_null_also = (row == start_row);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1350
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1351
    // See if the receiver is receiver[n].
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1352
    int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1353
    test_mdp_data_at(mdp, recvr_offset, receiver,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1354
                     (test_for_null_also ? reg2 : noreg),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1355
                     next_test);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1356
    // (Reg2 now contains the receiver from the CallData.)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1357
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1358
    // The receiver is receiver[n]. Increment count[n].
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1359
    int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1360
    increment_mdp_data_at(mdp, count_offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1361
    z_bru(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1362
    bind(next_test);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1363
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1364
    if (test_for_null_also) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1365
      Label found_null;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1366
      // Failed the equality check on receiver[n]... Test for null.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1367
      z_ltgr(reg2, reg2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1368
      if (start_row == last_row) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1369
        // The only thing left to do is handle the null case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1370
        if (is_virtual_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1371
          z_brz(found_null);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1372
          // Receiver did not match any saved receiver and there is no empty row for it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1373
          // Increment total counter to indicate polymorphic case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1374
          increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1375
          z_bru(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1376
          bind(found_null);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1377
        } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1378
          z_brnz(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1379
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1380
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1381
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1382
      // Since null is rare, make it be the branch-taken case.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1383
      z_brz(found_null);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1384
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1385
      // Put all the "Case 3" tests here.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1386
      record_klass_in_profile_helper(receiver, mdp, reg2, start_row + 1, done, is_virtual_call);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1387
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1388
      // Found a null. Keep searching for a matching receiver,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1389
      // but remember that this is an empty (unused) slot.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1390
      bind(found_null);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1391
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1392
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1393
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1394
  // In the fall-through case, we found no matching receiver, but we
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1395
  // observed the receiver[start_row] is NULL.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1396
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1397
  // Fill in the receiver field and increment the count.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1398
  int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1399
  set_mdp_data_at(mdp, recvr_offset, receiver);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1400
  int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1401
  load_const_optimized(reg2, DataLayout::counter_increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1402
  set_mdp_data_at(mdp, count_offset, reg2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1403
  if (start_row > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1404
    z_bru(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1405
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1406
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1407
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1408
// Example state machine code for three profile rows:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1409
//   // main copy of decision tree, rooted at row[1]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1410
//   if (row[0].rec == rec) { row[0].incr(); goto done; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1411
//   if (row[0].rec != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1412
//     // inner copy of decision tree, rooted at row[1]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1413
//     if (row[1].rec == rec) { row[1].incr(); goto done; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1414
//     if (row[1].rec != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1415
//       // degenerate decision tree, rooted at row[2]
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1416
//       if (row[2].rec == rec) { row[2].incr(); goto done; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1417
//       if (row[2].rec != NULL) { count.incr(); goto done; } // overflow
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1418
//       row[2].init(rec); goto done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1419
//     } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1420
//       // remember row[1] is empty
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1421
//       if (row[2].rec == rec) { row[2].incr(); goto done; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1422
//       row[1].init(rec); goto done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1423
//     }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1424
//   } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1425
//     // remember row[0] is empty
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1426
//     if (row[1].rec == rec) { row[1].incr(); goto done; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1427
//     if (row[2].rec == rec) { row[2].incr(); goto done; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1428
//     row[0].init(rec); goto done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1429
//   }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1430
//   done:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1431
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1432
void InterpreterMacroAssembler::record_klass_in_profile(Register receiver,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1433
                                                        Register mdp, Register reg2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1434
                                                        bool is_virtual_call) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1435
  assert(ProfileInterpreter, "must be profiling");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1436
  Label done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1437
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1438
  record_klass_in_profile_helper(receiver, mdp, reg2, 0, done, is_virtual_call);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1439
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1440
  bind (done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1441
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1442
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1443
void InterpreterMacroAssembler::profile_ret(Register return_bci, Register mdp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1444
  if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1445
    NearLabel profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1446
    uint row;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1447
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1448
    // If no method data exists, go to profile_continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1449
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1450
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1451
    // Update the total ret count.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1452
    increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1453
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1454
    for (row = 0; row < RetData::row_limit(); row++) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1455
      NearLabel next_test;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1456
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1457
      // See if return_bci is equal to bci[n]:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1458
      test_mdp_data_at(mdp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1459
                       in_bytes(RetData::bci_offset(row)),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1460
                       return_bci, noreg,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1461
                       next_test);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1462
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1463
      // Return_bci is equal to bci[n]. Increment the count.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1464
      increment_mdp_data_at(mdp, in_bytes(RetData::bci_count_offset(row)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1465
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1466
      // The method data pointer needs to be updated to reflect the new target.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1467
      update_mdp_by_offset(mdp, in_bytes(RetData::bci_displacement_offset(row)));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1468
      z_bru(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1469
      bind(next_test);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1470
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1471
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1472
    update_mdp_for_ret(return_bci);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1473
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1474
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1475
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1476
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1477
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1478
void InterpreterMacroAssembler::profile_null_seen(Register mdp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1479
  if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1480
    Label profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1481
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1482
    // If no method data exists, go to profile_continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1483
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1484
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1485
    set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1486
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1487
    // The method data pointer needs to be updated.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1488
    int mdp_delta = in_bytes(BitData::bit_data_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1489
    if (TypeProfileCasts) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1490
      mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1491
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1492
    update_mdp_by_constant(mdp, mdp_delta);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1493
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1494
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1495
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1496
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1497
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1498
void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp, Register tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1499
  if (ProfileInterpreter && TypeProfileCasts) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1500
    Label profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1501
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1502
    // If no method data exists, go to profile_continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1503
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1504
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1505
    int count_offset = in_bytes(CounterData::count_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1506
    // Back up the address, since we have already bumped the mdp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1507
    count_offset -= in_bytes(VirtualCallData::virtual_call_data_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1508
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1509
    // *Decrement* the counter. We expect to see zero or small negatives.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1510
    increment_mdp_data_at(mdp, count_offset, tmp, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1511
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1512
    bind (profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1513
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1514
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1515
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1516
void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass, Register reg2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1517
  if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1518
    Label profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1519
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1520
    // If no method data exists, go to profile_continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1521
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1522
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1523
    // The method data pointer needs to be updated.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1524
    int mdp_delta = in_bytes(BitData::bit_data_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1525
    if (TypeProfileCasts) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1526
      mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1527
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1528
      // Record the object type.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1529
      record_klass_in_profile(klass, mdp, reg2, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1530
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1531
    update_mdp_by_constant(mdp, mdp_delta);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1532
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1533
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1534
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1535
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1536
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1537
void InterpreterMacroAssembler::profile_switch_default(Register mdp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1538
  if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1539
    Label profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1540
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1541
    // If no method data exists, go to profile_continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1542
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1543
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1544
    // Update the default case count.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1545
    increment_mdp_data_at(mdp, in_bytes(MultiBranchData::default_count_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1546
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1547
    // The method data pointer needs to be updated.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1548
    update_mdp_by_offset(mdp, in_bytes(MultiBranchData::default_displacement_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1549
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1550
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1551
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1552
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1553
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1554
// Kills: index, scratch1, scratch2.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1555
void InterpreterMacroAssembler::profile_switch_case(Register index,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1556
                                                    Register mdp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1557
                                                    Register scratch1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1558
                                                    Register scratch2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1559
  if (ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1560
    Label profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1561
    assert_different_registers(index, mdp, scratch1, scratch2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1562
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1563
    // If no method data exists, go to profile_continue.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1564
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1565
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1566
    // Build the base (index * per_case_size_in_bytes()) +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1567
    // case_array_offset_in_bytes().
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1568
    z_sllg(index, index, exact_log2(in_bytes(MultiBranchData::per_case_size())));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1569
    add2reg(index, in_bytes(MultiBranchData::case_array_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1570
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1571
    // Add the calculated base to the mdp -> address of the case' data.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1572
    Address case_data_addr(mdp, index);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1573
    Register case_data = scratch1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1574
    load_address(case_data, case_data_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1575
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1576
    // Update the case count.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1577
    increment_mdp_data_at(case_data,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1578
                          in_bytes(MultiBranchData::relative_count_offset()),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1579
                          scratch2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1580
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1581
    // The method data pointer needs to be updated.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1582
    update_mdp_by_offset(mdp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1583
                         index,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1584
                         in_bytes(MultiBranchData::relative_displacement_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1585
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1586
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1587
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1588
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1589
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1590
// kills: R0, R1, flags, loads klass from obj (if not null)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1591
void InterpreterMacroAssembler::profile_obj_type(Register obj, Address mdo_addr, Register klass, bool cmp_done) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1592
  NearLabel null_seen, init_klass, do_nothing, do_update;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1593
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1594
  // Klass = obj is allowed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1595
  const Register tmp = Z_R1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1596
  assert_different_registers(obj, mdo_addr.base(), tmp, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1597
  assert_different_registers(klass, mdo_addr.base(), tmp, Z_R0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1598
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1599
  z_lg(tmp, mdo_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1600
  if (cmp_done) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1601
    z_brz(null_seen);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1602
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1603
    compareU64_and_branch(obj, (intptr_t)0, Assembler::bcondEqual, null_seen);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1604
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1605
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1606
  verify_oop(obj);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1607
  load_klass(klass, obj);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1608
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1609
  // Klass seen before, nothing to do (regardless of unknown bit).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1610
  z_lgr(Z_R0, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1611
  assert(Immediate::is_uimm(~TypeEntries::type_klass_mask, 16), "or change following instruction");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1612
  z_nill(Z_R0, TypeEntries::type_klass_mask & 0xFFFF);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1613
  compareU64_and_branch(Z_R0, klass, Assembler::bcondEqual, do_nothing);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1614
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1615
  // Already unknown. Nothing to do anymore.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1616
  z_tmll(tmp, TypeEntries::type_unknown);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1617
  z_brc(Assembler::bcondAllOne, do_nothing);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1618
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1619
  z_lgr(Z_R0, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1620
  assert(Immediate::is_uimm(~TypeEntries::type_mask, 16), "or change following instruction");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1621
  z_nill(Z_R0, TypeEntries::type_mask & 0xFFFF);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1622
  compareU64_and_branch(Z_R0, (intptr_t)0, Assembler::bcondEqual, init_klass);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1623
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1624
  // Different than before. Cannot keep accurate profile.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1625
  z_oill(tmp, TypeEntries::type_unknown);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1626
  z_bru(do_update);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1627
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1628
  bind(init_klass);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1629
  // Combine klass and null_seen bit (only used if (tmp & type_mask)==0).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1630
  z_ogr(tmp, klass);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1631
  z_bru(do_update);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1632
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1633
  bind(null_seen);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1634
  // Set null_seen if obj is 0.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1635
  z_oill(tmp, TypeEntries::null_seen);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1636
  // fallthru: z_bru(do_update);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1637
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1638
  bind(do_update);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1639
  z_stg(tmp, mdo_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1640
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1641
  bind(do_nothing);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1642
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1643
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1644
void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1645
  if (!ProfileInterpreter) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1646
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1647
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1648
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1649
  assert_different_registers(mdp, callee, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1650
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1651
  if (MethodData::profile_arguments() || MethodData::profile_return()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1652
    Label profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1653
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1654
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1655
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1656
    int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1657
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1658
    z_cliy(in_bytes(DataLayout::tag_offset()) - off_to_start, mdp,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1659
           is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1660
    z_brne(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1661
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1662
    if (MethodData::profile_arguments()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1663
      NearLabel done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1664
      int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1665
      add2reg(mdp, off_to_args);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1666
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1667
      for (int i = 0; i < TypeProfileArgsLimit; i++) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1668
        if (i > 0 || MethodData::profile_return()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1669
          // If return value type is profiled we may have no argument to profile.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1670
          z_lg(tmp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args, mdp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1671
          add2reg(tmp, -i*TypeStackSlotEntries::per_arg_count());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1672
          compare64_and_branch(tmp, TypeStackSlotEntries::per_arg_count(), Assembler::bcondLow, done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1673
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1674
        z_lg(tmp, Address(callee, Method::const_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1675
        z_lgh(tmp, Address(tmp, ConstMethod::size_of_parameters_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1676
        // Stack offset o (zero based) from the start of the argument
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1677
        // list. For n arguments translates into offset n - o - 1 from
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1678
        // the end of the argument list. But there is an extra slot at
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1679
        // the top of the stack. So the offset is n - o from Lesp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1680
        z_sg(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1681
        z_sllg(tmp, tmp, Interpreter::logStackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1682
        Address stack_slot_addr(tmp, Z_esp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1683
        z_ltg(tmp, stack_slot_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1684
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1685
        Address mdo_arg_addr(mdp, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1686
        profile_obj_type(tmp, mdo_arg_addr, tmp, /*ltg did compare to 0*/ true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1687
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1688
        int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1689
        add2reg(mdp, to_add);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1690
        off_to_args += to_add;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1691
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1692
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1693
      if (MethodData::profile_return()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1694
        z_lg(tmp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args, mdp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1695
        add2reg(tmp, -TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1696
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1697
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1698
      bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1699
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1700
      if (MethodData::profile_return()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1701
        // We're right after the type profile for the last
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1702
        // argument. Tmp is the number of cells left in the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1703
        // CallTypeData/VirtualCallTypeData to reach its end. Non null
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1704
        // if there's a return to profile.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1705
        assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1706
        z_sllg(tmp, tmp, exact_log2(DataLayout::cell_size));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1707
        z_agr(mdp, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1708
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1709
      z_stg(mdp, _z_ijava_state_neg(mdx), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1710
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1711
      assert(MethodData::profile_return(), "either profile call args or call ret");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1712
      update_mdp_by_constant(mdp, in_bytes(TypeEntriesAtCall::return_only_size()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1713
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1714
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1715
    // Mdp points right after the end of the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1716
    // CallTypeData/VirtualCallTypeData, right after the cells for the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1717
    // return value type if there's one.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1718
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1719
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1720
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1721
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1722
void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1723
  assert_different_registers(mdp, ret, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1724
  if (ProfileInterpreter && MethodData::profile_return()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1725
    Label profile_continue;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1726
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1727
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1728
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1729
    if (MethodData::profile_return_jsr292_only()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1730
      // If we don't profile all invoke bytecodes we must make sure
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1731
      // it's a bytecode we indeed profile. We can't go back to the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1732
      // beginning of the ProfileData we intend to update to check its
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1733
      // type because we're right after it and we don't known its
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1734
      // length.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1735
      NearLabel do_profile;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1736
      Address bc(Z_bcp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1737
      z_lb(tmp, bc);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1738
      compare32_and_branch(tmp, Bytecodes::_invokedynamic, Assembler::bcondEqual, do_profile);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1739
      compare32_and_branch(tmp, Bytecodes::_invokehandle, Assembler::bcondEqual, do_profile);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1740
      get_method(tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1741
      // Supplement to 8139891: _intrinsic_id exceeded 1-byte size limit.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1742
      if (Method::intrinsic_id_size_in_bytes() == 1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1743
        z_cli(Method::intrinsic_id_offset_in_bytes(), tmp, vmIntrinsics::_compiledLambdaForm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1744
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1745
        assert(Method::intrinsic_id_size_in_bytes() == 2, "size error: check Method::_intrinsic_id");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1746
        z_lh(tmp, Method::intrinsic_id_offset_in_bytes(), Z_R0, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1747
        z_chi(tmp, vmIntrinsics::_compiledLambdaForm);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1748
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1749
      z_brne(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1750
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1751
      bind(do_profile);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1752
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1753
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1754
    Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1755
    profile_obj_type(ret, mdo_ret_addr, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1756
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1757
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1758
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1759
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1760
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1761
void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1762
  if (ProfileInterpreter && MethodData::profile_parameters()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1763
    Label profile_continue, done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1764
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1765
    test_method_data_pointer(mdp, profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1766
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1767
    // Load the offset of the area within the MDO used for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1768
    // parameters. If it's negative we're not profiling any parameters.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1769
    Address parm_di_addr(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1770
    load_and_test_int2long(tmp1, parm_di_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1771
    z_brl(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1772
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1773
    // Compute a pointer to the area for parameters from the offset
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1774
    // and move the pointer to the slot for the last
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1775
    // parameters. Collect profiling from last parameter down.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1776
    // mdo start + parameters offset + array length - 1
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1777
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1778
    // Pointer to the parameter area in the MDO.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1779
    z_agr(mdp, tmp1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1780
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1781
    // Offset of the current profile entry to update.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1782
    const Register entry_offset = tmp1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1783
    // entry_offset = array len in number of cells.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1784
    z_lg(entry_offset, Address(mdp, ArrayData::array_len_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1785
    // entry_offset (number of cells) = array len - size of 1 entry
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1786
    add2reg(entry_offset, -TypeStackSlotEntries::per_arg_count());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1787
    // entry_offset in bytes
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1788
    z_sllg(entry_offset, entry_offset, exact_log2(DataLayout::cell_size));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1789
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1790
    Label loop;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1791
    bind(loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1792
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1793
    Address arg_off(mdp, entry_offset, ParametersTypeData::stack_slot_offset(0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1794
    Address arg_type(mdp, entry_offset, ParametersTypeData::type_offset(0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1795
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1796
    // Load offset on the stack from the slot for this parameter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1797
    z_lg(tmp2, arg_off);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1798
    z_sllg(tmp2, tmp2, Interpreter::logStackElementSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1799
    z_lcgr(tmp2); // Negate.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1800
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1801
    // Profile the parameter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1802
    z_ltg(tmp2, Address(Z_locals, tmp2));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1803
    profile_obj_type(tmp2, arg_type, tmp2, /*ltg did compare to 0*/ true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1804
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1805
    // Go to next parameter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1806
    z_aghi(entry_offset, -TypeStackSlotEntries::per_arg_count() * DataLayout::cell_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1807
    z_brnl(loop);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1808
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1809
    bind(profile_continue);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1810
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1811
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1812
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1813
// Jump if ((*counter_addr += increment) & mask) satisfies the condition.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1814
void InterpreterMacroAssembler::increment_mask_and_jump(Address          counter_addr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1815
                                                        int              increment,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1816
                                                        Address          mask,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1817
                                                        Register         scratch,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1818
                                                        bool             preloaded,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1819
                                                        branch_condition cond,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1820
                                                        Label           *where) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1821
  assert_different_registers(counter_addr.base(), scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1822
  if (preloaded) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1823
    add2reg(scratch, increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1824
    reg2mem_opt(scratch, counter_addr, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1825
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1826
    if (VM_Version::has_MemWithImmALUOps() && Immediate::is_simm8(increment) && counter_addr.is_RSYform()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1827
      z_alsi(counter_addr.disp20(), counter_addr.base(), increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1828
      mem2reg_signed_opt(scratch, counter_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1829
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1830
      mem2reg_signed_opt(scratch, counter_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1831
      add2reg(scratch, increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1832
      reg2mem_opt(scratch, counter_addr, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1833
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1834
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1835
  z_n(scratch, mask);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1836
  if (where) { z_brc(cond, *where); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1837
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1838
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1839
// Get MethodCounters object for given method. Lazily allocated if necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1840
//   method    - Ptr to Method object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1841
//   Rcounters - Ptr to MethodCounters object associated with Method object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1842
//   skip      - Exit point if MethodCounters object can't be created (OOM condition).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1843
void InterpreterMacroAssembler::get_method_counters(Register Rmethod,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1844
                                                    Register Rcounters,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1845
                                                    Label& skip) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1846
  assert_different_registers(Rmethod, Rcounters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1847
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1848
  BLOCK_COMMENT("get MethodCounters object {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1849
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1850
  Label has_counters;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1851
  load_and_test_long(Rcounters, Address(Rmethod, Method::method_counters_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1852
  z_brnz(has_counters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1853
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1854
  call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::build_method_counters), Rmethod, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1855
  z_ltgr(Rcounters, Z_RET); // Runtime call returns MethodCounters object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1856
  z_brz(skip); // No MethodCounters, out of memory.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1857
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1858
  bind(has_counters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1859
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1860
  BLOCK_COMMENT("} get MethodCounters object");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1861
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1862
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1863
// Increment invocation counter in MethodCounters object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1864
// Return (invocation_counter+backedge_counter) as "result" in RctrSum.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1865
// Counter values are all unsigned.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1866
void InterpreterMacroAssembler::increment_invocation_counter(Register Rcounters, Register RctrSum) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1867
  assert(UseCompiler || LogTouchedMethods, "incrementing must be useful");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1868
  assert_different_registers(Rcounters, RctrSum);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1869
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1870
  int increment          = InvocationCounter::count_increment;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1871
  int inv_counter_offset = in_bytes(MethodCounters::invocation_counter_offset() + InvocationCounter::counter_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1872
  int be_counter_offset  = in_bytes(MethodCounters::backedge_counter_offset()   + InvocationCounter::counter_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1873
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1874
  BLOCK_COMMENT("Increment invocation counter {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1875
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1876
  if (VM_Version::has_MemWithImmALUOps() && Immediate::is_simm8(increment)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1877
    // Increment the invocation counter in place,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1878
    // then add the incremented value to the backedge counter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1879
    z_l(RctrSum, be_counter_offset, Rcounters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1880
    z_alsi(inv_counter_offset, Rcounters, increment);     // Atomic increment @no extra cost!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1881
    z_nilf(RctrSum, InvocationCounter::count_mask_value); // Mask off state bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1882
    z_al(RctrSum, inv_counter_offset, Z_R0, Rcounters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1883
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1884
    // This path is optimized for low register consumption
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1885
    // at the cost of somewhat higher operand delays.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1886
    // It does not need an extra temp register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1887
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1888
    // Update the invocation counter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1889
    z_l(RctrSum, inv_counter_offset, Rcounters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1890
    if (RctrSum == Z_R0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1891
      z_ahi(RctrSum, increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1892
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1893
      add2reg(RctrSum, increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1894
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1895
    z_st(RctrSum, inv_counter_offset, Rcounters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1896
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1897
    // Mask off the state bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1898
    z_nilf(RctrSum, InvocationCounter::count_mask_value);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1899
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1900
    // Add the backedge counter to the updated invocation counter to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1901
    // form the result.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1902
    z_al(RctrSum, be_counter_offset, Z_R0, Rcounters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1903
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1904
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1905
  BLOCK_COMMENT("} Increment invocation counter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1906
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1907
  // Note that this macro must leave the backedge_count + invocation_count in Rtmp!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1908
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1909
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1910
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1911
// increment backedge counter in MethodCounters object.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1912
// return (invocation_counter+backedge_counter) as "result" in RctrSum
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1913
// counter values are all unsigned!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1914
void InterpreterMacroAssembler::increment_backedge_counter(Register Rcounters, Register RctrSum) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1915
  assert(UseCompiler, "incrementing must be useful");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1916
  assert_different_registers(Rcounters, RctrSum);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1917
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1918
  int increment          = InvocationCounter::count_increment;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1919
  int inv_counter_offset = in_bytes(MethodCounters::invocation_counter_offset() + InvocationCounter::counter_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1920
  int be_counter_offset  = in_bytes(MethodCounters::backedge_counter_offset()   + InvocationCounter::counter_offset());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1921
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1922
  BLOCK_COMMENT("Increment backedge counter {");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1923
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1924
  if (VM_Version::has_MemWithImmALUOps() && Immediate::is_simm8(increment)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1925
    // Increment the invocation counter in place,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1926
    // then add the incremented value to the backedge counter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1927
    z_l(RctrSum, inv_counter_offset, Rcounters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1928
    z_alsi(be_counter_offset, Rcounters, increment);      // Atomic increment @no extra cost!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1929
    z_nilf(RctrSum, InvocationCounter::count_mask_value); // Mask off state bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1930
    z_al(RctrSum, be_counter_offset, Z_R0, Rcounters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1931
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1932
    // This path is optimized for low register consumption
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1933
    // at the cost of somewhat higher operand delays.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1934
    // It does not need an extra temp register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1935
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1936
    // Update the invocation counter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1937
    z_l(RctrSum, be_counter_offset, Rcounters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1938
    if (RctrSum == Z_R0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1939
      z_ahi(RctrSum, increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1940
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1941
      add2reg(RctrSum, increment);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1942
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1943
    z_st(RctrSum, be_counter_offset, Rcounters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1944
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1945
    // Mask off the state bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1946
    z_nilf(RctrSum, InvocationCounter::count_mask_value);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1947
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1948
    // Add the backedge counter to the updated invocation counter to
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1949
    // form the result.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1950
    z_al(RctrSum, inv_counter_offset, Z_R0, Rcounters);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1951
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1952
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1953
  BLOCK_COMMENT("} Increment backedge counter");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1954
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1955
  // Note that this macro must leave the backedge_count + invocation_count in Rtmp!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1956
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1957
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1958
// Add an InterpMonitorElem to stack (see frame_s390.hpp).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1959
void InterpreterMacroAssembler::add_monitor_to_stack(bool     stack_is_empty,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1960
                                                     Register Rtemp1,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1961
                                                     Register Rtemp2,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1962
                                                     Register Rtemp3) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1963
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1964
  const Register Rcurr_slot = Rtemp1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1965
  const Register Rlimit     = Rtemp2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1966
  const jint delta = -frame::interpreter_frame_monitor_size() * wordSize;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1967
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1968
  assert((delta & LongAlignmentMask) == 0,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1969
         "sizeof BasicObjectLock must be even number of doublewords");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1970
  assert(2 * wordSize == -delta, "this works only as long as delta == -2*wordSize");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1971
  assert(Rcurr_slot != Z_R0, "Register must be usable as base register");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1972
  assert_different_registers(Rlimit, Rcurr_slot, Rtemp3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1973
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1974
  get_monitors(Rlimit);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1975
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1976
  // Adjust stack pointer for additional monitor entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1977
  resize_frame(RegisterOrConstant((intptr_t) delta), Z_fp, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1978
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1979
  if (!stack_is_empty) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1980
    // Must copy stack contents down.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1981
    NearLabel next, done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1982
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1983
    // Rtemp := addr(Tos), Z_esp is pointing below it!
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1984
    add2reg(Rcurr_slot, wordSize, Z_esp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1985
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1986
    // Nothing to do, if already at monitor area.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1987
    compareU64_and_branch(Rcurr_slot, Rlimit, bcondNotLow, done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1988
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1989
    bind(next);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1990
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1991
    // Move one stack slot.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1992
    mem2reg_opt(Rtemp3, Address(Rcurr_slot));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1993
    reg2mem_opt(Rtemp3, Address(Rcurr_slot, delta));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1994
    add2reg(Rcurr_slot, wordSize);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1995
    compareU64_and_branch(Rcurr_slot, Rlimit, bcondLow, next); // Are we done?
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1996
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1997
    bind(done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1998
    // Done copying stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1999
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2000
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2001
  // Adjust expression stack and monitor pointers.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2002
  add2reg(Z_esp, delta);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2003
  add2reg(Rlimit, delta);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2004
  save_monitors(Rlimit);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2005
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2006
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2007
// Note: Index holds the offset in bytes afterwards.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2008
// You can use this to store a new value (with Llocals as the base).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2009
void InterpreterMacroAssembler::access_local_int(Register index, Register dst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2010
  z_sllg(index, index, LogBytesPerWord);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2011
  mem2reg_opt(dst, Address(Z_locals, index), false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2012
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2013
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2014
void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2015
  if (state == atos) { MacroAssembler::verify_oop(reg); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2016
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2017
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2018
// Inline assembly for:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2019
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2020
// if (thread is in interp_only_mode) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2021
//   InterpreterRuntime::post_method_entry();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2022
// }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2023
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2024
void InterpreterMacroAssembler::notify_method_entry() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2025
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2026
  // JVMTI
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2027
  // Whenever JVMTI puts a thread in interp_only_mode, method
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2028
  // entry/exit events are sent for that thread to track stack
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2029
  // depth. If it is possible to enter interp_only_mode we add
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2030
  // the code to check if the event should be sent.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2031
  if (JvmtiExport::can_post_interpreter_events()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2032
    Label jvmti_post_done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2033
    MacroAssembler::load_and_test_int(Z_R0, Address(Z_thread, JavaThread::interp_only_mode_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2034
    z_bre(jvmti_post_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2035
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_entry), /*check_exceptions=*/false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2036
    bind(jvmti_post_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2037
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2038
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2039
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2040
// Inline assembly for:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2041
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2042
// if (thread is in interp_only_mode) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2043
//   if (!native_method) save result
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2044
//   InterpreterRuntime::post_method_exit();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2045
//   if (!native_method) restore result
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2046
// }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2047
// if (DTraceMethodProbes) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2048
//   SharedRuntime::dtrace_method_exit(thread, method);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2049
// }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2050
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2051
// For native methods their result is stored in z_ijava_state.lresult
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2052
// and z_ijava_state.fresult before coming here.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2053
// Java methods have their result stored in the expression stack.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2054
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2055
// Notice the dependency to frame::interpreter_frame_result().
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2056
void InterpreterMacroAssembler::notify_method_exit(bool native_method,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2057
                                                   TosState state,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2058
                                                   NotifyMethodExitMode mode) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2059
  // JVMTI
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2060
  // Whenever JVMTI puts a thread in interp_only_mode, method
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2061
  // entry/exit events are sent for that thread to track stack
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2062
  // depth. If it is possible to enter interp_only_mode we add
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2063
  // the code to check if the event should be sent.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2064
  if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2065
    Label jvmti_post_done;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2066
    MacroAssembler::load_and_test_int(Z_R0, Address(Z_thread, JavaThread::interp_only_mode_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2067
    z_bre(jvmti_post_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2068
    if (!native_method) push(state); // see frame::interpreter_frame_result()
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2069
    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit), /*check_exceptions=*/false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2070
    if (!native_method) pop(state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2071
    bind(jvmti_post_done);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2072
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2073
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2074
#if 0
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2075
  // Dtrace currently not supported on z/Architecture.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2076
  {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2077
    SkipIfEqual skip(this, &DTraceMethodProbes, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2078
    push(state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2079
    get_method(c_rarg1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2080
    call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2081
                 r15_thread, c_rarg1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2082
    pop(state);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2083
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2084
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2085
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2086
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2087
void InterpreterMacroAssembler::skip_if_jvmti_mode(Label &Lskip, Register Rscratch) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2088
  if (!JvmtiExport::can_post_interpreter_events()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2089
    return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2090
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2091
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2092
  load_and_test_int(Rscratch, Address(Z_thread, JavaThread::interp_only_mode_offset()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2093
  z_brnz(Lskip);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2094
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2095
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2096
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2097
// Pop the topmost TOP_IJAVA_FRAME and set it's sender_sp as new Z_SP.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2098
// The return pc is loaded into the register return_pc.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2099
//
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2100
// Registers updated:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2101
//     return_pc  - The return pc of the calling frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2102
//     tmp1, tmp2 - scratch
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2103
void InterpreterMacroAssembler::pop_interpreter_frame(Register return_pc, Register tmp1, Register tmp2) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2104
  // F0  Z_SP -> caller_sp (F1's)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2105
  //             ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2106
  //             sender_sp (F1's)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2107
  //             ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2108
  // F1  Z_fp -> caller_sp (F2's)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2109
  //             return_pc (Continuation after return from F0.)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2110
  //             ...
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2111
  // F2          caller_sp
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2112
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2113
  // Remove F0's activation. Restoring Z_SP to sender_sp reverts modifications
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2114
  // (a) by a c2i adapter and (b) by generate_fixed_frame().
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2115
  // In case (a) the new top frame F1 is an unextended compiled frame.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2116
  // In case (b) F1 is converted from PARENT_IJAVA_FRAME to TOP_IJAVA_FRAME.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2117
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2118
  // Case (b) seems to be redundant when returning to a interpreted caller,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2119
  // because then the caller's top_frame_sp is installed as sp (see
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2120
  // TemplateInterpreterGenerator::generate_return_entry_for ()). But
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2121
  // pop_interpreter_frame() is also used in exception handling and there the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2122
  // frame type of the caller is unknown, therefore top_frame_sp cannot be used,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2123
  // so it is important that sender_sp is the caller's sp as TOP_IJAVA_FRAME.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2124
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2125
  Register R_f1_sender_sp = tmp1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2126
  Register R_f2_sp = tmp2;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2127
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2128
  // Tirst check the for the interpreter frame's magic.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2129
  asm_assert_ijava_state_magic(R_f2_sp/*tmp*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2130
  z_lg(R_f2_sp, _z_parent_ijava_frame_abi(callers_sp), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2131
  z_lg(R_f1_sender_sp, _z_ijava_state_neg(sender_sp), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2132
  if (return_pc->is_valid())
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2133
    z_lg(return_pc, _z_parent_ijava_frame_abi(return_pc), Z_fp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2134
  // Pop F0 by resizing to R_f1_sender_sp and using R_f2_sp as fp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2135
  resize_frame_absolute(R_f1_sender_sp, R_f2_sp, false/*load fp*/);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2136
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2137
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2138
  // The return_pc in the new top frame is dead... at least that's my
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2139
  // current understanding; to assert this I overwrite it.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2140
  load_const_optimized(Z_ARG3, 0xb00b1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2141
  z_stg(Z_ARG3, _z_parent_ijava_frame_abi(return_pc), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2142
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2143
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2144
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2145
void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2146
  if (VerifyFPU) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2147
    unimplemented("verfiyFPU");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2148
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2149
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  2150