src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
author coleenp
Fri, 16 Mar 2018 09:12:13 -0400
changeset 49449 ef5d5d343e2a
parent 49376 7cd503c499a0
child 49455 848864ed9b17
permissions -rw-r--r--
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files Summary: interfaceSupport.hpp is an inline file so moved to interfaceSupport.inline.hpp and stopped including it in .hpp files Reviewed-by: stefank, rehn, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     1
/*
48626
9f6f48d4f9a1 8194814: [ppc, s390] A row of minor fixes and cleanups
goetz
parents: 48476
diff changeset
     2
 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
49376
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
     3
 * Copyright (c) 2012, 2018, SAP SE. All rights reserved.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     5
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     9
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    14
 * accompanied this code).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    15
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    19
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    22
 * questions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    23
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    24
 */
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    25
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    26
#include "precompiled.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    28
#include "compiler/disassembler.hpp"
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
    29
#include "gc/shared/cardTable.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30303
diff changeset
    30
#include "gc/shared/cardTableModRefBS.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30303
diff changeset
    31
#include "gc/shared/collectedHeap.inline.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    32
#include "interpreter/interpreter.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    33
#include "memory/resourceArea.hpp"
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
    34
#include "nativeInst_ppc.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    35
#include "prims/methodHandles.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    36
#include "runtime/biasedLocking.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 25374
diff changeset
    37
#include "runtime/icache.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49376
diff changeset
    38
#include "runtime/interfaceSupport.inline.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    39
#include "runtime/objectMonitor.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    40
#include "runtime/os.hpp"
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
    41
#include "runtime/safepoint.hpp"
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
    42
#include "runtime/safepointMechanism.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    43
#include "runtime/sharedRuntime.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    44
#include "runtime/stubRoutines.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    45
#include "utilities/macros.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    46
#if INCLUDE_ALL_GCS
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    47
#include "gc/g1/g1BarrierSet.hpp"
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
    48
#include "gc/g1/g1CardTable.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30303
diff changeset
    49
#include "gc/g1/g1CollectedHeap.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30303
diff changeset
    50
#include "gc/g1/heapRegion.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    51
#endif // INCLUDE_ALL_GCS
36303
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
    52
#ifdef COMPILER2
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
    53
#include "opto/intrinsicnode.hpp"
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
    54
#endif
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    55
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    56
#ifdef PRODUCT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    57
#define BLOCK_COMMENT(str) // nothing
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    58
#else
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    59
#define BLOCK_COMMENT(str) block_comment(str)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    60
#endif
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
    61
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    62
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    63
#ifdef ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    64
// On RISC, there's no benefit to verifying instruction boundaries.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    65
bool AbstractAssembler::pd_check_instruction_mark() { return false; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    66
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    67
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    68
void MacroAssembler::ld_largeoffset_unchecked(Register d, int si31, Register a, int emit_filler_nop) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    69
  assert(Assembler::is_simm(si31, 31) && si31 >= 0, "si31 out of range");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    70
  if (Assembler::is_simm(si31, 16)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    71
    ld(d, si31, a);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    72
    if (emit_filler_nop) nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    73
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    74
    const int hi = MacroAssembler::largeoffset_si16_si16_hi(si31);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    75
    const int lo = MacroAssembler::largeoffset_si16_si16_lo(si31);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    76
    addis(d, a, hi);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    77
    ld(d, lo, d);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    78
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    79
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    80
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    81
void MacroAssembler::ld_largeoffset(Register d, int si31, Register a, int emit_filler_nop) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    82
  assert_different_registers(d, a);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    83
  ld_largeoffset_unchecked(d, si31, a, emit_filler_nop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    84
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    85
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    86
void MacroAssembler::load_sized_value(Register dst, RegisterOrConstant offs, Register base,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    87
                                      size_t size_in_bytes, bool is_signed) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    88
  switch (size_in_bytes) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    89
  case  8:              ld(dst, offs, base);                         break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    90
  case  4:  is_signed ? lwa(dst, offs, base) : lwz(dst, offs, base); break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    91
  case  2:  is_signed ? lha(dst, offs, base) : lhz(dst, offs, base); break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    92
  case  1:  lbz(dst, offs, base); if (is_signed) extsb(dst, dst);    break; // lba doesn't exist :(
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    93
  default:  ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    94
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    95
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    96
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    97
void MacroAssembler::store_sized_value(Register dst, RegisterOrConstant offs, Register base,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    98
                                       size_t size_in_bytes) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    99
  switch (size_in_bytes) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   100
  case  8:  std(dst, offs, base); break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   101
  case  4:  stw(dst, offs, base); break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   102
  case  2:  sth(dst, offs, base); break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   103
  case  1:  stb(dst, offs, base); break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   104
  default:  ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   105
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   106
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   107
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   108
void MacroAssembler::align(int modulus, int max, int rem) {
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   109
  int padding = (rem + modulus - (offset() % modulus)) % modulus;
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   110
  if (padding > max) return;
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   111
  for (int c = (padding >> 2); c > 0; --c) { nop(); }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   112
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   113
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   114
// Issue instructions that calculate given TOC from global TOC.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   115
void MacroAssembler::calculate_address_from_global_toc(Register dst, address addr, bool hi16, bool lo16,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   116
                                                       bool add_relocation, bool emit_dummy_addr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   117
  int offset = -1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   118
  if (emit_dummy_addr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   119
    offset = -128; // dummy address
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   120
  } else if (addr != (address)(intptr_t)-1) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   121
    offset = MacroAssembler::offset_to_global_toc(addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   122
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   123
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   124
  if (hi16) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   125
    addis(dst, R29_TOC, MacroAssembler::largeoffset_si16_si16_hi(offset));
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   126
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   127
  if (lo16) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   128
    if (add_relocation) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   129
      // Relocate at the addi to avoid confusion with a load from the method's TOC.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   130
      relocate(internal_word_Relocation::spec(addr));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   131
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   132
    addi(dst, dst, MacroAssembler::largeoffset_si16_si16_lo(offset));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   133
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   134
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   135
47520
50790528dd25 8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents: 47216
diff changeset
   136
address MacroAssembler::patch_calculate_address_from_global_toc_at(address a, address bound, address addr) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   137
  const int offset = MacroAssembler::offset_to_global_toc(addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   138
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   139
  const address inst2_addr = a;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   140
  const int inst2 = *(int *)inst2_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   141
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   142
  // The relocation points to the second instruction, the addi,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   143
  // and the addi reads and writes the same register dst.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   144
  const int dst = inv_rt_field(inst2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   145
  assert(is_addi(inst2) && inv_ra_field(inst2) == dst, "must be addi reading and writing dst");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   146
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   147
  // Now, find the preceding addis which writes to dst.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   148
  int inst1 = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   149
  address inst1_addr = inst2_addr - BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   150
  while (inst1_addr >= bound) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   151
    inst1 = *(int *) inst1_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   152
    if (is_addis(inst1) && inv_rt_field(inst1) == dst) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   153
      // Stop, found the addis which writes dst.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   154
      break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   155
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   156
    inst1_addr -= BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   157
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   158
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   159
  assert(is_addis(inst1) && inv_ra_field(inst1) == 29 /* R29 */, "source must be global TOC");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   160
  set_imm((int *)inst1_addr, MacroAssembler::largeoffset_si16_si16_hi(offset));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   161
  set_imm((int *)inst2_addr, MacroAssembler::largeoffset_si16_si16_lo(offset));
47520
50790528dd25 8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents: 47216
diff changeset
   162
  return inst1_addr;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   163
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   164
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   165
address MacroAssembler::get_address_of_calculate_address_from_global_toc_at(address a, address bound) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   166
  const address inst2_addr = a;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   167
  const int inst2 = *(int *)inst2_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   168
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   169
  // The relocation points to the second instruction, the addi,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   170
  // and the addi reads and writes the same register dst.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   171
  const int dst = inv_rt_field(inst2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   172
  assert(is_addi(inst2) && inv_ra_field(inst2) == dst, "must be addi reading and writing dst");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   173
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   174
  // Now, find the preceding addis which writes to dst.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   175
  int inst1 = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   176
  address inst1_addr = inst2_addr - BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   177
  while (inst1_addr >= bound) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   178
    inst1 = *(int *) inst1_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   179
    if (is_addis(inst1) && inv_rt_field(inst1) == dst) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   180
      // stop, found the addis which writes dst
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   181
      break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   182
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   183
    inst1_addr -= BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   184
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   185
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   186
  assert(is_addis(inst1) && inv_ra_field(inst1) == 29 /* R29 */, "source must be global TOC");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   187
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   188
  int offset = (get_imm(inst1_addr, 0) << 16) + get_imm(inst2_addr, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   189
  // -1 is a special case
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   190
  if (offset == -1) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   191
    return (address)(intptr_t)-1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   192
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   193
    return global_toc() + offset;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   194
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   195
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   196
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   197
#ifdef _LP64
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   198
// Patch compressed oops or klass constants.
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   199
// Assembler sequence is
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   200
// 1) compressed oops:
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   201
//    lis  rx = const.hi
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   202
//    ori rx = rx | const.lo
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   203
// 2) compressed klass:
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   204
//    lis  rx = const.hi
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   205
//    clrldi rx = rx & 0xFFFFffff // clearMS32b, optional
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   206
//    ori rx = rx | const.lo
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   207
// Clrldi will be passed by.
47520
50790528dd25 8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents: 47216
diff changeset
   208
address MacroAssembler::patch_set_narrow_oop(address a, address bound, narrowOop data) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   209
  assert(UseCompressedOops, "Should only patch compressed oops");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   210
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   211
  const address inst2_addr = a;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   212
  const int inst2 = *(int *)inst2_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   213
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   214
  // The relocation points to the second instruction, the ori,
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   215
  // and the ori reads and writes the same register dst.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   216
  const int dst = inv_rta_field(inst2);
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
   217
  assert(is_ori(inst2) && inv_rs_field(inst2) == dst, "must be ori reading and writing dst");
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   218
  // Now, find the preceding addis which writes to dst.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   219
  int inst1 = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   220
  address inst1_addr = inst2_addr - BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   221
  bool inst1_found = false;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   222
  while (inst1_addr >= bound) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   223
    inst1 = *(int *)inst1_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   224
    if (is_lis(inst1) && inv_rs_field(inst1) == dst) { inst1_found = true; break; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   225
    inst1_addr -= BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   226
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   227
  assert(inst1_found, "inst is not lis");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   228
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   229
  int xc = (data >> 16) & 0xffff;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   230
  int xd = (data >>  0) & 0xffff;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   231
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   232
  set_imm((int *)inst1_addr, (short)(xc)); // see enc_load_con_narrow_hi/_lo
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
   233
  set_imm((int *)inst2_addr,        (xd)); // unsigned int
47520
50790528dd25 8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents: 47216
diff changeset
   234
  return inst1_addr;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   235
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   236
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   237
// Get compressed oop or klass constant.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   238
narrowOop MacroAssembler::get_narrow_oop(address a, address bound) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   239
  assert(UseCompressedOops, "Should only patch compressed oops");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   240
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   241
  const address inst2_addr = a;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   242
  const int inst2 = *(int *)inst2_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   243
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   244
  // The relocation points to the second instruction, the ori,
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   245
  // and the ori reads and writes the same register dst.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   246
  const int dst = inv_rta_field(inst2);
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
   247
  assert(is_ori(inst2) && inv_rs_field(inst2) == dst, "must be ori reading and writing dst");
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   248
  // Now, find the preceding lis which writes to dst.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   249
  int inst1 = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   250
  address inst1_addr = inst2_addr - BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   251
  bool inst1_found = false;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   252
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   253
  while (inst1_addr >= bound) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   254
    inst1 = *(int *) inst1_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   255
    if (is_lis(inst1) && inv_rs_field(inst1) == dst) { inst1_found = true; break;}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   256
    inst1_addr -= BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   257
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   258
  assert(inst1_found, "inst is not lis");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   259
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   260
  uint xl = ((unsigned int) (get_imm(inst2_addr, 0) & 0xffff));
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   261
  uint xh = (((get_imm(inst1_addr, 0)) & 0xffff) << 16);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   262
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   263
  return (int) (xl | xh);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   264
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   265
#endif // _LP64
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   266
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   267
// Returns true if successful.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   268
bool MacroAssembler::load_const_from_method_toc(Register dst, AddressLiteral& a,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   269
                                                Register toc, bool fixed_size) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   270
  int toc_offset = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   271
  // Use RelocationHolder::none for the constant pool entry, otherwise
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   272
  // we will end up with a failing NativeCall::verify(x) where x is
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   273
  // the address of the constant pool entry.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   274
  // FIXME: We should insert relocation information for oops at the constant
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   275
  // pool entries instead of inserting it at the loads; patching of a constant
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   276
  // pool entry should be less expensive.
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   277
  address const_address = address_constant((address)a.value(), RelocationHolder::none);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   278
  if (const_address == NULL) { return false; } // allocation failure
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   279
  // Relocate at the pc of the load.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   280
  relocate(a.rspec());
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   281
  toc_offset = (int)(const_address - code()->consts()->start());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   282
  ld_largeoffset_unchecked(dst, toc_offset, toc, fixed_size);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   283
  return true;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   284
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   285
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   286
bool MacroAssembler::is_load_const_from_method_toc_at(address a) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   287
  const address inst1_addr = a;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   288
  const int inst1 = *(int *)inst1_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   289
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   290
   // The relocation points to the ld or the addis.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   291
   return (is_ld(inst1)) ||
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   292
          (is_addis(inst1) && inv_ra_field(inst1) != 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   293
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   294
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   295
int MacroAssembler::get_offset_of_load_const_from_method_toc_at(address a) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   296
  assert(is_load_const_from_method_toc_at(a), "must be load_const_from_method_toc");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   297
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   298
  const address inst1_addr = a;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   299
  const int inst1 = *(int *)inst1_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   300
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   301
  if (is_ld(inst1)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   302
    return inv_d1_field(inst1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   303
  } else if (is_addis(inst1)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   304
    const int dst = inv_rt_field(inst1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   305
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   306
    // Now, find the succeeding ld which reads and writes to dst.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   307
    address inst2_addr = inst1_addr + BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   308
    int inst2 = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   309
    while (true) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   310
      inst2 = *(int *) inst2_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   311
      if (is_ld(inst2) && inv_ra_field(inst2) == dst && inv_rt_field(inst2) == dst) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   312
        // Stop, found the ld which reads and writes dst.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   313
        break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   314
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   315
      inst2_addr += BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   316
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   317
    return (inv_d1_field(inst1) << 16) + inv_d1_field(inst2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   318
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   319
  ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   320
  return 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   321
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   322
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   323
// Get the constant from a `load_const' sequence.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   324
long MacroAssembler::get_const(address a) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   325
  assert(is_load_const_at(a), "not a load of a constant");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   326
  const int *p = (const int*) a;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   327
  unsigned long x = (((unsigned long) (get_imm(a,0) & 0xffff)) << 48);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   328
  if (is_ori(*(p+1))) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   329
    x |= (((unsigned long) (get_imm(a,1) & 0xffff)) << 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   330
    x |= (((unsigned long) (get_imm(a,3) & 0xffff)) << 16);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   331
    x |= (((unsigned long) (get_imm(a,4) & 0xffff)));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   332
  } else if (is_lis(*(p+1))) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   333
    x |= (((unsigned long) (get_imm(a,2) & 0xffff)) << 32);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   334
    x |= (((unsigned long) (get_imm(a,1) & 0xffff)) << 16);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   335
    x |= (((unsigned long) (get_imm(a,3) & 0xffff)));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   336
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   337
    ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   338
    return (long) 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   339
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   340
  return (long) x;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   341
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   342
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   343
// Patch the 64 bit constant of a `load_const' sequence. This is a low
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   344
// level procedure. It neither flushes the instruction cache nor is it
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   345
// mt safe.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   346
void MacroAssembler::patch_const(address a, long x) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   347
  assert(is_load_const_at(a), "not a load of a constant");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   348
  int *p = (int*) a;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   349
  if (is_ori(*(p+1))) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   350
    set_imm(0 + p, (x >> 48) & 0xffff);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   351
    set_imm(1 + p, (x >> 32) & 0xffff);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   352
    set_imm(3 + p, (x >> 16) & 0xffff);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   353
    set_imm(4 + p, x & 0xffff);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   354
  } else if (is_lis(*(p+1))) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   355
    set_imm(0 + p, (x >> 48) & 0xffff);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   356
    set_imm(2 + p, (x >> 32) & 0xffff);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   357
    set_imm(1 + p, (x >> 16) & 0xffff);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   358
    set_imm(3 + p, x & 0xffff);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   359
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   360
    ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   361
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   362
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   363
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   364
AddressLiteral MacroAssembler::allocate_metadata_address(Metadata* obj) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   365
  assert(oop_recorder() != NULL, "this assembler needs a Recorder");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   366
  int index = oop_recorder()->allocate_metadata_index(obj);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   367
  RelocationHolder rspec = metadata_Relocation::spec(index);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   368
  return AddressLiteral((address)obj, rspec);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   369
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   370
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   371
AddressLiteral MacroAssembler::constant_metadata_address(Metadata* obj) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   372
  assert(oop_recorder() != NULL, "this assembler needs a Recorder");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   373
  int index = oop_recorder()->find_index(obj);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   374
  RelocationHolder rspec = metadata_Relocation::spec(index);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   375
  return AddressLiteral((address)obj, rspec);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   376
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   377
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   378
AddressLiteral MacroAssembler::allocate_oop_address(jobject obj) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   379
  assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   380
  int oop_index = oop_recorder()->allocate_oop_index(obj);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   381
  return AddressLiteral(address(obj), oop_Relocation::spec(oop_index));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   382
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   383
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   384
AddressLiteral MacroAssembler::constant_oop_address(jobject obj) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   385
  assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   386
  int oop_index = oop_recorder()->find_index(obj);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   387
  return AddressLiteral(address(obj), oop_Relocation::spec(oop_index));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   388
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   389
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   390
RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_addr,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   391
                                                      Register tmp, int offset) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   392
  intptr_t value = *delayed_value_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   393
  if (value != 0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   394
    return RegisterOrConstant(value + offset);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   395
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   396
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   397
  // Load indirectly to solve generation ordering problem.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   398
  // static address, no relocation
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   399
  int simm16_offset = load_const_optimized(tmp, delayed_value_addr, noreg, true);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   400
  ld(tmp, simm16_offset, tmp); // must be aligned ((xa & 3) == 0)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   401
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   402
  if (offset != 0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   403
    addi(tmp, tmp, offset);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   404
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   405
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   406
  return RegisterOrConstant(tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   407
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   408
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   409
#ifndef PRODUCT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   410
void MacroAssembler::pd_print_patched_instruction(address branch) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   411
  Unimplemented(); // TODO: PPC port
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   412
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   413
#endif // ndef PRODUCT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   414
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   415
// Conditional far branch for destinations encodable in 24+2 bits.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   416
void MacroAssembler::bc_far(int boint, int biint, Label& dest, int optimize) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   417
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   418
  // If requested by flag optimize, relocate the bc_far as a
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   419
  // runtime_call and prepare for optimizing it when the code gets
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   420
  // relocated.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   421
  if (optimize == bc_far_optimize_on_relocate) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   422
    relocate(relocInfo::runtime_call_type);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   423
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   424
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   425
  // variant 2:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   426
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   427
  //    b!cxx SKIP
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   428
  //    bxx   DEST
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   429
  //  SKIP:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   430
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   431
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   432
  const int opposite_boint = add_bhint_to_boint(opposite_bhint(inv_boint_bhint(boint)),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   433
                                                opposite_bcond(inv_boint_bcond(boint)));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   434
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   435
  // We emit two branches.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   436
  // First, a conditional branch which jumps around the far branch.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   437
  const address not_taken_pc = pc() + 2 * BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   438
  const address bc_pc        = pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   439
  bc(opposite_boint, biint, not_taken_pc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   440
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   441
  const int bc_instr = *(int*)bc_pc;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   442
  assert(not_taken_pc == (address)inv_bd_field(bc_instr, (intptr_t)bc_pc), "postcondition");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   443
  assert(opposite_boint == inv_bo_field(bc_instr), "postcondition");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   444
  assert(boint == add_bhint_to_boint(opposite_bhint(inv_boint_bhint(inv_bo_field(bc_instr))),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   445
                                     opposite_bcond(inv_boint_bcond(inv_bo_field(bc_instr)))),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   446
         "postcondition");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   447
  assert(biint == inv_bi_field(bc_instr), "postcondition");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   448
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   449
  // Second, an unconditional far branch which jumps to dest.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   450
  // Note: target(dest) remembers the current pc (see CodeSection::target)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   451
  //       and returns the current pc if the label is not bound yet; when
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   452
  //       the label gets bound, the unconditional far branch will be patched.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   453
  const address target_pc = target(dest);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   454
  const address b_pc  = pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   455
  b(target_pc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   456
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   457
  assert(not_taken_pc == pc(),                     "postcondition");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   458
  assert(dest.is_bound() || target_pc == b_pc, "postcondition");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   459
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   460
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   461
// 1 or 2 instructions
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   462
void MacroAssembler::bc_far_optimized(int boint, int biint, Label& dest) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   463
  if (dest.is_bound() && is_within_range_of_bcxx(target(dest), pc())) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   464
    bc(boint, biint, dest);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   465
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   466
    bc_far(boint, biint, dest, MacroAssembler::bc_far_optimize_on_relocate);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   467
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   468
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   469
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   470
bool MacroAssembler::is_bc_far_at(address instruction_addr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   471
  return is_bc_far_variant1_at(instruction_addr) ||
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   472
         is_bc_far_variant2_at(instruction_addr) ||
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   473
         is_bc_far_variant3_at(instruction_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   474
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   475
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   476
address MacroAssembler::get_dest_of_bc_far_at(address instruction_addr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   477
  if (is_bc_far_variant1_at(instruction_addr)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   478
    const address instruction_1_addr = instruction_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   479
    const int instruction_1 = *(int*)instruction_1_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   480
    return (address)inv_bd_field(instruction_1, (intptr_t)instruction_1_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   481
  } else if (is_bc_far_variant2_at(instruction_addr)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   482
    const address instruction_2_addr = instruction_addr + 4;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   483
    return bxx_destination(instruction_2_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   484
  } else if (is_bc_far_variant3_at(instruction_addr)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   485
    return instruction_addr + 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   486
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   487
  // variant 4 ???
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   488
  ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   489
  return NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   490
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   491
void MacroAssembler::set_dest_of_bc_far_at(address instruction_addr, address dest) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   492
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   493
  if (is_bc_far_variant3_at(instruction_addr)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   494
    // variant 3, far cond branch to the next instruction, already patched to nops:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   495
    //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   496
    //    nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   497
    //    endgroup
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   498
    //  SKIP/DEST:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   499
    //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   500
    return;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   501
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   502
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   503
  // first, extract boint and biint from the current branch
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   504
  int boint = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   505
  int biint = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   506
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   507
  ResourceMark rm;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   508
  const int code_size = 2 * BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   509
  CodeBuffer buf(instruction_addr, code_size);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   510
  MacroAssembler masm(&buf);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   511
  if (is_bc_far_variant2_at(instruction_addr) && dest == instruction_addr + 8) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   512
    // Far branch to next instruction: Optimize it by patching nops (produce variant 3).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   513
    masm.nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   514
    masm.endgroup();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   515
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   516
    if (is_bc_far_variant1_at(instruction_addr)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   517
      // variant 1, the 1st instruction contains the destination address:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   518
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   519
      //    bcxx  DEST
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   520
      //    nop
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   521
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   522
      const int instruction_1 = *(int*)(instruction_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   523
      boint = inv_bo_field(instruction_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   524
      biint = inv_bi_field(instruction_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   525
    } else if (is_bc_far_variant2_at(instruction_addr)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   526
      // variant 2, the 2nd instruction contains the destination address:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   527
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   528
      //    b!cxx SKIP
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   529
      //    bxx   DEST
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   530
      //  SKIP:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   531
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   532
      const int instruction_1 = *(int*)(instruction_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   533
      boint = add_bhint_to_boint(opposite_bhint(inv_boint_bhint(inv_bo_field(instruction_1))),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   534
          opposite_bcond(inv_boint_bcond(inv_bo_field(instruction_1))));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   535
      biint = inv_bi_field(instruction_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   536
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   537
      // variant 4???
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   538
      ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   539
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   540
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   541
    // second, set the new branch destination and optimize the code
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   542
    if (dest != instruction_addr + 4 && // the bc_far is still unbound!
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   543
        masm.is_within_range_of_bcxx(dest, instruction_addr)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   544
      // variant 1:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   545
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   546
      //    bcxx  DEST
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   547
      //    nop
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   548
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   549
      masm.bc(boint, biint, dest);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   550
      masm.nop();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   551
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   552
      // variant 2:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   553
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   554
      //    b!cxx SKIP
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   555
      //    bxx   DEST
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   556
      //  SKIP:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   557
      //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   558
      const int opposite_boint = add_bhint_to_boint(opposite_bhint(inv_boint_bhint(boint)),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   559
                                                    opposite_bcond(inv_boint_bcond(boint)));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   560
      const address not_taken_pc = masm.pc() + 2 * BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   561
      masm.bc(opposite_boint, biint, not_taken_pc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   562
      masm.b(dest);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   563
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   564
  }
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   565
  ICache::ppc64_flush_icache_bytes(instruction_addr, code_size);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   566
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   567
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   568
// Emit a NOT mt-safe patchable 64 bit absolute call/jump.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   569
void MacroAssembler::bxx64_patchable(address dest, relocInfo::relocType rt, bool link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   570
  // get current pc
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   571
  uint64_t start_pc = (uint64_t) pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   572
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   573
  const address pc_of_bl = (address) (start_pc + (6*BytesPerInstWord)); // bl is last
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   574
  const address pc_of_b  = (address) (start_pc + (0*BytesPerInstWord)); // b is first
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   575
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   576
  // relocate here
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   577
  if (rt != relocInfo::none) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   578
    relocate(rt);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   579
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   580
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   581
  if ( ReoptimizeCallSequences &&
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   582
       (( link && is_within_range_of_b(dest, pc_of_bl)) ||
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   583
        (!link && is_within_range_of_b(dest, pc_of_b)))) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   584
    // variant 2:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   585
    // Emit an optimized, pc-relative call/jump.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   586
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   587
    if (link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   588
      // some padding
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   589
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   590
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   591
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   592
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   593
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   594
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   595
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   596
      // do the call
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   597
      assert(pc() == pc_of_bl, "just checking");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   598
      bl(dest, relocInfo::none);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   599
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   600
      // do the jump
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   601
      assert(pc() == pc_of_b, "just checking");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   602
      b(dest, relocInfo::none);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   603
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   604
      // some padding
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   605
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   606
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   607
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   608
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   609
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   610
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   611
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   612
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   613
    // Assert that we can identify the emitted call/jump.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   614
    assert(is_bxx64_patchable_variant2_at((address)start_pc, link),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   615
           "can't identify emitted call");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   616
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   617
    // variant 1:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   618
    mr(R0, R11);  // spill R11 -> R0.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   619
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   620
    // Load the destination address into CTR,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   621
    // calculate destination relative to global toc.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   622
    calculate_address_from_global_toc(R11, dest, true, true, false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   623
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   624
    mtctr(R11);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   625
    mr(R11, R0);  // spill R11 <- R0.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   626
    nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   627
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   628
    // do the call/jump
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   629
    if (link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   630
      bctrl();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   631
    } else{
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   632
      bctr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   633
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   634
    // Assert that we can identify the emitted call/jump.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   635
    assert(is_bxx64_patchable_variant1b_at((address)start_pc, link),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   636
           "can't identify emitted call");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   637
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   638
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   639
  // Assert that we can identify the emitted call/jump.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   640
  assert(is_bxx64_patchable_at((address)start_pc, link),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   641
         "can't identify emitted call");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   642
  assert(get_dest_of_bxx64_patchable_at((address)start_pc, link) == dest,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   643
         "wrong encoding of dest address");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   644
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   645
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   646
// Identify a bxx64_patchable instruction.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   647
bool MacroAssembler::is_bxx64_patchable_at(address instruction_addr, bool link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   648
  return is_bxx64_patchable_variant1b_at(instruction_addr, link)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   649
    //|| is_bxx64_patchable_variant1_at(instruction_addr, link)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   650
      || is_bxx64_patchable_variant2_at(instruction_addr, link);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   651
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   652
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   653
// Does the call64_patchable instruction use a pc-relative encoding of
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   654
// the call destination?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   655
bool MacroAssembler::is_bxx64_patchable_pcrelative_at(address instruction_addr, bool link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   656
  // variant 2 is pc-relative
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   657
  return is_bxx64_patchable_variant2_at(instruction_addr, link);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   658
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   659
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   660
// Identify variant 1.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   661
bool MacroAssembler::is_bxx64_patchable_variant1_at(address instruction_addr, bool link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   662
  unsigned int* instr = (unsigned int*) instruction_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   663
  return (link ? is_bctrl(instr[6]) : is_bctr(instr[6])) // bctr[l]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   664
      && is_mtctr(instr[5]) // mtctr
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   665
    && is_load_const_at(instruction_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   666
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   667
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   668
// Identify variant 1b: load destination relative to global toc.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   669
bool MacroAssembler::is_bxx64_patchable_variant1b_at(address instruction_addr, bool link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   670
  unsigned int* instr = (unsigned int*) instruction_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   671
  return (link ? is_bctrl(instr[6]) : is_bctr(instr[6])) // bctr[l]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   672
    && is_mtctr(instr[3]) // mtctr
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   673
    && is_calculate_address_from_global_toc_at(instruction_addr + 2*BytesPerInstWord, instruction_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   674
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   675
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   676
// Identify variant 2.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   677
bool MacroAssembler::is_bxx64_patchable_variant2_at(address instruction_addr, bool link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   678
  unsigned int* instr = (unsigned int*) instruction_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   679
  if (link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   680
    return is_bl (instr[6])  // bl dest is last
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   681
      && is_nop(instr[0])  // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   682
      && is_nop(instr[1])  // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   683
      && is_nop(instr[2])  // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   684
      && is_nop(instr[3])  // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   685
      && is_nop(instr[4])  // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   686
      && is_nop(instr[5]); // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   687
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   688
    return is_b  (instr[0])  // b  dest is first
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   689
      && is_nop(instr[1])  // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   690
      && is_nop(instr[2])  // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   691
      && is_nop(instr[3])  // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   692
      && is_nop(instr[4])  // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   693
      && is_nop(instr[5])  // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   694
      && is_nop(instr[6]); // nop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   695
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   696
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   697
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   698
// Set dest address of a bxx64_patchable instruction.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   699
void MacroAssembler::set_dest_of_bxx64_patchable_at(address instruction_addr, address dest, bool link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   700
  ResourceMark rm;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   701
  int code_size = MacroAssembler::bxx64_patchable_size;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   702
  CodeBuffer buf(instruction_addr, code_size);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   703
  MacroAssembler masm(&buf);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   704
  masm.bxx64_patchable(dest, relocInfo::none, link);
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
   705
  ICache::ppc64_flush_icache_bytes(instruction_addr, code_size);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   706
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   707
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   708
// Get dest address of a bxx64_patchable instruction.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   709
address MacroAssembler::get_dest_of_bxx64_patchable_at(address instruction_addr, bool link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   710
  if (is_bxx64_patchable_variant1_at(instruction_addr, link)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   711
    return (address) (unsigned long) get_const(instruction_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   712
  } else if (is_bxx64_patchable_variant2_at(instruction_addr, link)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   713
    unsigned int* instr = (unsigned int*) instruction_addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   714
    if (link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   715
      const int instr_idx = 6; // bl is last
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   716
      int branchoffset = branch_destination(instr[instr_idx], 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   717
      return instruction_addr + branchoffset + instr_idx*BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   718
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   719
      const int instr_idx = 0; // b is first
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   720
      int branchoffset = branch_destination(instr[instr_idx], 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   721
      return instruction_addr + branchoffset + instr_idx*BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   722
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   723
  // Load dest relative to global toc.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   724
  } else if (is_bxx64_patchable_variant1b_at(instruction_addr, link)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   725
    return get_address_of_calculate_address_from_global_toc_at(instruction_addr + 2*BytesPerInstWord,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   726
                                                               instruction_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   727
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   728
    ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   729
    return NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   730
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   731
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   732
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   733
// Uses ordering which corresponds to ABI:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   734
//    _savegpr0_14:  std  r14,-144(r1)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   735
//    _savegpr0_15:  std  r15,-136(r1)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   736
//    _savegpr0_16:  std  r16,-128(r1)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   737
void MacroAssembler::save_nonvolatile_gprs(Register dst, int offset) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   738
  std(R14, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   739
  std(R15, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   740
  std(R16, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   741
  std(R17, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   742
  std(R18, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   743
  std(R19, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   744
  std(R20, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   745
  std(R21, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   746
  std(R22, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   747
  std(R23, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   748
  std(R24, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   749
  std(R25, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   750
  std(R26, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   751
  std(R27, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   752
  std(R28, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   753
  std(R29, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   754
  std(R30, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   755
  std(R31, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   756
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   757
  stfd(F14, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   758
  stfd(F15, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   759
  stfd(F16, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   760
  stfd(F17, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   761
  stfd(F18, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   762
  stfd(F19, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   763
  stfd(F20, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   764
  stfd(F21, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   765
  stfd(F22, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   766
  stfd(F23, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   767
  stfd(F24, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   768
  stfd(F25, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   769
  stfd(F26, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   770
  stfd(F27, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   771
  stfd(F28, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   772
  stfd(F29, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   773
  stfd(F30, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   774
  stfd(F31, offset, dst);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   775
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   776
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   777
// Uses ordering which corresponds to ABI:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   778
//    _restgpr0_14:  ld   r14,-144(r1)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   779
//    _restgpr0_15:  ld   r15,-136(r1)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   780
//    _restgpr0_16:  ld   r16,-128(r1)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   781
void MacroAssembler::restore_nonvolatile_gprs(Register src, int offset) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   782
  ld(R14, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   783
  ld(R15, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   784
  ld(R16, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   785
  ld(R17, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   786
  ld(R18, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   787
  ld(R19, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   788
  ld(R20, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   789
  ld(R21, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   790
  ld(R22, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   791
  ld(R23, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   792
  ld(R24, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   793
  ld(R25, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   794
  ld(R26, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   795
  ld(R27, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   796
  ld(R28, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   797
  ld(R29, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   798
  ld(R30, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   799
  ld(R31, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   800
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   801
  // FP registers
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   802
  lfd(F14, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   803
  lfd(F15, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   804
  lfd(F16, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   805
  lfd(F17, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   806
  lfd(F18, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   807
  lfd(F19, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   808
  lfd(F20, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   809
  lfd(F21, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   810
  lfd(F22, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   811
  lfd(F23, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   812
  lfd(F24, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   813
  lfd(F25, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   814
  lfd(F26, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   815
  lfd(F27, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   816
  lfd(F28, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   817
  lfd(F29, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   818
  lfd(F30, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   819
  lfd(F31, offset, src);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   820
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   821
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   822
// For verify_oops.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   823
void MacroAssembler::save_volatile_gprs(Register dst, int offset) {
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
   824
  std(R2,  offset, dst);   offset += 8;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   825
  std(R3,  offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   826
  std(R4,  offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   827
  std(R5,  offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   828
  std(R6,  offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   829
  std(R7,  offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   830
  std(R8,  offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   831
  std(R9,  offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   832
  std(R10, offset, dst);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   833
  std(R11, offset, dst);   offset += 8;
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   834
  std(R12, offset, dst);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   835
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   836
  stfd(F0, offset, dst);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   837
  stfd(F1, offset, dst);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   838
  stfd(F2, offset, dst);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   839
  stfd(F3, offset, dst);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   840
  stfd(F4, offset, dst);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   841
  stfd(F5, offset, dst);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   842
  stfd(F6, offset, dst);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   843
  stfd(F7, offset, dst);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   844
  stfd(F8, offset, dst);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   845
  stfd(F9, offset, dst);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   846
  stfd(F10, offset, dst);  offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   847
  stfd(F11, offset, dst);  offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   848
  stfd(F12, offset, dst);  offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   849
  stfd(F13, offset, dst);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   850
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   851
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   852
// For verify_oops.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   853
void MacroAssembler::restore_volatile_gprs(Register src, int offset) {
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
   854
  ld(R2,  offset, src);   offset += 8;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   855
  ld(R3,  offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   856
  ld(R4,  offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   857
  ld(R5,  offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   858
  ld(R6,  offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   859
  ld(R7,  offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   860
  ld(R8,  offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   861
  ld(R9,  offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   862
  ld(R10, offset, src);   offset += 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   863
  ld(R11, offset, src);   offset += 8;
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   864
  ld(R12, offset, src);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   865
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   866
  lfd(F0, offset, src);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   867
  lfd(F1, offset, src);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   868
  lfd(F2, offset, src);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   869
  lfd(F3, offset, src);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   870
  lfd(F4, offset, src);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   871
  lfd(F5, offset, src);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   872
  lfd(F6, offset, src);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   873
  lfd(F7, offset, src);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   874
  lfd(F8, offset, src);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   875
  lfd(F9, offset, src);   offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   876
  lfd(F10, offset, src);  offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   877
  lfd(F11, offset, src);  offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   878
  lfd(F12, offset, src);  offset += 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   879
  lfd(F13, offset, src);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   880
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   881
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   882
void MacroAssembler::save_LR_CR(Register tmp) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   883
  mfcr(tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   884
  std(tmp, _abi(cr), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   885
  mflr(tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   886
  std(tmp, _abi(lr), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   887
  // Tmp must contain lr on exit! (see return_addr and prolog in ppc64.ad)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   888
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   889
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   890
void MacroAssembler::restore_LR_CR(Register tmp) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   891
  assert(tmp != R1_SP, "must be distinct");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   892
  ld(tmp, _abi(lr), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   893
  mtlr(tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   894
  ld(tmp, _abi(cr), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   895
  mtcr(tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   896
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   897
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   898
address MacroAssembler::get_PC_trash_LR(Register result) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   899
  Label L;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   900
  bl(L);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   901
  bind(L);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   902
  address lr_pc = pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   903
  mflr(result);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   904
  return lr_pc;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   905
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   906
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   907
void MacroAssembler::resize_frame(Register offset, Register tmp) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   908
#ifdef ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   909
  assert_different_registers(offset, tmp, R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   910
  andi_(tmp, offset, frame::alignment_in_bytes-1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   911
  asm_assert_eq("resize_frame: unaligned", 0x204);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   912
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   913
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   914
  // tmp <- *(SP)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   915
  ld(tmp, _abi(callers_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   916
  // addr <- SP + offset;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   917
  // *(addr) <- tmp;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   918
  // SP <- addr
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   919
  stdux(tmp, R1_SP, offset);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   920
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   921
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   922
void MacroAssembler::resize_frame(int offset, Register tmp) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   923
  assert(is_simm(offset, 16), "too big an offset");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   924
  assert_different_registers(tmp, R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   925
  assert((offset & (frame::alignment_in_bytes-1))==0, "resize_frame: unaligned");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   926
  // tmp <- *(SP)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   927
  ld(tmp, _abi(callers_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   928
  // addr <- SP + offset;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   929
  // *(addr) <- tmp;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   930
  // SP <- addr
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   931
  stdu(tmp, offset, R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   932
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   933
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   934
void MacroAssembler::resize_frame_absolute(Register addr, Register tmp1, Register tmp2) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   935
  // (addr == tmp1) || (addr == tmp2) is allowed here!
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   936
  assert(tmp1 != tmp2, "must be distinct");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   937
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   938
  // compute offset w.r.t. current stack pointer
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   939
  // tmp_1 <- addr - SP (!)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   940
  subf(tmp1, R1_SP, addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   941
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   942
  // atomically update SP keeping back link.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   943
  resize_frame(tmp1/* offset */, tmp2/* tmp */);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   944
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   945
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   946
void MacroAssembler::push_frame(Register bytes, Register tmp) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   947
#ifdef ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   948
  assert(bytes != R0, "r0 not allowed here");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   949
  andi_(R0, bytes, frame::alignment_in_bytes-1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   950
  asm_assert_eq("push_frame(Reg, Reg): unaligned", 0x203);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   951
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   952
  neg(tmp, bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   953
  stdux(R1_SP, R1_SP, tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   954
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   955
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   956
// Push a frame of size `bytes'.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   957
void MacroAssembler::push_frame(unsigned int bytes, Register tmp) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   958
  long offset = align_addr(bytes, frame::alignment_in_bytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   959
  if (is_simm(-offset, 16)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   960
    stdu(R1_SP, -offset, R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   961
  } else {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
   962
    load_const_optimized(tmp, -offset);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   963
    stdux(R1_SP, R1_SP, tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   964
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   965
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   966
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   967
// Push a frame of size `bytes' plus abi_reg_args on top.
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   968
void MacroAssembler::push_frame_reg_args(unsigned int bytes, Register tmp) {
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   969
  push_frame(bytes + frame::abi_reg_args_size, tmp);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   970
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   971
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   972
// Setup up a new C frame with a spill area for non-volatile GPRs and
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   973
// additional space for local variables.
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   974
void MacroAssembler::push_frame_reg_args_nonvolatiles(unsigned int bytes,
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   975
                                                      Register tmp) {
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   976
  push_frame(bytes + frame::abi_reg_args_size + frame::spill_nonvolatiles_size, tmp);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   977
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   978
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   979
// Pop current C frame.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   980
void MacroAssembler::pop_frame() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   981
  ld(R1_SP, _abi(callers_sp), R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   982
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   983
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   984
#if defined(ABI_ELFv2)
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   985
address MacroAssembler::branch_to(Register r_function_entry, bool and_link) {
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   986
  // TODO(asmundak): make sure the caller uses R12 as function descriptor
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   987
  // most of the times.
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   988
  if (R12 != r_function_entry) {
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   989
    mr(R12, r_function_entry);
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   990
  }
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   991
  mtctr(R12);
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   992
  // Do a call or a branch.
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   993
  if (and_link) {
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   994
    bctrl();
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   995
  } else {
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   996
    bctr();
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   997
  }
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   998
  _last_calls_return_pc = pc();
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
   999
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1000
  return _last_calls_return_pc;
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1001
}
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1002
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1003
// Call a C function via a function descriptor and use full C
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1004
// calling conventions. Updates and returns _last_calls_return_pc.
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1005
address MacroAssembler::call_c(Register r_function_entry) {
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1006
  return branch_to(r_function_entry, /*and_link=*/true);
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1007
}
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1008
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1009
// For tail calls: only branch, don't link, so callee returns to caller of this function.
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1010
address MacroAssembler::call_c_and_return_to_caller(Register r_function_entry) {
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1011
  return branch_to(r_function_entry, /*and_link=*/false);
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1012
}
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1013
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1014
address MacroAssembler::call_c(address function_entry, relocInfo::relocType rt) {
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1015
  load_const(R12, function_entry, R0);
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1016
  return branch_to(R12,  /*and_link=*/true);
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1017
}
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1018
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1019
#else
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1020
// Generic version of a call to C function via a function descriptor
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1021
// with variable support for C calling conventions (TOC, ENV, etc.).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1022
// Updates and returns _last_calls_return_pc.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1023
address MacroAssembler::branch_to(Register function_descriptor, bool and_link, bool save_toc_before_call,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1024
                                  bool restore_toc_after_call, bool load_toc_of_callee, bool load_env_of_callee) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1025
  // we emit standard ptrgl glue code here
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1026
  assert((function_descriptor != R0), "function_descriptor cannot be R0");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1027
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1028
  // retrieve necessary entries from the function descriptor
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1029
  ld(R0, in_bytes(FunctionDescriptor::entry_offset()), function_descriptor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1030
  mtctr(R0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1031
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1032
  if (load_toc_of_callee) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1033
    ld(R2_TOC, in_bytes(FunctionDescriptor::toc_offset()), function_descriptor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1034
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1035
  if (load_env_of_callee) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1036
    ld(R11, in_bytes(FunctionDescriptor::env_offset()), function_descriptor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1037
  } else if (load_toc_of_callee) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1038
    li(R11, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1039
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1040
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1041
  // do a call or a branch
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1042
  if (and_link) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1043
    bctrl();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1044
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1045
    bctr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1046
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1047
  _last_calls_return_pc = pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1048
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1049
  return _last_calls_return_pc;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1050
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1051
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1052
// Call a C function via a function descriptor and use full C calling
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1053
// conventions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1054
// We don't use the TOC in generated code, so there is no need to save
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1055
// and restore its value.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1056
address MacroAssembler::call_c(Register fd) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1057
  return branch_to(fd, /*and_link=*/true,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1058
                       /*save toc=*/false,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1059
                       /*restore toc=*/false,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1060
                       /*load toc=*/true,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1061
                       /*load env=*/true);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1062
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1063
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  1064
address MacroAssembler::call_c_and_return_to_caller(Register fd) {
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  1065
  return branch_to(fd, /*and_link=*/false,
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  1066
                       /*save toc=*/false,
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  1067
                       /*restore toc=*/false,
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  1068
                       /*load toc=*/true,
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  1069
                       /*load env=*/true);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  1070
}
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  1071
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1072
address MacroAssembler::call_c(const FunctionDescriptor* fd, relocInfo::relocType rt) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1073
  if (rt != relocInfo::none) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1074
    // this call needs to be relocatable
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1075
    if (!ReoptimizeCallSequences
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1076
        || (rt != relocInfo::runtime_call_type && rt != relocInfo::none)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1077
        || fd == NULL   // support code-size estimation
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1078
        || !fd->is_friend_function()
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1079
        || fd->entry() == NULL) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1080
      // it's not a friend function as defined by class FunctionDescriptor,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1081
      // so do a full call-c here.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1082
      load_const(R11, (address)fd, R0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1083
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1084
      bool has_env = (fd != NULL && fd->env() != NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1085
      return branch_to(R11, /*and_link=*/true,
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  1086
                            /*save toc=*/false,
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  1087
                            /*restore toc=*/false,
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  1088
                            /*load toc=*/true,
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  1089
                            /*load env=*/has_env);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1090
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1091
      // It's a friend function. Load the entry point and don't care about
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1092
      // toc and env. Use an optimizable call instruction, but ensure the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1093
      // same code-size as in the case of a non-friend function.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1094
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1095
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1096
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1097
      bl64_patchable(fd->entry(), rt);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1098
      _last_calls_return_pc = pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1099
      return _last_calls_return_pc;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1100
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1101
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1102
    // This call does not need to be relocatable, do more aggressive
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1103
    // optimizations.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1104
    if (!ReoptimizeCallSequences
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1105
      || !fd->is_friend_function()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1106
      // It's not a friend function as defined by class FunctionDescriptor,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1107
      // so do a full call-c here.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1108
      load_const(R11, (address)fd, R0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1109
      return branch_to(R11, /*and_link=*/true,
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  1110
                            /*save toc=*/false,
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  1111
                            /*restore toc=*/false,
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  1112
                            /*load toc=*/true,
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  1113
                            /*load env=*/true);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1114
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1115
      // it's a friend function, load the entry point and don't care about
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1116
      // toc and env.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1117
      address dest = fd->entry();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1118
      if (is_within_range_of_b(dest, pc())) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1119
        bl(dest);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1120
      } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1121
        bl64_patchable(dest, rt);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1122
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1123
      _last_calls_return_pc = pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1124
      return _last_calls_return_pc;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1125
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1126
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1127
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1128
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1129
// Call a C function.  All constants needed reside in TOC.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1130
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1131
// Read the address to call from the TOC.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1132
// Read env from TOC, if fd specifies an env.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1133
// Read new TOC from TOC.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1134
address MacroAssembler::call_c_using_toc(const FunctionDescriptor* fd,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1135
                                         relocInfo::relocType rt, Register toc) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1136
  if (!ReoptimizeCallSequences
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1137
    || (rt != relocInfo::runtime_call_type && rt != relocInfo::none)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1138
    || !fd->is_friend_function()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1139
    // It's not a friend function as defined by class FunctionDescriptor,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1140
    // so do a full call-c here.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1141
    assert(fd->entry() != NULL, "function must be linked");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1142
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1143
    AddressLiteral fd_entry(fd->entry());
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1144
    bool success = load_const_from_method_toc(R11, fd_entry, toc, /*fixed_size*/ true);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1145
    mtctr(R11);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1146
    if (fd->env() == NULL) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1147
      li(R11, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1148
      nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1149
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1150
      AddressLiteral fd_env(fd->env());
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1151
      success = success && load_const_from_method_toc(R11, fd_env, toc, /*fixed_size*/ true);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1152
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1153
    AddressLiteral fd_toc(fd->toc());
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1154
    // Set R2_TOC (load from toc)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1155
    success = success && load_const_from_method_toc(R2_TOC, fd_toc, toc, /*fixed_size*/ true);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1156
    bctrl();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1157
    _last_calls_return_pc = pc();
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1158
    if (!success) { return NULL; }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1159
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1160
    // It's a friend function, load the entry point and don't care about
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1161
    // toc and env. Use an optimizable call instruction, but ensure the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1162
    // same code-size as in the case of a non-friend function.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1163
    nop();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1164
    bl64_patchable(fd->entry(), rt);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1165
    _last_calls_return_pc = pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1166
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1167
  return _last_calls_return_pc;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1168
}
23492
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23221
diff changeset
  1169
#endif // ABI_ELFv2
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1170
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1171
void MacroAssembler::call_VM_base(Register oop_result,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1172
                                  Register last_java_sp,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1173
                                  address  entry_point,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1174
                                  bool     check_exceptions) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1175
  BLOCK_COMMENT("call_VM {");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1176
  // Determine last_java_sp register.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1177
  if (!last_java_sp->is_valid()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1178
    last_java_sp = R1_SP;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1179
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1180
  set_top_ijava_frame_at_SP_as_last_Java_frame(last_java_sp, R11_scratch1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1181
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1182
  // ARG1 must hold thread address.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1183
  mr(R3_ARG1, R16_thread);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1184
#if defined(ABI_ELFv2)
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1185
  address return_pc = call_c(entry_point, relocInfo::none);
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1186
#else
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1187
  address return_pc = call_c((FunctionDescriptor*)entry_point, relocInfo::none);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1188
#endif
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1189
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1190
  reset_last_Java_frame();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1191
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1192
  // Check for pending exceptions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1193
  if (check_exceptions) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1194
    // We don't check for exceptions here.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1195
    ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1196
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1197
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1198
  // Get oop result if there is one and reset the value in the thread.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1199
  if (oop_result->is_valid()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1200
    get_vm_result(oop_result);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1201
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1202
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1203
  _last_calls_return_pc = return_pc;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1204
  BLOCK_COMMENT("} call_VM");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1205
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1206
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1207
void MacroAssembler::call_VM_leaf_base(address entry_point) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1208
  BLOCK_COMMENT("call_VM_leaf {");
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1209
#if defined(ABI_ELFv2)
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1210
  call_c(entry_point, relocInfo::none);
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1211
#else
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1212
  call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, entry_point), relocInfo::none);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  1213
#endif
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1214
  BLOCK_COMMENT("} call_VM_leaf");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1215
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1216
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1217
void MacroAssembler::call_VM(Register oop_result, address entry_point, bool check_exceptions) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1218
  call_VM_base(oop_result, noreg, entry_point, check_exceptions);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1219
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1220
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1221
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1222
                             bool check_exceptions) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1223
  // R3_ARG1 is reserved for the thread.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1224
  mr_if_needed(R4_ARG2, arg_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1225
  call_VM(oop_result, entry_point, check_exceptions);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1226
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1227
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1228
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1229
                             bool check_exceptions) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1230
  // R3_ARG1 is reserved for the thread
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1231
  mr_if_needed(R4_ARG2, arg_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1232
  assert(arg_2 != R4_ARG2, "smashed argument");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1233
  mr_if_needed(R5_ARG3, arg_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1234
  call_VM(oop_result, entry_point, check_exceptions);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1235
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1236
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  1237
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3,
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  1238
                             bool check_exceptions) {
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  1239
  // R3_ARG1 is reserved for the thread
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  1240
  mr_if_needed(R4_ARG2, arg_1);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  1241
  assert(arg_2 != R4_ARG2, "smashed argument");
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  1242
  mr_if_needed(R5_ARG3, arg_2);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  1243
  mr_if_needed(R6_ARG4, arg_3);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  1244
  call_VM(oop_result, entry_point, check_exceptions);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  1245
}
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  1246
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1247
void MacroAssembler::call_VM_leaf(address entry_point) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1248
  call_VM_leaf_base(entry_point);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1249
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1250
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1251
void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1252
  mr_if_needed(R3_ARG1, arg_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1253
  call_VM_leaf(entry_point);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1254
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1255
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1256
void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1, Register arg_2) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1257
  mr_if_needed(R3_ARG1, arg_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1258
  assert(arg_2 != R3_ARG1, "smashed argument");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1259
  mr_if_needed(R4_ARG2, arg_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1260
  call_VM_leaf(entry_point);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1261
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1262
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1263
void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1, Register arg_2, Register arg_3) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1264
  mr_if_needed(R3_ARG1, arg_1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1265
  assert(arg_2 != R3_ARG1, "smashed argument");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1266
  mr_if_needed(R4_ARG2, arg_2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1267
  assert(arg_3 != R3_ARG1 && arg_3 != R4_ARG2, "smashed argument");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1268
  mr_if_needed(R5_ARG3, arg_3);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1269
  call_VM_leaf(entry_point);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1270
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1271
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1272
// Check whether instruction is a read access to the polling page
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1273
// which was emitted by load_from_polling_page(..).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1274
bool MacroAssembler::is_load_from_polling_page(int instruction, void* ucontext,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1275
                                               address* polling_address_ptr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1276
  if (!is_ld(instruction))
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1277
    return false; // It's not a ld. Fail.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1278
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1279
  int rt = inv_rt_field(instruction);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1280
  int ra = inv_ra_field(instruction);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1281
  int ds = inv_ds_field(instruction);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1282
  if (!(ds == 0 && ra != 0 && rt == 0)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1283
    return false; // It's not a ld(r0, X, ra). Fail.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1284
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1285
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1286
  if (!ucontext) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1287
    // Set polling address.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1288
    if (polling_address_ptr != NULL) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1289
      *polling_address_ptr = NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1290
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1291
    return true; // No ucontext given. Can't check value of ra. Assume true.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1292
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1293
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1294
#ifdef LINUX
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1295
  // Ucontext given. Check that register ra contains the address of
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1296
  // the safepoing polling page.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1297
  ucontext_t* uc = (ucontext_t*) ucontext;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1298
  // Set polling address.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1299
  address addr = (address)uc->uc_mcontext.regs->gpr[ra] + (ssize_t)ds;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1300
  if (polling_address_ptr != NULL) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1301
    *polling_address_ptr = addr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1302
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1303
  return os::is_poll_address(addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1304
#else
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1305
  // Not on Linux, ucontext must be NULL.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1306
  ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1307
  return false;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1308
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1309
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1310
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1311
bool MacroAssembler::is_memory_serialization(int instruction, JavaThread* thread, void* ucontext) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1312
#ifdef LINUX
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1313
  ucontext_t* uc = (ucontext_t*) ucontext;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1314
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1315
  if (is_stwx(instruction) || is_stwux(instruction)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1316
    int ra = inv_ra_field(instruction);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1317
    int rb = inv_rb_field(instruction);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1318
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1319
    // look up content of ra and rb in ucontext
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1320
    address ra_val=(address)uc->uc_mcontext.regs->gpr[ra];
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1321
    long rb_val=(long)uc->uc_mcontext.regs->gpr[rb];
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1322
    return os::is_memory_serialize_page(thread, ra_val+rb_val);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1323
  } else if (is_stw(instruction) || is_stwu(instruction)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1324
    int ra = inv_ra_field(instruction);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1325
    int d1 = inv_d1_field(instruction);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1326
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1327
    // look up content of ra in ucontext
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1328
    address ra_val=(address)uc->uc_mcontext.regs->gpr[ra];
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1329
    return os::is_memory_serialize_page(thread, ra_val+d1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1330
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1331
    return false;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1332
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1333
#else
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1334
  // workaround not needed on !LINUX :-)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1335
  ShouldNotCallThis();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1336
  return false;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1337
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1338
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1339
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1340
void MacroAssembler::bang_stack_with_offset(int offset) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1341
  // When increasing the stack, the old stack pointer will be written
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1342
  // to the new top of stack according to the PPC64 abi.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1343
  // Therefore, stack banging is not necessary when increasing
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1344
  // the stack by <= os::vm_page_size() bytes.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1345
  // When increasing the stack by a larger amount, this method is
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1346
  // called repeatedly to bang the intermediate pages.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1347
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1348
  // Stack grows down, caller passes positive offset.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1349
  assert(offset > 0, "must bang with positive offset");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1350
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1351
  long stdoffset = -offset;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1352
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1353
  if (is_simm(stdoffset, 16)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1354
    // Signed 16 bit offset, a simple std is ok.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1355
    if (UseLoadInstructionsForStackBangingPPC64) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1356
      ld(R0, (int)(signed short)stdoffset, R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1357
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1358
      std(R0,(int)(signed short)stdoffset, R1_SP);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1359
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1360
  } else if (is_simm(stdoffset, 31)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1361
    const int hi = MacroAssembler::largeoffset_si16_si16_hi(stdoffset);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1362
    const int lo = MacroAssembler::largeoffset_si16_si16_lo(stdoffset);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1363
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1364
    Register tmp = R11;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1365
    addis(tmp, R1_SP, hi);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1366
    if (UseLoadInstructionsForStackBangingPPC64) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1367
      ld(R0,  lo, tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1368
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1369
      std(R0, lo, tmp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1370
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1371
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1372
    ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1373
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1374
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1375
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1376
// If instruction is a stack bang of the form
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1377
//    std    R0,    x(Ry),       (see bang_stack_with_offset())
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1378
//    stdu   R1_SP, x(R1_SP),    (see push_frame(), resize_frame())
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1379
// or stdux  R1_SP, Rx, R1_SP    (see push_frame(), resize_frame())
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1380
// return the banged address. Otherwise, return 0.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1381
address MacroAssembler::get_stack_bang_address(int instruction, void *ucontext) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1382
#ifdef LINUX
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1383
  ucontext_t* uc = (ucontext_t*) ucontext;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1384
  int rs = inv_rs_field(instruction);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1385
  int ra = inv_ra_field(instruction);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1386
  if (   (is_ld(instruction)   && rs == 0 &&  UseLoadInstructionsForStackBangingPPC64)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1387
      || (is_std(instruction)  && rs == 0 && !UseLoadInstructionsForStackBangingPPC64)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1388
      || (is_stdu(instruction) && rs == 1)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1389
    int ds = inv_ds_field(instruction);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1390
    // return banged address
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1391
    return ds+(address)uc->uc_mcontext.regs->gpr[ra];
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1392
  } else if (is_stdux(instruction) && rs == 1) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1393
    int rb = inv_rb_field(instruction);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1394
    address sp = (address)uc->uc_mcontext.regs->gpr[1];
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1395
    long rb_val = (long)uc->uc_mcontext.regs->gpr[rb];
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1396
    return ra != 1 || rb_val >= 0 ? NULL         // not a stack bang
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1397
                                  : sp + rb_val; // banged address
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1398
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1399
  return NULL; // not a stack bang
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1400
#else
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1401
  // workaround not needed on !LINUX :-)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1402
  ShouldNotCallThis();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1403
  return NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1404
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1405
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1406
38931
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1407
void MacroAssembler::reserved_stack_check(Register return_pc) {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1408
  // Test if reserved zone needs to be enabled.
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1409
  Label no_reserved_zone_enabling;
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1410
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1411
  ld_ptr(R0, JavaThread::reserved_stack_activation_offset(), R16_thread);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1412
  cmpld(CCR0, R1_SP, R0);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1413
  blt_predict_taken(CCR0, no_reserved_zone_enabling);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1414
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1415
  // Enable reserved zone again, throw stack overflow exception.
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1416
  push_frame_reg_args(0, R0);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1417
  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), R16_thread);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1418
  pop_frame();
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1419
  mtlr(return_pc);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1420
  load_const_optimized(R0, StubRoutines::throw_delayed_StackOverflowError_entry());
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1421
  mtctr(R0);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1422
  bctr();
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1423
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1424
  should_not_reach_here();
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1425
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1426
  bind(no_reserved_zone_enabling);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1427
}
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1428
39444
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1429
void MacroAssembler::getandsetd(Register dest_current_value, Register exchange_value, Register addr_base,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1430
                                bool cmpxchgx_hint) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1431
  Label retry;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1432
  bind(retry);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1433
  ldarx(dest_current_value, addr_base, cmpxchgx_hint);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1434
  stdcx_(exchange_value, addr_base);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1435
  if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1436
    bne_predict_not_taken(CCR0, retry); // StXcx_ sets CCR0.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1437
  } else {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1438
    bne(                  CCR0, retry); // StXcx_ sets CCR0.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1439
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1440
}
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1441
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1442
void MacroAssembler::getandaddd(Register dest_current_value, Register inc_value, Register addr_base,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1443
                                Register tmp, bool cmpxchgx_hint) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1444
  Label retry;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1445
  bind(retry);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1446
  ldarx(dest_current_value, addr_base, cmpxchgx_hint);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1447
  add(tmp, dest_current_value, inc_value);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1448
  stdcx_(tmp, addr_base);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1449
  if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1450
    bne_predict_not_taken(CCR0, retry); // StXcx_ sets CCR0.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1451
  } else {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1452
    bne(                  CCR0, retry); // StXcx_ sets CCR0.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1453
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1454
}
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1455
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1456
// Word/sub-word atomic helper functions
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1457
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1458
// Temps and addr_base are killed if size < 4 and processor does not support respective instructions.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1459
// Only signed types are supported with size < 4.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1460
// Atomic add always kills tmp1.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1461
void MacroAssembler::atomic_get_and_modify_generic(Register dest_current_value, Register exchange_value,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1462
                                                   Register addr_base, Register tmp1, Register tmp2, Register tmp3,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1463
                                                   bool cmpxchgx_hint, bool is_add, int size) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1464
  // Sub-word instructions are available since Power 8.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1465
  // For older processors, instruction_type != size holds, and we
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1466
  // emulate the sub-word instructions by constructing a 4-byte value
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1467
  // that leaves the other bytes unchanged.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1468
  const int instruction_type = VM_Version::has_lqarx() ? size : 4;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1469
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1470
  Label retry;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1471
  Register shift_amount = noreg,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1472
           val32 = dest_current_value,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1473
           modval = is_add ? tmp1 : exchange_value;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1474
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1475
  if (instruction_type != size) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1476
    assert_different_registers(tmp1, tmp2, tmp3, dest_current_value, exchange_value, addr_base);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1477
    modval = tmp1;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1478
    shift_amount = tmp2;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1479
    val32 = tmp3;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1480
    // Need some preperation: Compute shift amount, align address. Note: shorts must be 2 byte aligned.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1481
#ifdef VM_LITTLE_ENDIAN
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1482
    rldic(shift_amount, addr_base, 3, 64-5); // (dest & 3) * 8;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1483
    clrrdi(addr_base, addr_base, 2);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1484
#else
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1485
    xori(shift_amount, addr_base, (size == 1) ? 3 : 2);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1486
    clrrdi(addr_base, addr_base, 2);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1487
    rldic(shift_amount, shift_amount, 3, 64-5); // byte: ((3-dest) & 3) * 8; short: ((1-dest/2) & 1) * 16;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1488
#endif
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1489
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1490
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1491
  // atomic emulation loop
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1492
  bind(retry);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1493
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1494
  switch (instruction_type) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1495
    case 4: lwarx(val32, addr_base, cmpxchgx_hint); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1496
    case 2: lharx(val32, addr_base, cmpxchgx_hint); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1497
    case 1: lbarx(val32, addr_base, cmpxchgx_hint); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1498
    default: ShouldNotReachHere();
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1499
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1500
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1501
  if (instruction_type != size) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1502
    srw(dest_current_value, val32, shift_amount);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1503
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1504
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1505
  if (is_add) { add(modval, dest_current_value, exchange_value); }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1506
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1507
  if (instruction_type != size) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1508
    // Transform exchange value such that the replacement can be done by one xor instruction.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1509
    xorr(modval, dest_current_value, is_add ? modval : exchange_value);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1510
    clrldi(modval, modval, (size == 1) ? 56 : 48);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1511
    slw(modval, modval, shift_amount);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1512
    xorr(modval, val32, modval);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1513
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1514
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1515
  switch (instruction_type) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1516
    case 4: stwcx_(modval, addr_base); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1517
    case 2: sthcx_(modval, addr_base); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1518
    case 1: stbcx_(modval, addr_base); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1519
    default: ShouldNotReachHere();
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1520
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1521
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1522
  if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1523
    bne_predict_not_taken(CCR0, retry); // StXcx_ sets CCR0.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1524
  } else {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1525
    bne(                  CCR0, retry); // StXcx_ sets CCR0.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1526
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1527
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1528
  // l?arx zero-extends, but Java wants byte/short values sign-extended.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1529
  if (size == 1) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1530
    extsb(dest_current_value, dest_current_value);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1531
  } else if (size == 2) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1532
    extsh(dest_current_value, dest_current_value);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1533
  };
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1534
}
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1535
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1536
// Temps, addr_base and exchange_value are killed if size < 4 and processor does not support respective instructions.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1537
// Only signed types are supported with size < 4.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1538
void MacroAssembler::cmpxchg_loop_body(ConditionRegister flag, Register dest_current_value,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1539
                                       Register compare_value, Register exchange_value,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1540
                                       Register addr_base, Register tmp1, Register tmp2,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1541
                                       Label &retry, Label &failed, bool cmpxchgx_hint, int size) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1542
  // Sub-word instructions are available since Power 8.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1543
  // For older processors, instruction_type != size holds, and we
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1544
  // emulate the sub-word instructions by constructing a 4-byte value
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1545
  // that leaves the other bytes unchanged.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1546
  const int instruction_type = VM_Version::has_lqarx() ? size : 4;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1547
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1548
  Register shift_amount = noreg,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1549
           val32 = dest_current_value,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1550
           modval = exchange_value;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1551
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1552
  if (instruction_type != size) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1553
    assert_different_registers(tmp1, tmp2, dest_current_value, compare_value, exchange_value, addr_base);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1554
    shift_amount = tmp1;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1555
    val32 = tmp2;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1556
    modval = tmp2;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1557
    // Need some preperation: Compute shift amount, align address. Note: shorts must be 2 byte aligned.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1558
#ifdef VM_LITTLE_ENDIAN
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1559
    rldic(shift_amount, addr_base, 3, 64-5); // (dest & 3) * 8;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1560
    clrrdi(addr_base, addr_base, 2);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1561
#else
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1562
    xori(shift_amount, addr_base, (size == 1) ? 3 : 2);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1563
    clrrdi(addr_base, addr_base, 2);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1564
    rldic(shift_amount, shift_amount, 3, 64-5); // byte: ((3-dest) & 3) * 8; short: ((1-dest/2) & 1) * 16;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1565
#endif
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1566
    // Transform exchange value such that the replacement can be done by one xor instruction.
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1567
    xorr(exchange_value, compare_value, exchange_value);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1568
    clrldi(exchange_value, exchange_value, (size == 1) ? 56 : 48);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1569
    slw(exchange_value, exchange_value, shift_amount);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1570
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1571
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1572
  // atomic emulation loop
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1573
  bind(retry);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1574
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1575
  switch (instruction_type) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1576
    case 4: lwarx(val32, addr_base, cmpxchgx_hint); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1577
    case 2: lharx(val32, addr_base, cmpxchgx_hint); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1578
    case 1: lbarx(val32, addr_base, cmpxchgx_hint); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1579
    default: ShouldNotReachHere();
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1580
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1581
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1582
  if (instruction_type != size) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1583
    srw(dest_current_value, val32, shift_amount);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1584
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1585
  if (size == 1) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1586
    extsb(dest_current_value, dest_current_value);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1587
  } else if (size == 2) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1588
    extsh(dest_current_value, dest_current_value);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1589
  };
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1590
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1591
  cmpw(flag, dest_current_value, compare_value);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1592
  if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1593
    bne_predict_not_taken(flag, failed);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1594
  } else {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1595
    bne(                  flag, failed);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1596
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1597
  // branch to done  => (flag == ne), (dest_current_value != compare_value)
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1598
  // fall through    => (flag == eq), (dest_current_value == compare_value)
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1599
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1600
  if (instruction_type != size) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1601
    xorr(modval, val32, exchange_value);
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1602
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1603
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1604
  switch (instruction_type) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1605
    case 4: stwcx_(modval, addr_base); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1606
    case 2: sthcx_(modval, addr_base); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1607
    case 1: stbcx_(modval, addr_base); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1608
    default: ShouldNotReachHere();
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1609
  }
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1610
}
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1611
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1612
// CmpxchgX sets condition register to cmpX(current, compare).
39444
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1613
void MacroAssembler::cmpxchg_generic(ConditionRegister flag, Register dest_current_value,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1614
                                     Register compare_value, Register exchange_value,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1615
                                     Register addr_base, Register tmp1, Register tmp2,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1616
                                     int semantics, bool cmpxchgx_hint,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1617
                                     Register int_flag_success, bool contention_hint, bool weak, int size) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1618
  Label retry;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1619
  Label failed;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1620
  Label done;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1621
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1622
  // Save one branch if result is returned via register and
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1623
  // result register is different from the other ones.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1624
  bool use_result_reg    = (int_flag_success != noreg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1625
  bool preset_result_reg = (int_flag_success != dest_current_value && int_flag_success != compare_value &&
39444
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1626
                            int_flag_success != exchange_value && int_flag_success != addr_base &&
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1627
                            int_flag_success != tmp1 && int_flag_success != tmp2);
38685
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1628
  assert(!weak || flag == CCR0, "weak only supported with CCR0");
39444
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1629
  assert(size == 1 || size == 2 || size == 4, "unsupported");
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1630
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1631
  if (use_result_reg && preset_result_reg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1632
    li(int_flag_success, 0); // preset (assume cas failed)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1633
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1634
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1635
  // Add simple guard in order to reduce risk of starving under high contention (recommended by IBM).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1636
  if (contention_hint) { // Don't try to reserve if cmp fails.
39444
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1637
    switch (size) {
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1638
      case 1: lbz(dest_current_value, 0, addr_base); extsb(dest_current_value, dest_current_value); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1639
      case 2: lha(dest_current_value, 0, addr_base); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1640
      case 4: lwz(dest_current_value, 0, addr_base); break;
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1641
      default: ShouldNotReachHere();
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1642
    }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1643
    cmpw(flag, dest_current_value, compare_value);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1644
    bne(flag, failed);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1645
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1646
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1647
  // release/fence semantics
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1648
  if (semantics & MemBarRel) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1649
    release();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1650
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1651
39444
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1652
  cmpxchg_loop_body(flag, dest_current_value, compare_value, exchange_value, addr_base, tmp1, tmp2,
2eae9b74c1f3 8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents: 38931
diff changeset
  1653
                    retry, failed, cmpxchgx_hint, size);
38685
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1654
  if (!weak || use_result_reg) {
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1655
    if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1656
      bne_predict_not_taken(CCR0, weak ? failed : retry); // StXcx_ sets CCR0.
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1657
    } else {
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1658
      bne(                  CCR0, weak ? failed : retry); // StXcx_ sets CCR0.
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1659
    }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1660
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1661
  // fall through    => (flag == eq), (dest_current_value == compare_value), (swapped)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1662
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1663
  // Result in register (must do this at the end because int_flag_success can be the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1664
  // same register as one above).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1665
  if (use_result_reg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1666
    li(int_flag_success, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1667
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1668
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1669
  if (semantics & MemBarFenceAfter) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1670
    fence();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1671
  } else if (semantics & MemBarAcq) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1672
    isync();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1673
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1674
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1675
  if (use_result_reg && !preset_result_reg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1676
    b(done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1677
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1678
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1679
  bind(failed);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1680
  if (use_result_reg && !preset_result_reg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1681
    li(int_flag_success, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1682
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1683
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1684
  bind(done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1685
  // (flag == ne) => (dest_current_value != compare_value), (!swapped)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1686
  // (flag == eq) => (dest_current_value == compare_value), ( swapped)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1687
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1688
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1689
// Preforms atomic compare exchange:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1690
//   if (compare_value == *addr_base)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1691
//     *addr_base = exchange_value
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1692
//     int_flag_success = 1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1693
//   else
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1694
//     int_flag_success = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1695
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1696
// ConditionRegister flag       = cmp(compare_value, *addr_base)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1697
// Register dest_current_value  = *addr_base
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1698
// Register compare_value       Used to compare with value in memory
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1699
// Register exchange_value      Written to memory if compare_value == *addr_base
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1700
// Register addr_base           The memory location to compareXChange
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1701
// Register int_flag_success    Set to 1 if exchange_value was written to *addr_base
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1702
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1703
// To avoid the costly compare exchange the value is tested beforehand.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1704
// Several special cases exist to avoid that unnecessary information is generated.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1705
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1706
void MacroAssembler::cmpxchgd(ConditionRegister flag,
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  1707
                              Register dest_current_value, RegisterOrConstant compare_value, Register exchange_value,
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1708
                              Register addr_base, int semantics, bool cmpxchgx_hint,
38685
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1709
                              Register int_flag_success, Label* failed_ext, bool contention_hint, bool weak) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1710
  Label retry;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1711
  Label failed_int;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1712
  Label& failed = (failed_ext != NULL) ? *failed_ext : failed_int;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1713
  Label done;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1714
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1715
  // Save one branch if result is returned via register and result register is different from the other ones.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1716
  bool use_result_reg    = (int_flag_success!=noreg);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  1717
  bool preset_result_reg = (int_flag_success!=dest_current_value && int_flag_success!=compare_value.register_or_noreg() &&
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1718
                            int_flag_success!=exchange_value && int_flag_success!=addr_base);
38685
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1719
  assert(!weak || flag == CCR0, "weak only supported with CCR0");
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1720
  assert(int_flag_success == noreg || failed_ext == NULL, "cannot have both");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1721
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1722
  if (use_result_reg && preset_result_reg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1723
    li(int_flag_success, 0); // preset (assume cas failed)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1724
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1725
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1726
  // Add simple guard in order to reduce risk of starving under high contention (recommended by IBM).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1727
  if (contention_hint) { // Don't try to reserve if cmp fails.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1728
    ld(dest_current_value, 0, addr_base);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  1729
    cmpd(flag, compare_value, dest_current_value);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1730
    bne(flag, failed);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1731
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1732
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1733
  // release/fence semantics
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1734
  if (semantics & MemBarRel) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1735
    release();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1736
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1737
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1738
  // atomic emulation loop
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1739
  bind(retry);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1740
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1741
  ldarx(dest_current_value, addr_base, cmpxchgx_hint);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  1742
  cmpd(flag, compare_value, dest_current_value);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1743
  if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1744
    bne_predict_not_taken(flag, failed);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1745
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1746
    bne(                  flag, failed);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1747
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1748
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1749
  stdcx_(exchange_value, addr_base);
38685
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1750
  if (!weak || use_result_reg || failed_ext) {
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1751
    if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1752
      bne_predict_not_taken(CCR0, weak ? failed : retry); // stXcx_ sets CCR0
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1753
    } else {
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1754
      bne(                  CCR0, weak ? failed : retry); // stXcx_ sets CCR0
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38074
diff changeset
  1755
    }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1756
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1757
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1758
  // result in register (must do this at the end because int_flag_success can be the same register as one above)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1759
  if (use_result_reg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1760
    li(int_flag_success, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1761
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1762
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1763
  if (semantics & MemBarFenceAfter) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1764
    fence();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1765
  } else if (semantics & MemBarAcq) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1766
    isync();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1767
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1768
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1769
  if (use_result_reg && !preset_result_reg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1770
    b(done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1771
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1772
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1773
  bind(failed_int);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1774
  if (use_result_reg && !preset_result_reg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1775
    li(int_flag_success, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1776
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1777
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1778
  bind(done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1779
  // (flag == ne) => (dest_current_value != compare_value), (!swapped)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1780
  // (flag == eq) => (dest_current_value == compare_value), ( swapped)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1781
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1782
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1783
// Look up the method for a megamorphic invokeinterface call.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1784
// The target method is determined by <intf_klass, itable_index>.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1785
// The receiver klass is in recv_klass.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1786
// On success, the result will be in method_result, and execution falls through.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1787
// On failure, execution transfers to the given label.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1788
void MacroAssembler::lookup_interface_method(Register recv_klass,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1789
                                             Register intf_klass,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1790
                                             RegisterOrConstant itable_index,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1791
                                             Register method_result,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1792
                                             Register scan_temp,
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1793
                                             Register temp2,
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1794
                                             Label& L_no_such_interface,
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1795
                                             bool return_method) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1796
  assert_different_registers(recv_klass, intf_klass, method_result, scan_temp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1797
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1798
  // Compute start of first itableOffsetEntry (which is at the end of the vtable).
35899
0dbc821628fc 8148047: Move the vtable length field to Klass
mgerdin
parents: 35871
diff changeset
  1799
  int vtable_base = in_bytes(Klass::vtable_start_offset());
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1800
  int itentry_off = itableMethodEntry::method_offset_in_bytes();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1801
  int logMEsize   = exact_log2(itableMethodEntry::size() * wordSize);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1802
  int scan_step   = itableOffsetEntry::size() * wordSize;
35871
607bf949dfb3 8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents: 35232
diff changeset
  1803
  int log_vte_size= exact_log2(vtableEntry::size_in_bytes());
607bf949dfb3 8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents: 35232
diff changeset
  1804
35899
0dbc821628fc 8148047: Move the vtable length field to Klass
mgerdin
parents: 35871
diff changeset
  1805
  lwz(scan_temp, in_bytes(Klass::vtable_length_offset()), recv_klass);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1806
  // %%% We should store the aligned, prescaled offset in the klassoop.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1807
  // Then the next several instructions would fold away.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1808
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1809
  sldi(scan_temp, scan_temp, log_vte_size);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1810
  addi(scan_temp, scan_temp, vtable_base);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1811
  add(scan_temp, recv_klass, scan_temp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1812
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1813
  // Adjust recv_klass by scaled itable_index, so we can free itable_index.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1814
  if (return_method) {
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1815
    if (itable_index.is_register()) {
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1816
      Register itable_offset = itable_index.as_register();
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1817
      sldi(method_result, itable_offset, logMEsize);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1818
      if (itentry_off) { addi(method_result, method_result, itentry_off); }
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1819
      add(method_result, method_result, recv_klass);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1820
    } else {
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1821
      long itable_offset = (long)itable_index.as_constant();
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1822
      // static address, no relocation
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1823
      add_const_optimized(method_result, recv_klass, (itable_offset << logMEsize) + itentry_off, temp2);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1824
    }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1825
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1826
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1827
  // for (scan = klass->itable(); scan->interface() != NULL; scan += scan_step) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1828
  //   if (scan->interface() == intf) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1829
  //     result = (klass + scan->offset() + itable_index);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1830
  //   }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1831
  // }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1832
  Label search, found_method;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1833
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1834
  for (int peel = 1; peel >= 0; peel--) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1835
    // %%%% Could load both offset and interface in one ldx, if they were
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1836
    // in the opposite order. This would save a load.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1837
    ld(temp2, itableOffsetEntry::interface_offset_in_bytes(), scan_temp);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1838
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1839
    // Check that this entry is non-null. A null entry means that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1840
    // the receiver class doesn't implement the interface, and wasn't the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1841
    // same as when the caller was compiled.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1842
    cmpd(CCR0, temp2, intf_klass);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1843
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1844
    if (peel) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1845
      beq(CCR0, found_method);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1846
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1847
      bne(CCR0, search);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1848
      // (invert the test to fall through to found_method...)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1849
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1850
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1851
    if (!peel) break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1852
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1853
    bind(search);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1854
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1855
    cmpdi(CCR0, temp2, 0);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1856
    beq(CCR0, L_no_such_interface);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1857
    addi(scan_temp, scan_temp, scan_step);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1858
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1859
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1860
  bind(found_method);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1861
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1862
  // Got a hit.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1863
  if (return_method) {
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1864
    int ito_offset = itableOffsetEntry::offset_offset_in_bytes();
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1865
    lwz(scan_temp, ito_offset, scan_temp);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1866
    ldx(method_result, scan_temp, method_result);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  1867
  }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1868
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1869
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1870
// virtual method calling
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1871
void MacroAssembler::lookup_virtual_method(Register recv_klass,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1872
                                           RegisterOrConstant vtable_index,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1873
                                           Register method_result) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1874
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1875
  assert_different_registers(recv_klass, method_result, vtable_index.register_or_noreg());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1876
35899
0dbc821628fc 8148047: Move the vtable length field to Klass
mgerdin
parents: 35871
diff changeset
  1877
  const int base = in_bytes(Klass::vtable_start_offset());
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1878
  assert(vtableEntry::size() * wordSize == wordSize, "adjust the scaling in the code below");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1879
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1880
  if (vtable_index.is_register()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1881
    sldi(vtable_index.as_register(), vtable_index.as_register(), LogBytesPerWord);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1882
    add(recv_klass, vtable_index.as_register(), recv_klass);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1883
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1884
    addi(recv_klass, recv_klass, vtable_index.as_constant() << LogBytesPerWord);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1885
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1886
  ld(R19_method, base + vtableEntry::method_offset_in_bytes(), recv_klass);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1887
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1888
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1889
/////////////////////////////////////////// subtype checking ////////////////////////////////////////////
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1890
void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1891
                                                   Register super_klass,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1892
                                                   Register temp1_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1893
                                                   Register temp2_reg,
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1894
                                                   Label* L_success,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1895
                                                   Label* L_failure,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1896
                                                   Label* L_slow_path,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1897
                                                   RegisterOrConstant super_check_offset) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1898
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1899
  const Register check_cache_offset = temp1_reg;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1900
  const Register cached_super       = temp2_reg;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1901
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1902
  assert_different_registers(sub_klass, super_klass, check_cache_offset, cached_super);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1903
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1904
  int sco_offset = in_bytes(Klass::super_check_offset_offset());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1905
  int sc_offset  = in_bytes(Klass::secondary_super_cache_offset());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1906
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1907
  bool must_load_sco = (super_check_offset.constant_or_zero() == -1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1908
  bool need_slow_path = (must_load_sco || super_check_offset.constant_or_zero() == sco_offset);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1909
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1910
  Label L_fallthrough;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1911
  int label_nulls = 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1912
  if (L_success == NULL)   { L_success   = &L_fallthrough; label_nulls++; }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1913
  if (L_failure == NULL)   { L_failure   = &L_fallthrough; label_nulls++; }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1914
  if (L_slow_path == NULL) { L_slow_path = &L_fallthrough; label_nulls++; }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1915
  assert(label_nulls <= 1 ||
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1916
         (L_slow_path == &L_fallthrough && label_nulls <= 2 && !need_slow_path),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1917
         "at most one NULL in the batch, usually");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1918
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1919
  // If the pointers are equal, we are done (e.g., String[] elements).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1920
  // This self-check enables sharing of secondary supertype arrays among
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1921
  // non-primary types such as array-of-interface. Otherwise, each such
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1922
  // type would need its own customized SSA.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1923
  // We move this check to the front of the fast path because many
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1924
  // type checks are in fact trivially successful in this manner,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1925
  // so we get a nicely predicted branch right at the start of the check.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1926
  cmpd(CCR0, sub_klass, super_klass);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1927
  beq(CCR0, *L_success);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1928
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1929
  // Check the supertype display:
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1930
  if (must_load_sco) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1931
    // The super check offset is always positive...
42068
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41334
diff changeset
  1932
    lwz(check_cache_offset, sco_offset, super_klass);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1933
    super_check_offset = RegisterOrConstant(check_cache_offset);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1934
    // super_check_offset is register.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1935
    assert_different_registers(sub_klass, super_klass, cached_super, super_check_offset.as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1936
  }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1937
  // The loaded value is the offset from KlassOopDesc.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1938
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1939
  ld(cached_super, super_check_offset, sub_klass);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1940
  cmpd(CCR0, cached_super, super_klass);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1941
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1942
  // This check has worked decisively for primary supers.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1943
  // Secondary supers are sought in the super_cache ('super_cache_addr').
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1944
  // (Secondary supers are interfaces and very deeply nested subtypes.)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1945
  // This works in the same check above because of a tricky aliasing
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1946
  // between the super_cache and the primary super display elements.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1947
  // (The 'super_check_addr' can address either, as the case requires.)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1948
  // Note that the cache is updated below if it does not help us find
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1949
  // what we need immediately.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1950
  // So if it was a primary super, we can just fail immediately.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1951
  // Otherwise, it's the slow path for us (no success at this point).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1952
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1953
#define FINAL_JUMP(label) if (&(label) != &L_fallthrough) { b(label); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1954
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1955
  if (super_check_offset.is_register()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1956
    beq(CCR0, *L_success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1957
    cmpwi(CCR0, super_check_offset.as_register(), sc_offset);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1958
    if (L_failure == &L_fallthrough) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1959
      beq(CCR0, *L_slow_path);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1960
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1961
      bne(CCR0, *L_failure);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1962
      FINAL_JUMP(*L_slow_path);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1963
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1964
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1965
    if (super_check_offset.as_constant() == sc_offset) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1966
      // Need a slow path; fast failure is impossible.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1967
      if (L_slow_path == &L_fallthrough) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1968
        beq(CCR0, *L_success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1969
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1970
        bne(CCR0, *L_slow_path);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1971
        FINAL_JUMP(*L_success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1972
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1973
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1974
      // No slow path; it's a fast decision.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1975
      if (L_failure == &L_fallthrough) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1976
        beq(CCR0, *L_success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1977
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1978
        bne(CCR0, *L_failure);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1979
        FINAL_JUMP(*L_success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1980
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1981
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1982
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1983
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1984
  bind(L_fallthrough);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  1985
#undef FINAL_JUMP
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1986
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1987
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1988
void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1989
                                                   Register super_klass,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1990
                                                   Register temp1_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1991
                                                   Register temp2_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1992
                                                   Label* L_success,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1993
                                                   Register result_reg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1994
  const Register array_ptr = temp1_reg; // current value from cache array
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1995
  const Register temp      = temp2_reg;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1996
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1997
  assert_different_registers(sub_klass, super_klass, array_ptr, temp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1998
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  1999
  int source_offset = in_bytes(Klass::secondary_supers_offset());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2000
  int target_offset = in_bytes(Klass::secondary_super_cache_offset());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2001
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2002
  int length_offset = Array<Klass*>::length_offset_in_bytes();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2003
  int base_offset   = Array<Klass*>::base_offset_in_bytes();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2004
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2005
  Label hit, loop, failure, fallthru;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2006
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2007
  ld(array_ptr, source_offset, sub_klass);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2008
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2009
  // TODO: PPC port: assert(4 == arrayOopDesc::length_length_in_bytes(), "precondition violated.");
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2010
  lwz(temp, length_offset, array_ptr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2011
  cmpwi(CCR0, temp, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2012
  beq(CCR0, result_reg!=noreg ? failure : fallthru); // length 0
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2013
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2014
  mtctr(temp); // load ctr
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2015
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2016
  bind(loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2017
  // Oops in table are NO MORE compressed.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2018
  ld(temp, base_offset, array_ptr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2019
  cmpd(CCR0, temp, super_klass);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2020
  beq(CCR0, hit);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2021
  addi(array_ptr, array_ptr, BytesPerWord);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2022
  bdnz(loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2023
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2024
  bind(failure);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2025
  if (result_reg!=noreg) li(result_reg, 1); // load non-zero result (indicates a miss)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2026
  b(fallthru);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2027
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2028
  bind(hit);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2029
  std(super_klass, target_offset, sub_klass); // save result to cache
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2030
  if (result_reg != noreg) { li(result_reg, 0); } // load zero result (indicates a hit)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2031
  if (L_success != NULL) { b(*L_success); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2032
  else if (result_reg == noreg) { blr(); } // return with CR0.eq if neither label nor result reg provided
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2033
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2034
  bind(fallthru);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2035
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2036
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2037
// Try fast path, then go to slow one if not successful
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2038
void MacroAssembler::check_klass_subtype(Register sub_klass,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2039
                         Register super_klass,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2040
                         Register temp1_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2041
                         Register temp2_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2042
                         Label& L_success) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2043
  Label L_failure;
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2044
  check_klass_subtype_fast_path(sub_klass, super_klass, temp1_reg, temp2_reg, &L_success, &L_failure);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2045
  check_klass_subtype_slow_path(sub_klass, super_klass, temp1_reg, temp2_reg, &L_success);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2046
  bind(L_failure); // Fallthru if not successful.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2047
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2048
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2049
void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2050
                                              Register temp_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2051
                                              Label& wrong_method_type) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2052
  assert_different_registers(mtype_reg, mh_reg, temp_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2053
  // Compare method type against that of the receiver.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2054
  load_heap_oop_not_null(temp_reg, delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg), mh_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2055
  cmpd(CCR0, temp_reg, mtype_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2056
  bne(CCR0, wrong_method_type);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2057
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2058
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2059
RegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2060
                                                   Register temp_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2061
                                                   int extra_slot_offset) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2062
  // cf. TemplateTable::prepare_invoke(), if (load_receiver).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2063
  int stackElementSize = Interpreter::stackElementSize;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2064
  int offset = extra_slot_offset * stackElementSize;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2065
  if (arg_slot.is_constant()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2066
    offset += arg_slot.as_constant() * stackElementSize;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2067
    return offset;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2068
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2069
    assert(temp_reg != noreg, "must specify");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2070
    sldi(temp_reg, arg_slot.as_register(), exact_log2(stackElementSize));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2071
    if (offset != 0)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2072
      addi(temp_reg, temp_reg, offset);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2073
    return temp_reg;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2074
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2075
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2076
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2077
// Supports temp2_reg = R0.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2078
void MacroAssembler::biased_locking_enter(ConditionRegister cr_reg, Register obj_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2079
                                          Register mark_reg, Register temp_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2080
                                          Register temp2_reg, Label& done, Label* slow_case) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2081
  assert(UseBiasedLocking, "why call this otherwise?");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2082
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2083
#ifdef ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2084
  assert_different_registers(obj_reg, mark_reg, temp_reg, temp2_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2085
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2086
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2087
  Label cas_label;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2088
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2089
  // Branch to done if fast path fails and no slow_case provided.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2090
  Label *slow_case_int = (slow_case != NULL) ? slow_case : &done;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2091
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2092
  // Biased locking
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2093
  // See whether the lock is currently biased toward our thread and
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2094
  // whether the epoch is still valid
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2095
  // Note that the runtime guarantees sufficient alignment of JavaThread
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2096
  // pointers to allow age to be placed into low bits
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2097
  assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2098
         "biased locking makes assumptions about bit layout");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2099
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2100
  if (PrintBiasedLockingStatistics) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2101
    load_const(temp2_reg, (address) BiasedLocking::total_entry_count_addr(), temp_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2102
    lwzx(temp_reg, temp2_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2103
    addi(temp_reg, temp_reg, 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2104
    stwx(temp_reg, temp2_reg);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2105
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2106
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2107
  andi(temp_reg, mark_reg, markOopDesc::biased_lock_mask_in_place);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2108
  cmpwi(cr_reg, temp_reg, markOopDesc::biased_lock_pattern);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2109
  bne(cr_reg, cas_label);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2110
23492
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23221
diff changeset
  2111
  load_klass(temp_reg, obj_reg);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2112
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2113
  load_const_optimized(temp2_reg, ~((int) markOopDesc::age_mask_in_place));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2114
  ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2115
  orr(temp_reg, R16_thread, temp_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2116
  xorr(temp_reg, mark_reg, temp_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2117
  andr(temp_reg, temp_reg, temp2_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2118
  cmpdi(cr_reg, temp_reg, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2119
  if (PrintBiasedLockingStatistics) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2120
    Label l;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2121
    bne(cr_reg, l);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2122
    load_const(temp2_reg, (address) BiasedLocking::biased_lock_entry_count_addr());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2123
    lwzx(mark_reg, temp2_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2124
    addi(mark_reg, mark_reg, 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2125
    stwx(mark_reg, temp2_reg);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2126
    // restore mark_reg
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2127
    ld(mark_reg, oopDesc::mark_offset_in_bytes(), obj_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2128
    bind(l);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2129
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2130
  beq(cr_reg, done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2131
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2132
  Label try_revoke_bias;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2133
  Label try_rebias;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2134
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2135
  // At this point we know that the header has the bias pattern and
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2136
  // that we are not the bias owner in the current epoch. We need to
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2137
  // figure out more details about the state of the header in order to
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2138
  // know what operations can be legally performed on the object's
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2139
  // header.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2140
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2141
  // If the low three bits in the xor result aren't clear, that means
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2142
  // the prototype header is no longer biased and we have to revoke
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2143
  // the bias on this object.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2144
  andi(temp2_reg, temp_reg, markOopDesc::biased_lock_mask_in_place);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2145
  cmpwi(cr_reg, temp2_reg, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2146
  bne(cr_reg, try_revoke_bias);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2147
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2148
  // Biasing is still enabled for this data type. See whether the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2149
  // epoch of the current bias is still valid, meaning that the epoch
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2150
  // bits of the mark word are equal to the epoch bits of the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2151
  // prototype header. (Note that the prototype header's epoch bits
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2152
  // only change at a safepoint.) If not, attempt to rebias the object
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2153
  // toward the current thread. Note that we must be absolutely sure
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2154
  // that the current epoch is invalid in order to do this because
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2155
  // otherwise the manipulations it performs on the mark word are
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2156
  // illegal.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2157
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2158
  int shift_amount = 64 - markOopDesc::epoch_shift;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2159
  // rotate epoch bits to right (little) end and set other bits to 0
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2160
  // [ big part | epoch | little part ] -> [ 0..0 | epoch ]
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2161
  rldicl_(temp2_reg, temp_reg, shift_amount, 64 - markOopDesc::epoch_bits);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2162
  // branch if epoch bits are != 0, i.e. they differ, because the epoch has been incremented
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2163
  bne(CCR0, try_rebias);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2164
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2165
  // The epoch of the current bias is still valid but we know nothing
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2166
  // about the owner; it might be set or it might be clear. Try to
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2167
  // acquire the bias of the object using an atomic operation. If this
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2168
  // fails we will go in to the runtime to revoke the object's bias.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2169
  // Note that we first construct the presumed unbiased header so we
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2170
  // don't accidentally blow away another thread's valid bias.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2171
  andi(mark_reg, mark_reg, (markOopDesc::biased_lock_mask_in_place |
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2172
                                markOopDesc::age_mask_in_place |
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2173
                                markOopDesc::epoch_mask_in_place));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2174
  orr(temp_reg, R16_thread, mark_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2175
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2176
  assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2177
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2178
  // CmpxchgX sets cr_reg to cmpX(temp2_reg, mark_reg).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2179
  cmpxchgd(/*flag=*/cr_reg, /*current_value=*/temp2_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2180
           /*compare_value=*/mark_reg, /*exchange_value=*/temp_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2181
           /*where=*/obj_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2182
           MacroAssembler::MemBarAcq,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2183
           MacroAssembler::cmpxchgx_hint_acquire_lock(),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2184
           noreg, slow_case_int); // bail out if failed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2185
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2186
  // If the biasing toward our thread failed, this means that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2187
  // another thread succeeded in biasing it toward itself and we
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2188
  // need to revoke that bias. The revocation will occur in the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2189
  // interpreter runtime in the slow case.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2190
  if (PrintBiasedLockingStatistics) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2191
    load_const(temp2_reg, (address) BiasedLocking::anonymously_biased_lock_entry_count_addr(), temp_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2192
    lwzx(temp_reg, temp2_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2193
    addi(temp_reg, temp_reg, 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2194
    stwx(temp_reg, temp2_reg);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2195
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2196
  b(done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2197
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2198
  bind(try_rebias);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2199
  // At this point we know the epoch has expired, meaning that the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2200
  // current "bias owner", if any, is actually invalid. Under these
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2201
  // circumstances _only_, we are allowed to use the current header's
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2202
  // value as the comparison value when doing the cas to acquire the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2203
  // bias in the current epoch. In other words, we allow transfer of
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2204
  // the bias from one thread to another directly in this situation.
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2205
  load_klass(temp_reg, obj_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2206
  andi(temp2_reg, mark_reg, markOopDesc::age_mask_in_place);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2207
  orr(temp2_reg, R16_thread, temp2_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2208
  ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2209
  orr(temp_reg, temp2_reg, temp_reg);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2210
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2211
  assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2212
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2213
  cmpxchgd(/*flag=*/cr_reg, /*current_value=*/temp2_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2214
                 /*compare_value=*/mark_reg, /*exchange_value=*/temp_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2215
                 /*where=*/obj_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2216
                 MacroAssembler::MemBarAcq,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2217
                 MacroAssembler::cmpxchgx_hint_acquire_lock(),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2218
                 noreg, slow_case_int); // bail out if failed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2219
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2220
  // If the biasing toward our thread failed, this means that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2221
  // another thread succeeded in biasing it toward itself and we
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2222
  // need to revoke that bias. The revocation will occur in the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2223
  // interpreter runtime in the slow case.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2224
  if (PrintBiasedLockingStatistics) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2225
    load_const(temp2_reg, (address) BiasedLocking::rebiased_lock_entry_count_addr(), temp_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2226
    lwzx(temp_reg, temp2_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2227
    addi(temp_reg, temp_reg, 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2228
    stwx(temp_reg, temp2_reg);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2229
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2230
  b(done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2231
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2232
  bind(try_revoke_bias);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2233
  // The prototype mark in the klass doesn't have the bias bit set any
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2234
  // more, indicating that objects of this data type are not supposed
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2235
  // to be biased any more. We are going to try to reset the mark of
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2236
  // this object to the prototype value and fall through to the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2237
  // CAS-based locking scheme. Note that if our CAS fails, it means
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2238
  // that another thread raced us for the privilege of revoking the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2239
  // bias of this particular object, so it's okay to continue in the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2240
  // normal locking code.
23492
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23221
diff changeset
  2241
  load_klass(temp_reg, obj_reg);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2242
  ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2243
  andi(temp2_reg, mark_reg, markOopDesc::age_mask_in_place);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2244
  orr(temp_reg, temp_reg, temp2_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2245
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2246
  assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2247
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2248
  // CmpxchgX sets cr_reg to cmpX(temp2_reg, mark_reg).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2249
  cmpxchgd(/*flag=*/cr_reg, /*current_value=*/temp2_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2250
                 /*compare_value=*/mark_reg, /*exchange_value=*/temp_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2251
                 /*where=*/obj_reg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2252
                 MacroAssembler::MemBarAcq,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2253
                 MacroAssembler::cmpxchgx_hint_acquire_lock());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2254
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2255
  // reload markOop in mark_reg before continuing with lightweight locking
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2256
  ld(mark_reg, oopDesc::mark_offset_in_bytes(), obj_reg);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2257
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2258
  // Fall through to the normal CAS-based lock, because no matter what
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2259
  // the result of the above CAS, some thread must have succeeded in
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2260
  // removing the bias bit from the object's header.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2261
  if (PrintBiasedLockingStatistics) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2262
    Label l;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2263
    bne(cr_reg, l);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2264
    load_const(temp2_reg, (address) BiasedLocking::revoked_lock_entry_count_addr(), temp_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2265
    lwzx(temp_reg, temp2_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2266
    addi(temp_reg, temp_reg, 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2267
    stwx(temp_reg, temp2_reg);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2268
    bind(l);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2269
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2270
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2271
  bind(cas_label);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2272
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2273
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2274
void MacroAssembler::biased_locking_exit (ConditionRegister cr_reg, Register mark_addr, Register temp_reg, Label& done) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2275
  // Check for biased locking unlock case, which is a no-op
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2276
  // Note: we do not have to check the thread ID for two reasons.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2277
  // First, the interpreter checks for IllegalMonitorStateException at
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2278
  // a higher level. Second, if the bias was revoked while we held the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2279
  // lock, the object could not be rebiased toward another thread, so
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2280
  // the bias bit would be clear.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2281
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2282
  ld(temp_reg, 0, mark_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2283
  andi(temp_reg, temp_reg, markOopDesc::biased_lock_mask_in_place);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2284
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2285
  cmpwi(cr_reg, temp_reg, markOopDesc::biased_lock_pattern);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2286
  beq(cr_reg, done);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2287
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2288
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2289
// allocation (for C1)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2290
void MacroAssembler::eden_allocate(
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2291
  Register obj,                      // result: pointer to object after successful allocation
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2292
  Register var_size_in_bytes,        // object size in bytes if unknown at compile time; invalid otherwise
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2293
  int      con_size_in_bytes,        // object size in bytes if   known at compile time
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2294
  Register t1,                       // temp register
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2295
  Register t2,                       // temp register
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2296
  Label&   slow_case                 // continuation point if fast allocation fails
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2297
) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2298
  b(slow_case);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2299
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2300
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2301
void MacroAssembler::tlab_allocate(
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2302
  Register obj,                      // result: pointer to object after successful allocation
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2303
  Register var_size_in_bytes,        // object size in bytes if unknown at compile time; invalid otherwise
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2304
  int      con_size_in_bytes,        // object size in bytes if   known at compile time
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2305
  Register t1,                       // temp register
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2306
  Label&   slow_case                 // continuation point if fast allocation fails
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2307
) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2308
  // make sure arguments make sense
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2309
  assert_different_registers(obj, var_size_in_bytes, t1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2310
  assert(0 <= con_size_in_bytes && is_simm13(con_size_in_bytes), "illegal object size");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2311
  assert((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0, "object size is not multiple of alignment");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2312
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2313
  const Register new_top = t1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2314
  //verify_tlab(); not implemented
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2315
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2316
  ld(obj, in_bytes(JavaThread::tlab_top_offset()), R16_thread);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2317
  ld(R0, in_bytes(JavaThread::tlab_end_offset()), R16_thread);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2318
  if (var_size_in_bytes == noreg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2319
    addi(new_top, obj, con_size_in_bytes);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2320
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2321
    add(new_top, obj, var_size_in_bytes);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2322
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2323
  cmpld(CCR0, new_top, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2324
  bc_far_optimized(Assembler::bcondCRbiIs1, bi0(CCR0, Assembler::greater), slow_case);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2325
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2326
#ifdef ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2327
  // make sure new free pointer is properly aligned
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2328
  {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2329
    Label L;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2330
    andi_(R0, new_top, MinObjAlignmentInBytesMask);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2331
    beq(CCR0, L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2332
    stop("updated TLAB free is not properly aligned", 0x934);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2333
    bind(L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2334
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2335
#endif // ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2336
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2337
  // update the tlab top pointer
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2338
  std(new_top, in_bytes(JavaThread::tlab_top_offset()), R16_thread);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2339
  //verify_tlab(); not implemented
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2340
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2341
void MacroAssembler::incr_allocated_bytes(RegisterOrConstant size_in_bytes, Register t1, Register t2) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2342
  unimplemented("incr_allocated_bytes");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2343
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2344
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2345
address MacroAssembler::emit_trampoline_stub(int destination_toc_offset,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2346
                                             int insts_call_instruction_offset, Register Rtoc) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2347
  // Start the stub.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2348
  address stub = start_a_stub(64);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2349
  if (stub == NULL) { return NULL; } // CodeCache full: bail out
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2350
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2351
  // Create a trampoline stub relocation which relates this trampoline stub
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2352
  // with the call instruction at insts_call_instruction_offset in the
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2353
  // instructions code-section.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2354
  relocate(trampoline_stub_Relocation::spec(code()->insts()->start() + insts_call_instruction_offset));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2355
  const int stub_start_offset = offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2356
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2357
  // For java_to_interp stubs we use R11_scratch1 as scratch register
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2358
  // and in call trampoline stubs we use R12_scratch2. This way we
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2359
  // can distinguish them (see is_NativeCallTrampolineStub_at()).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2360
  Register reg_scratch = R12_scratch2;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2361
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2362
  // Now, create the trampoline stub's code:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2363
  // - load the TOC
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2364
  // - load the call target from the constant pool
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2365
  // - call
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2366
  if (Rtoc == noreg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2367
    calculate_address_from_global_toc(reg_scratch, method_toc());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2368
    Rtoc = reg_scratch;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2369
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2370
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2371
  ld_largeoffset_unchecked(reg_scratch, destination_toc_offset, Rtoc, false);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2372
  mtctr(reg_scratch);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2373
  bctr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2374
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2375
  const address stub_start_addr = addr_at(stub_start_offset);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2376
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2377
  // Assert that the encoded destination_toc_offset can be identified and that it is correct.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2378
  assert(destination_toc_offset == NativeCallTrampolineStub_at(stub_start_addr)->destination_toc_offset(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2379
         "encoded offset into the constant pool must match");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2380
  // Trampoline_stub_size should be good.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2381
  assert((uint)(offset() - stub_start_offset) <= trampoline_stub_size, "should be good size");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2382
  assert(is_NativeCallTrampolineStub_at(stub_start_addr), "doesn't look like a trampoline");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2383
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2384
  // End the stub.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2385
  end_a_stub();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2386
  return stub;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2387
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2388
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2389
// TM on PPC64.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2390
void MacroAssembler::atomic_inc_ptr(Register addr, Register result, int simm16) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2391
  Label retry;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2392
  bind(retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2393
  ldarx(result, addr, /*hint*/ false);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2394
  addi(result, result, simm16);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2395
  stdcx_(result, addr);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2396
  if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2397
    bne_predict_not_taken(CCR0, retry); // stXcx_ sets CCR0
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2398
  } else {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2399
    bne(                  CCR0, retry); // stXcx_ sets CCR0
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2400
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2401
}
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2402
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2403
void MacroAssembler::atomic_ori_int(Register addr, Register result, int uimm16) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2404
  Label retry;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2405
  bind(retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2406
  lwarx(result, addr, /*hint*/ false);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2407
  ori(result, result, uimm16);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2408
  stwcx_(result, addr);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2409
  if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2410
    bne_predict_not_taken(CCR0, retry); // stXcx_ sets CCR0
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2411
  } else {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2412
    bne(                  CCR0, retry); // stXcx_ sets CCR0
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2413
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2414
}
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2415
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2416
#if INCLUDE_RTM_OPT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2417
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2418
// Update rtm_counters based on abort status
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2419
// input: abort_status
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2420
//        rtm_counters (RTMLockingCounters*)
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2421
void MacroAssembler::rtm_counters_update(Register abort_status, Register rtm_counters_Reg) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2422
  // Mapping to keep PreciseRTMLockingStatistics similar to x86.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2423
  // x86 ppc (! means inverted, ? means not the same)
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2424
  //  0   31  Set if abort caused by XABORT instruction.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2425
  //  1  ! 7  If set, the transaction may succeed on a retry. This bit is always clear if bit 0 is set.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2426
  //  2   13  Set if another logical processor conflicted with a memory address that was part of the transaction that aborted.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2427
  //  3   10  Set if an internal buffer overflowed.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2428
  //  4  ?12  Set if a debug breakpoint was hit.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2429
  //  5  ?32  Set if an abort occurred during execution of a nested transaction.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2430
  const  int tm_failure_bit[] = {Assembler::tm_tabort, // Note: Seems like signal handler sets this, too.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2431
                                 Assembler::tm_failure_persistent, // inverted: transient
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2432
                                 Assembler::tm_trans_cf,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2433
                                 Assembler::tm_footprint_of,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2434
                                 Assembler::tm_non_trans_cf,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2435
                                 Assembler::tm_suspended};
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2436
  const bool tm_failure_inv[] = {false, true, false, false, false, false};
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2437
  assert(sizeof(tm_failure_bit)/sizeof(int) == RTMLockingCounters::ABORT_STATUS_LIMIT, "adapt mapping!");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2438
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2439
  const Register addr_Reg = R0;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2440
  // Keep track of offset to where rtm_counters_Reg had pointed to.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2441
  int counters_offs = RTMLockingCounters::abort_count_offset();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2442
  addi(addr_Reg, rtm_counters_Reg, counters_offs);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2443
  const Register temp_Reg = rtm_counters_Reg;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2444
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2445
  //atomic_inc_ptr(addr_Reg, temp_Reg); We don't increment atomically
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2446
  ldx(temp_Reg, addr_Reg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2447
  addi(temp_Reg, temp_Reg, 1);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2448
  stdx(temp_Reg, addr_Reg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2449
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2450
  if (PrintPreciseRTMLockingStatistics) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2451
    int counters_offs_delta = RTMLockingCounters::abortX_count_offset() - counters_offs;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2452
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2453
    //mftexasr(abort_status); done by caller
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2454
    for (int i = 0; i < RTMLockingCounters::ABORT_STATUS_LIMIT; i++) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2455
      counters_offs += counters_offs_delta;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2456
      li(temp_Reg, counters_offs_delta); // can't use addi with R0
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2457
      add(addr_Reg, addr_Reg, temp_Reg); // point to next counter
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2458
      counters_offs_delta = sizeof(uintx);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2459
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2460
      Label check_abort;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2461
      rldicr_(temp_Reg, abort_status, tm_failure_bit[i], 0);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2462
      if (tm_failure_inv[i]) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2463
        bne(CCR0, check_abort);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2464
      } else {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2465
        beq(CCR0, check_abort);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2466
      }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2467
      //atomic_inc_ptr(addr_Reg, temp_Reg); We don't increment atomically
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2468
      ldx(temp_Reg, addr_Reg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2469
      addi(temp_Reg, temp_Reg, 1);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2470
      stdx(temp_Reg, addr_Reg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2471
      bind(check_abort);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2472
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2473
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2474
  li(temp_Reg, -counters_offs); // can't use addi with R0
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2475
  add(rtm_counters_Reg, addr_Reg, temp_Reg); // restore
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2476
}
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2477
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2478
// Branch if (random & (count-1) != 0), count is 2^n
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2479
// tmp and CR0 are killed
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2480
void MacroAssembler::branch_on_random_using_tb(Register tmp, int count, Label& brLabel) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2481
  mftb(tmp);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2482
  andi_(tmp, tmp, count-1);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2483
  bne(CCR0, brLabel);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2484
}
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2485
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2486
// Perform abort ratio calculation, set no_rtm bit if high ratio.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2487
// input:  rtm_counters_Reg (RTMLockingCounters* address) - KILLED
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2488
void MacroAssembler::rtm_abort_ratio_calculation(Register rtm_counters_Reg,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2489
                                                 RTMLockingCounters* rtm_counters,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2490
                                                 Metadata* method_data) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2491
  Label L_done, L_check_always_rtm1, L_check_always_rtm2;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2492
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2493
  if (RTMLockingCalculationDelay > 0) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2494
    // Delay calculation.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2495
    ld(rtm_counters_Reg, (RegisterOrConstant)(intptr_t)RTMLockingCounters::rtm_calculation_flag_addr());
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2496
    cmpdi(CCR0, rtm_counters_Reg, 0);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2497
    beq(CCR0, L_done);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2498
    load_const_optimized(rtm_counters_Reg, (address)rtm_counters, R0); // reload
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2499
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2500
  // Abort ratio calculation only if abort_count > RTMAbortThreshold.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2501
  //   Aborted transactions = abort_count * 100
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2502
  //   All transactions = total_count *  RTMTotalCountIncrRate
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2503
  //   Set no_rtm bit if (Aborted transactions >= All transactions * RTMAbortRatio)
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2504
  ld(R0, RTMLockingCounters::abort_count_offset(), rtm_counters_Reg);
46494
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2505
  if (is_simm(RTMAbortThreshold, 16)) {   // cmpdi can handle 16bit immediate only.
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2506
    cmpdi(CCR0, R0, RTMAbortThreshold);
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2507
    blt(CCR0, L_check_always_rtm2);  // reload of rtm_counters_Reg not necessary
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2508
  } else {
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2509
    load_const_optimized(rtm_counters_Reg, RTMAbortThreshold);
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2510
    cmpd(CCR0, R0, rtm_counters_Reg);
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2511
    blt(CCR0, L_check_always_rtm1);  // reload of rtm_counters_Reg required
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2512
  }
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2513
  mulli(R0, R0, 100);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2514
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2515
  const Register tmpReg = rtm_counters_Reg;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2516
  ld(tmpReg, RTMLockingCounters::total_count_offset(), rtm_counters_Reg);
46494
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2517
  mulli(tmpReg, tmpReg, RTMTotalCountIncrRate); // allowable range: int16
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2518
  mulli(tmpReg, tmpReg, RTMAbortRatio);         // allowable range: int16
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2519
  cmpd(CCR0, R0, tmpReg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2520
  blt(CCR0, L_check_always_rtm1); // jump to reload
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2521
  if (method_data != NULL) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2522
    // Set rtm_state to "no rtm" in MDO.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2523
    // Not using a metadata relocation. Method and Class Loader are kept alive anyway.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2524
    // (See nmethod::metadata_do and CodeBuffer::finalize_oop_references.)
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2525
    load_const(R0, (address)method_data + MethodData::rtm_state_offset_in_bytes(), tmpReg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2526
    atomic_ori_int(R0, tmpReg, NoRTM);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2527
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2528
  b(L_done);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2529
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2530
  bind(L_check_always_rtm1);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2531
  load_const_optimized(rtm_counters_Reg, (address)rtm_counters, R0); // reload
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2532
  bind(L_check_always_rtm2);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2533
  ld(tmpReg, RTMLockingCounters::total_count_offset(), rtm_counters_Reg);
46494
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2534
  int64_t thresholdValue = RTMLockingThreshold / RTMTotalCountIncrRate;
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2535
  if (is_simm(thresholdValue, 16)) {   // cmpdi can handle 16bit immediate only.
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2536
    cmpdi(CCR0, tmpReg, thresholdValue);
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2537
  } else {
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2538
    load_const_optimized(R0, thresholdValue);
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2539
    cmpd(CCR0, tmpReg, R0);
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2540
  }
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2541
  blt(CCR0, L_done);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2542
  if (method_data != NULL) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2543
    // Set rtm_state to "always rtm" in MDO.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2544
    // Not using a metadata relocation. See above.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2545
    load_const(R0, (address)method_data + MethodData::rtm_state_offset_in_bytes(), tmpReg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2546
    atomic_ori_int(R0, tmpReg, UseRTM);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2547
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2548
  bind(L_done);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2549
}
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2550
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2551
// Update counters and perform abort ratio calculation.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2552
// input: abort_status_Reg
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2553
void MacroAssembler::rtm_profiling(Register abort_status_Reg, Register temp_Reg,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2554
                                   RTMLockingCounters* rtm_counters,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2555
                                   Metadata* method_data,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2556
                                   bool profile_rtm) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2557
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2558
  assert(rtm_counters != NULL, "should not be NULL when profiling RTM");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2559
  // Update rtm counters based on state at abort.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2560
  // Reads abort_status_Reg, updates flags.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2561
  assert_different_registers(abort_status_Reg, temp_Reg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2562
  load_const_optimized(temp_Reg, (address)rtm_counters, R0);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2563
  rtm_counters_update(abort_status_Reg, temp_Reg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2564
  if (profile_rtm) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2565
    assert(rtm_counters != NULL, "should not be NULL when profiling RTM");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2566
    rtm_abort_ratio_calculation(temp_Reg, rtm_counters, method_data);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2567
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2568
}
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2569
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2570
// Retry on abort if abort's status indicates non-persistent failure.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2571
// inputs: retry_count_Reg
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2572
//       : abort_status_Reg
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2573
// output: retry_count_Reg decremented by 1
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2574
void MacroAssembler::rtm_retry_lock_on_abort(Register retry_count_Reg, Register abort_status_Reg,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2575
                                             Label& retryLabel, Label* checkRetry) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2576
  Label doneRetry;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2577
  rldicr_(R0, abort_status_Reg, tm_failure_persistent, 0);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2578
  bne(CCR0, doneRetry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2579
  if (checkRetry) { bind(*checkRetry); }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2580
  addic_(retry_count_Reg, retry_count_Reg, -1);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2581
  blt(CCR0, doneRetry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2582
  smt_yield(); // Can't use wait(). No permission (SIGILL).
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2583
  b(retryLabel);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2584
  bind(doneRetry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2585
}
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2586
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2587
// Spin and retry if lock is busy.
43428
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2588
// inputs: owner_addr_Reg (monitor address)
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2589
//       : retry_count_Reg
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2590
// output: retry_count_Reg decremented by 1
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2591
// CTR is killed
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2592
void MacroAssembler::rtm_retry_lock_on_busy(Register retry_count_Reg, Register owner_addr_Reg, Label& retryLabel) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2593
  Label SpinLoop, doneRetry;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2594
  addic_(retry_count_Reg, retry_count_Reg, -1);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2595
  blt(CCR0, doneRetry);
43428
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2596
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2597
  if (RTMSpinLoopCount > 1) {
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2598
    li(R0, RTMSpinLoopCount);
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2599
    mtctr(R0);
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2600
  }
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2601
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2602
  bind(SpinLoop);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2603
  smt_yield(); // Can't use waitrsv(). No permission (SIGILL).
43428
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2604
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2605
  if (RTMSpinLoopCount > 1) {
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2606
    bdz(retryLabel);
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2607
    ld(R0, 0, owner_addr_Reg);
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2608
    cmpdi(CCR0, R0, 0);
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2609
    bne(CCR0, SpinLoop);
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2610
  }
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42661
diff changeset
  2611
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2612
  b(retryLabel);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2613
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2614
  bind(doneRetry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2615
}
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2616
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2617
// Use RTM for normal stack locks.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2618
// Input: objReg (object to lock)
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2619
void MacroAssembler::rtm_stack_locking(ConditionRegister flag,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2620
                                       Register obj, Register mark_word, Register tmp,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2621
                                       Register retry_on_abort_count_Reg,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2622
                                       RTMLockingCounters* stack_rtm_counters,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2623
                                       Metadata* method_data, bool profile_rtm,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2624
                                       Label& DONE_LABEL, Label& IsInflated) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2625
  assert(UseRTMForStackLocks, "why call this otherwise?");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2626
  assert(!UseBiasedLocking, "Biased locking is not supported with RTM locking");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2627
  Label L_rtm_retry, L_decrement_retry, L_on_abort;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2628
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2629
  if (RTMRetryCount > 0) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2630
    load_const_optimized(retry_on_abort_count_Reg, RTMRetryCount); // Retry on abort
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2631
    bind(L_rtm_retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2632
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2633
  andi_(R0, mark_word, markOopDesc::monitor_value);  // inflated vs stack-locked|neutral|biased
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2634
  bne(CCR0, IsInflated);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2635
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2636
  if (PrintPreciseRTMLockingStatistics || profile_rtm) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2637
    Label L_noincrement;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2638
    if (RTMTotalCountIncrRate > 1) {
46494
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2639
      branch_on_random_using_tb(tmp, RTMTotalCountIncrRate, L_noincrement);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2640
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2641
    assert(stack_rtm_counters != NULL, "should not be NULL when profiling RTM");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2642
    load_const_optimized(tmp, (address)stack_rtm_counters->total_count_addr(), R0);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2643
    //atomic_inc_ptr(tmp, /*temp, will be reloaded*/mark_word); We don't increment atomically
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2644
    ldx(mark_word, tmp);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2645
    addi(mark_word, mark_word, 1);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2646
    stdx(mark_word, tmp);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2647
    bind(L_noincrement);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2648
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2649
  tbegin_();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2650
  beq(CCR0, L_on_abort);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2651
  ld(mark_word, oopDesc::mark_offset_in_bytes(), obj);         // Reload in transaction, conflicts need to be tracked.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2652
  andi(R0, mark_word, markOopDesc::biased_lock_mask_in_place); // look at 3 lock bits
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2653
  cmpwi(flag, R0, markOopDesc::unlocked_value);                // bits = 001 unlocked
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2654
  beq(flag, DONE_LABEL);                                       // all done if unlocked
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2655
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2656
  if (UseRTMXendForLockBusy) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2657
    tend_();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2658
    b(L_decrement_retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2659
  } else {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2660
    tabort_();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2661
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2662
  bind(L_on_abort);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2663
  const Register abort_status_Reg = tmp;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2664
  mftexasr(abort_status_Reg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2665
  if (PrintPreciseRTMLockingStatistics || profile_rtm) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2666
    rtm_profiling(abort_status_Reg, /*temp*/mark_word, stack_rtm_counters, method_data, profile_rtm);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2667
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2668
  ld(mark_word, oopDesc::mark_offset_in_bytes(), obj); // reload
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2669
  if (RTMRetryCount > 0) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2670
    // Retry on lock abort if abort status is not permanent.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2671
    rtm_retry_lock_on_abort(retry_on_abort_count_Reg, abort_status_Reg, L_rtm_retry, &L_decrement_retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2672
  } else {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2673
    bind(L_decrement_retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2674
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2675
}
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2676
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2677
// Use RTM for inflating locks
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2678
// inputs: obj       (object to lock)
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2679
//         mark_word (current header - KILLED)
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2680
//         boxReg    (on-stack box address (displaced header location) - KILLED)
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2681
void MacroAssembler::rtm_inflated_locking(ConditionRegister flag,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2682
                                          Register obj, Register mark_word, Register boxReg,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2683
                                          Register retry_on_busy_count_Reg, Register retry_on_abort_count_Reg,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2684
                                          RTMLockingCounters* rtm_counters,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2685
                                          Metadata* method_data, bool profile_rtm,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2686
                                          Label& DONE_LABEL) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2687
  assert(UseRTMLocking, "why call this otherwise?");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2688
  Label L_rtm_retry, L_decrement_retry, L_on_abort;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2689
  // Clean monitor_value bit to get valid pointer.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2690
  int owner_offset = ObjectMonitor::owner_offset_in_bytes() - markOopDesc::monitor_value;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2691
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2692
  // Store non-null, using boxReg instead of (intptr_t)markOopDesc::unused_mark().
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2693
  std(boxReg, BasicLock::displaced_header_offset_in_bytes(), boxReg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2694
  const Register tmpReg = boxReg;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2695
  const Register owner_addr_Reg = mark_word;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2696
  addi(owner_addr_Reg, mark_word, owner_offset);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2697
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2698
  if (RTMRetryCount > 0) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2699
    load_const_optimized(retry_on_busy_count_Reg, RTMRetryCount);  // Retry on lock busy.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2700
    load_const_optimized(retry_on_abort_count_Reg, RTMRetryCount); // Retry on abort.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2701
    bind(L_rtm_retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2702
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2703
  if (PrintPreciseRTMLockingStatistics || profile_rtm) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2704
    Label L_noincrement;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2705
    if (RTMTotalCountIncrRate > 1) {
46494
3fdd343bc5ea 8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
lucy
parents: 46369
diff changeset
  2706
      branch_on_random_using_tb(R0, RTMTotalCountIncrRate, L_noincrement);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2707
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2708
    assert(rtm_counters != NULL, "should not be NULL when profiling RTM");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2709
    load_const(R0, (address)rtm_counters->total_count_addr(), tmpReg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2710
    //atomic_inc_ptr(R0, tmpReg); We don't increment atomically
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2711
    ldx(tmpReg, R0);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2712
    addi(tmpReg, tmpReg, 1);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2713
    stdx(tmpReg, R0);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2714
    bind(L_noincrement);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2715
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2716
  tbegin_();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2717
  beq(CCR0, L_on_abort);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2718
  // We don't reload mark word. Will only be reset at safepoint.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2719
  ld(R0, 0, owner_addr_Reg); // Load in transaction, conflicts need to be tracked.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2720
  cmpdi(flag, R0, 0);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2721
  beq(flag, DONE_LABEL);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2722
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2723
  if (UseRTMXendForLockBusy) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2724
    tend_();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2725
    b(L_decrement_retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2726
  } else {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2727
    tabort_();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2728
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2729
  bind(L_on_abort);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2730
  const Register abort_status_Reg = tmpReg;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2731
  mftexasr(abort_status_Reg);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2732
  if (PrintPreciseRTMLockingStatistics || profile_rtm) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2733
    rtm_profiling(abort_status_Reg, /*temp*/ owner_addr_Reg, rtm_counters, method_data, profile_rtm);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2734
    // Restore owner_addr_Reg
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2735
    ld(mark_word, oopDesc::mark_offset_in_bytes(), obj);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2736
#ifdef ASSERT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2737
    andi_(R0, mark_word, markOopDesc::monitor_value);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2738
    asm_assert_ne("must be inflated", 0xa754); // Deflating only allowed at safepoint.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2739
#endif
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2740
    addi(owner_addr_Reg, mark_word, owner_offset);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2741
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2742
  if (RTMRetryCount > 0) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2743
    // Retry on lock abort if abort status is not permanent.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2744
    rtm_retry_lock_on_abort(retry_on_abort_count_Reg, abort_status_Reg, L_rtm_retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2745
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2746
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2747
  // Appears unlocked - try to swing _owner from null to non-null.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2748
  cmpxchgd(flag, /*current val*/ R0, (intptr_t)0, /*new val*/ R16_thread, owner_addr_Reg,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2749
           MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2750
           MacroAssembler::cmpxchgx_hint_acquire_lock(), noreg, &L_decrement_retry, true);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2751
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2752
  if (RTMRetryCount > 0) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2753
    // success done else retry
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2754
    b(DONE_LABEL);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2755
    bind(L_decrement_retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2756
    // Spin and retry if lock is busy.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2757
    rtm_retry_lock_on_busy(retry_on_busy_count_Reg, owner_addr_Reg, L_rtm_retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2758
  } else {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2759
    bind(L_decrement_retry);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2760
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2761
}
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2762
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2763
#endif //  INCLUDE_RTM_OPT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2764
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2765
// "The box" is the space on the stack where we copy the object mark.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2766
void MacroAssembler::compiler_fast_lock_object(ConditionRegister flag, Register oop, Register box,
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2767
                                               Register temp, Register displaced_header, Register current_header,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2768
                                               bool try_bias,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2769
                                               RTMLockingCounters* rtm_counters,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2770
                                               RTMLockingCounters* stack_rtm_counters,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2771
                                               Metadata* method_data,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2772
                                               bool use_rtm, bool profile_rtm) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2773
  assert_different_registers(oop, box, temp, displaced_header, current_header);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2774
  assert(flag != CCR0, "bad condition register");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2775
  Label cont;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2776
  Label object_has_monitor;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2777
  Label cas_failed;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2778
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2779
  // Load markOop from object into displaced_header.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2780
  ld(displaced_header, oopDesc::mark_offset_in_bytes(), oop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2781
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2782
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2783
  // Always do locking in runtime.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2784
  if (EmitSync & 0x01) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2785
    cmpdi(flag, oop, 0); // Oop can't be 0 here => always false.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2786
    return;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2787
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2788
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2789
  if (try_bias) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2790
    biased_locking_enter(flag, oop, displaced_header, temp, current_header, cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2791
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2792
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2793
#if INCLUDE_RTM_OPT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2794
  if (UseRTMForStackLocks && use_rtm) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2795
    rtm_stack_locking(flag, oop, displaced_header, temp, /*temp*/ current_header,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2796
                      stack_rtm_counters, method_data, profile_rtm,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2797
                      cont, object_has_monitor);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2798
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2799
#endif // INCLUDE_RTM_OPT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2800
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2801
  // Handle existing monitor.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2802
  if ((EmitSync & 0x02) == 0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2803
    // The object has an existing monitor iff (mark & monitor_value) != 0.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2804
    andi_(temp, displaced_header, markOopDesc::monitor_value);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2805
    bne(CCR0, object_has_monitor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2806
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2807
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2808
  // Set displaced_header to be (markOop of object | UNLOCK_VALUE).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2809
  ori(displaced_header, displaced_header, markOopDesc::unlocked_value);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2810
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2811
  // Load Compare Value application register.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2812
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2813
  // Initialize the box. (Must happen before we update the object mark!)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2814
  std(displaced_header, BasicLock::displaced_header_offset_in_bytes(), box);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2815
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2816
  // Must fence, otherwise, preceding store(s) may float below cmpxchg.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2817
  // Compare object markOop with mark and if equal exchange scratch1 with object markOop.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2818
  cmpxchgd(/*flag=*/flag,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2819
           /*current_value=*/current_header,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2820
           /*compare_value=*/displaced_header,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2821
           /*exchange_value=*/box,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2822
           /*where=*/oop,
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2823
           MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2824
           MacroAssembler::cmpxchgx_hint_acquire_lock(),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2825
           noreg,
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2826
           &cas_failed,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2827
           /*check without membar and ldarx first*/true);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2828
  assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2829
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2830
  // If the compare-and-exchange succeeded, then we found an unlocked
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2831
  // object and we have now locked it.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2832
  b(cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2833
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2834
  bind(cas_failed);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2835
  // We did not see an unlocked object so try the fast recursive case.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2836
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2837
  // Check if the owner is self by comparing the value in the markOop of object
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2838
  // (current_header) with the stack pointer.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2839
  sub(current_header, current_header, R1_SP);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  2840
  load_const_optimized(temp, ~(os::vm_page_size()-1) | markOopDesc::lock_mask_in_place);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2841
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2842
  and_(R0/*==0?*/, current_header, temp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2843
  // If condition is true we are cont and hence we can store 0 as the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2844
  // displaced header in the box, which indicates that it is a recursive lock.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2845
  mcrf(flag,CCR0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2846
  std(R0/*==0, perhaps*/, BasicLock::displaced_header_offset_in_bytes(), box);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2847
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2848
  // Handle existing monitor.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2849
  if ((EmitSync & 0x02) == 0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2850
    b(cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2851
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2852
    bind(object_has_monitor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2853
    // The object's monitor m is unlocked iff m->owner == NULL,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2854
    // otherwise m->owner may contain a thread or a stack address.
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2855
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2856
#if INCLUDE_RTM_OPT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2857
    // Use the same RTM locking code in 32- and 64-bit VM.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2858
    if (use_rtm) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2859
      rtm_inflated_locking(flag, oop, displaced_header, box, temp, /*temp*/ current_header,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2860
                           rtm_counters, method_data, profile_rtm, cont);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2861
    } else {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2862
#endif // INCLUDE_RTM_OPT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2863
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2864
    // Try to CAS m->owner from NULL to current thread.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2865
    addi(temp, displaced_header, ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2866
    cmpxchgd(/*flag=*/flag,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2867
             /*current_value=*/current_header,
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2868
             /*compare_value=*/(intptr_t)0,
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2869
             /*exchange_value=*/R16_thread,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2870
             /*where=*/temp,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2871
             MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2872
             MacroAssembler::cmpxchgx_hint_acquire_lock());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2873
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2874
    // Store a non-null value into the box.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2875
    std(box, BasicLock::displaced_header_offset_in_bytes(), box);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2876
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2877
#   ifdef ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2878
    bne(flag, cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2879
    // We have acquired the monitor, check some invariants.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2880
    addi(/*monitor=*/temp, temp, -ObjectMonitor::owner_offset_in_bytes());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2881
    // Invariant 1: _recursions should be 0.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2882
    //assert(ObjectMonitor::recursions_size_in_bytes() == 8, "unexpected size");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2883
    asm_assert_mem8_is_zero(ObjectMonitor::recursions_offset_in_bytes(), temp,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2884
                            "monitor->_recursions should be 0", -1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2885
#   endif
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2886
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2887
#if INCLUDE_RTM_OPT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2888
    } // use_rtm()
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2889
#endif
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2890
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2891
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2892
  bind(cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2893
  // flag == EQ indicates success
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2894
  // flag == NE indicates failure
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2895
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2896
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2897
void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Register oop, Register box,
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2898
                                                 Register temp, Register displaced_header, Register current_header,
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2899
                                                 bool try_bias, bool use_rtm) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2900
  assert_different_registers(oop, box, temp, displaced_header, current_header);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2901
  assert(flag != CCR0, "bad condition register");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2902
  Label cont;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2903
  Label object_has_monitor;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2904
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2905
  // Always do locking in runtime.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2906
  if (EmitSync & 0x01) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2907
    cmpdi(flag, oop, 0); // Oop can't be 0 here => always false.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2908
    return;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2909
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2910
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2911
  if (try_bias) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2912
    biased_locking_exit(flag, oop, current_header, cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2913
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2914
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2915
#if INCLUDE_RTM_OPT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2916
  if (UseRTMForStackLocks && use_rtm) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2917
    assert(!UseBiasedLocking, "Biased locking is not supported with RTM locking");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2918
    Label L_regular_unlock;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2919
    ld(current_header, oopDesc::mark_offset_in_bytes(), oop);         // fetch markword
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2920
    andi(R0, current_header, markOopDesc::biased_lock_mask_in_place); // look at 3 lock bits
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2921
    cmpwi(flag, R0, markOopDesc::unlocked_value);                     // bits = 001 unlocked
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2922
    bne(flag, L_regular_unlock);                                      // else RegularLock
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2923
    tend_();                                                          // otherwise end...
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2924
    b(cont);                                                          // ... and we're done
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2925
    bind(L_regular_unlock);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2926
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2927
#endif
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2928
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2929
  // Find the lock address and load the displaced header from the stack.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2930
  ld(displaced_header, BasicLock::displaced_header_offset_in_bytes(), box);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2931
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2932
  // If the displaced header is 0, we have a recursive unlock.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2933
  cmpdi(flag, displaced_header, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2934
  beq(flag, cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2935
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2936
  // Handle existing monitor.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2937
  if ((EmitSync & 0x02) == 0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2938
    // The object has an existing monitor iff (mark & monitor_value) != 0.
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2939
    RTM_OPT_ONLY( if (!(UseRTMForStackLocks && use_rtm)) ) // skip load if already done
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2940
    ld(current_header, oopDesc::mark_offset_in_bytes(), oop);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2941
    andi_(R0, current_header, markOopDesc::monitor_value);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2942
    bne(CCR0, object_has_monitor);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2943
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2944
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2945
  // Check if it is still a light weight lock, this is is true if we see
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2946
  // the stack address of the basicLock in the markOop of the object.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2947
  // Cmpxchg sets flag to cmpd(current_header, box).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2948
  cmpxchgd(/*flag=*/flag,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2949
           /*current_value=*/current_header,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2950
           /*compare_value=*/box,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2951
           /*exchange_value=*/displaced_header,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2952
           /*where=*/oop,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2953
           MacroAssembler::MemBarRel,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2954
           MacroAssembler::cmpxchgx_hint_release_lock(),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2955
           noreg,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2956
           &cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2957
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2958
  assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2959
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2960
  // Handle existing monitor.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2961
  if ((EmitSync & 0x02) == 0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2962
    b(cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2963
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2964
    bind(object_has_monitor);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2965
    addi(current_header, current_header, -markOopDesc::monitor_value); // monitor
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2966
    ld(temp,             ObjectMonitor::owner_offset_in_bytes(), current_header);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2967
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2968
    // It's inflated.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2969
#if INCLUDE_RTM_OPT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2970
    if (use_rtm) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2971
      Label L_regular_inflated_unlock;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2972
      // Clean monitor_value bit to get valid pointer
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2973
      cmpdi(flag, temp, 0);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2974
      bne(flag, L_regular_inflated_unlock);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2975
      tend_();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2976
      b(cont);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2977
      bind(L_regular_inflated_unlock);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2978
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2979
#endif
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  2980
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2981
    ld(displaced_header, ObjectMonitor::recursions_offset_in_bytes(), current_header);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2982
    xorr(temp, R16_thread, temp);      // Will be 0 if we are the owner.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2983
    orr(temp, temp, displaced_header); // Will be 0 if there are 0 recursions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2984
    cmpdi(flag, temp, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2985
    bne(flag, cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2986
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2987
    ld(temp,             ObjectMonitor::EntryList_offset_in_bytes(), current_header);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2988
    ld(displaced_header, ObjectMonitor::cxq_offset_in_bytes(), current_header);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2989
    orr(temp, temp, displaced_header); // Will be 0 if both are 0.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2990
    cmpdi(flag, temp, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2991
    bne(flag, cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2992
    release();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2993
    std(temp, ObjectMonitor::owner_offset_in_bytes(), current_header);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2994
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2995
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2996
  bind(cont);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2997
  // flag == EQ indicates success
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2998
  // flag == NE indicates failure
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  2999
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3000
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3001
// Write serialization page so VM thread can do a pseudo remote membar.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3002
// We use the current thread pointer to calculate a thread specific
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3003
// offset to write to within the page. This minimizes bus traffic
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3004
// due to cache line collision.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3005
void MacroAssembler::serialize_memory(Register thread, Register tmp1, Register tmp2) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3006
  srdi(tmp2, thread, os::get_serialize_page_shift_count());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3007
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3008
  int mask = os::vm_page_size() - sizeof(int);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3009
  if (Assembler::is_simm(mask, 16)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3010
    andi(tmp2, tmp2, mask);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3011
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3012
    lis(tmp1, (int)((signed short) (mask >> 16)));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3013
    ori(tmp1, tmp1, mask & 0x0000ffff);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3014
    andr(tmp2, tmp2, tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3015
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3016
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3017
  load_const(tmp1, (long) os::get_memory_serialize_page());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3018
  release();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3019
  stwx(R0, tmp1, tmp2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3020
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3021
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3022
void MacroAssembler::safepoint_poll(Label& slow_path, Register temp_reg) {
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3023
  if (SafepointMechanism::uses_thread_local_poll()) {
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3024
    ld(temp_reg, in_bytes(Thread::polling_page_offset()), R16_thread);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3025
    // Armed page has poll_bit set.
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3026
    andi_(temp_reg, temp_reg, SafepointMechanism::poll_bit());
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3027
  } else {
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3028
    lwz(temp_reg, (RegisterOrConstant)(intptr_t)SafepointSynchronize::address_of_state());
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3029
    cmpwi(CCR0, temp_reg, SafepointSynchronize::_not_synchronized);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3030
  }
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3031
  bne(CCR0, slow_path);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3032
}
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47580
diff changeset
  3033
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3034
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3035
// GC barrier helper macros
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3036
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3037
// Write the card table byte if needed.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3038
void MacroAssembler::card_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp) {
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 28187
diff changeset
  3039
  CardTableModRefBS* bs =
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 28187
diff changeset
  3040
    barrier_set_cast<CardTableModRefBS>(Universe::heap()->barrier_set());
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3041
  assert(bs->kind() == BarrierSet::CardTableModRef, "wrong barrier");
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3042
  CardTable* ct = bs->card_table();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3043
#ifdef ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3044
  cmpdi(CCR0, Rnew_val, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3045
  asm_assert_ne("null oop not allowed", 0x321);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3046
#endif
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3047
  card_table_write(ct->byte_map_base(), Rtmp, Rstore_addr);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3048
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3049
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3050
// Write the card table byte.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3051
void MacroAssembler::card_table_write(jbyte* byte_map_base, Register Rtmp, Register Robj) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3052
  assert_different_registers(Robj, Rtmp, R0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3053
  load_const_optimized(Rtmp, (address)byte_map_base, R0);
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3054
  srdi(Robj, Robj, CardTable::card_shift);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3055
  li(R0, 0); // dirty
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  3056
  if (UseConcMarkSweepGC) membar(Assembler::StoreStore);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3057
  stbx(R0, Rtmp, Robj);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3058
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3059
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3060
// Kills R31 if value is a volatile register.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3061
void MacroAssembler::resolve_jobject(Register value, Register tmp1, Register tmp2, bool needs_frame) {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3062
  Label done;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3063
  cmpdi(CCR0, value, 0);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3064
  beq(CCR0, done);         // Use NULL as-is.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3065
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3066
  clrrdi(tmp1, value, JNIHandles::weak_tag_size);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3067
#if INCLUDE_ALL_GCS
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3068
  if (UseG1GC) { andi_(tmp2, value, JNIHandles::weak_tag_mask); }
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3069
#endif
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3070
  ld(value, 0, tmp1);      // Resolve (untagged) jobject.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3071
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3072
#if INCLUDE_ALL_GCS
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3073
  if (UseG1GC) {
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3074
    Label not_weak;
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3075
    beq(CCR0, not_weak);   // Test for jweak tag.
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3076
    verify_oop(value);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3077
    g1_write_barrier_pre(noreg, // obj
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3078
                         noreg, // offset
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3079
                         value, // pre_val
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3080
                         tmp1, tmp2, needs_frame);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3081
    bind(not_weak);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3082
  }
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3083
#endif // INCLUDE_ALL_GCS
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3084
  verify_oop(value);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3085
  bind(done);
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3086
}
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3087
23492
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23221
diff changeset
  3088
#if INCLUDE_ALL_GCS
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3089
// General G1 pre-barrier generator.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3090
// Goal: record the previous value if it is not null.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3091
void MacroAssembler::g1_write_barrier_pre(Register Robj, RegisterOrConstant offset, Register Rpre_val,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3092
                                          Register Rtmp1, Register Rtmp2, bool needs_frame) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3093
  Label runtime, filtered;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3094
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3095
  // Is marking active?
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33198
diff changeset
  3096
  if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33198
diff changeset
  3097
    lwz(Rtmp1, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), R16_thread);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3098
  } else {
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33198
diff changeset
  3099
    guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33198
diff changeset
  3100
    lbz(Rtmp1, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), R16_thread);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3101
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3102
  cmpdi(CCR0, Rtmp1, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3103
  beq(CCR0, filtered);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3104
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3105
  // Do we need to load the previous value?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3106
  if (Robj != noreg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3107
    // Load the previous value...
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3108
    if (UseCompressedOops) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3109
      lwz(Rpre_val, offset, Robj);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3110
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3111
      ld(Rpre_val, offset, Robj);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3112
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3113
    // Previous value has been loaded into Rpre_val.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3114
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3115
  assert(Rpre_val != noreg, "must have a real register");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3116
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3117
  // Is the previous value null?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3118
  cmpdi(CCR0, Rpre_val, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3119
  beq(CCR0, filtered);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3120
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3121
  if (Robj != noreg && UseCompressedOops) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3122
    decode_heap_oop_not_null(Rpre_val);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3123
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3124
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3125
  // OK, it's not filtered, so we'll need to call enqueue. In the normal
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3126
  // case, pre_val will be a scratch G-reg, but there are some cases in
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3127
  // which it's an O-reg. In the first case, do a normal call. In the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3128
  // latter, do a save here and call the frameless version.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3129
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3130
  // Can we store original value in the thread's buffer?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3131
  // Is index == 0?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3132
  // (The index field is typed as size_t.)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3133
  const Register Rbuffer = Rtmp1, Rindex = Rtmp2;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3134
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33198
diff changeset
  3135
  ld(Rindex, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_index()), R16_thread);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3136
  cmpdi(CCR0, Rindex, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3137
  beq(CCR0, runtime); // If index == 0, goto runtime.
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33198
diff changeset
  3138
  ld(Rbuffer, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_buf()), R16_thread);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3139
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3140
  addi(Rindex, Rindex, -wordSize); // Decrement index.
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33198
diff changeset
  3141
  std(Rindex, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_index()), R16_thread);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3142
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3143
  // Record the previous value.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3144
  stdx(Rpre_val, Rbuffer, Rindex);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3145
  b(filtered);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3146
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3147
  bind(runtime);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3148
44406
a46a6c4d1dd9 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents: 44093
diff changeset
  3149
  // May need to preserve LR. Also needed if current frame is not compatible with C calling convention.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3150
  if (needs_frame) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3151
    save_LR_CR(Rtmp1);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  3152
    push_frame_reg_args(0, Rtmp2);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3153
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3154
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3155
  if (Rpre_val->is_volatile() && Robj == noreg) mr(R31, Rpre_val); // Save pre_val across C call if it was preloaded.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3156
  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), Rpre_val, R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3157
  if (Rpre_val->is_volatile() && Robj == noreg) mr(Rpre_val, R31); // restore
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3158
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3159
  if (needs_frame) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3160
    pop_frame();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3161
    restore_LR_CR(Rtmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3162
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3163
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3164
  bind(filtered);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3165
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3166
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3167
// General G1 post-barrier generator
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3168
// Store cross-region card.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3169
void MacroAssembler::g1_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp1, Register Rtmp2, Register Rtmp3, Label *filtered_ext) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3170
  Label runtime, filtered_int;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3171
  Label& filtered = (filtered_ext != NULL) ? *filtered_ext : filtered_int;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3172
  assert_different_registers(Rstore_addr, Rnew_val, Rtmp1, Rtmp2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3173
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
  3174
  G1BarrierSet* bs =
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
  3175
    barrier_set_cast<G1BarrierSet>(Universe::heap()->barrier_set());
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3176
  CardTable* ct = bs->card_table();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3177
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3178
  // Does store cross heap regions?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3179
  if (G1RSBarrierRegionFilter) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3180
    xorr(Rtmp1, Rstore_addr, Rnew_val);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3181
    srdi_(Rtmp1, Rtmp1, HeapRegion::LogOfHRGrainBytes);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3182
    beq(CCR0, filtered);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3183
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3184
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3185
  // Crosses regions, storing NULL?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3186
#ifdef ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3187
  cmpdi(CCR0, Rnew_val, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3188
  asm_assert_ne("null oop not allowed (G1)", 0x322); // Checked by caller on PPC64, so following branch is obsolete:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3189
  //beq(CCR0, filtered);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3190
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3191
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3192
  // Storing region crossing non-NULL, is card already dirty?
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3193
  assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3194
  const Register Rcard_addr = Rtmp1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3195
  Register Rbase = Rtmp2;
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3196
  load_const_optimized(Rbase, (address)ct->byte_map_base(), /*temp*/ Rtmp3);
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3197
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3198
  srdi(Rcard_addr, Rstore_addr, CardTable::card_shift);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3199
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3200
  // Get the address of the card.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3201
  lbzx(/*card value*/ Rtmp3, Rbase, Rcard_addr);
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3202
  cmpwi(CCR0, Rtmp3, (int)G1CardTable::g1_young_card_val());
23492
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23221
diff changeset
  3203
  beq(CCR0, filtered);
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23221
diff changeset
  3204
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23221
diff changeset
  3205
  membar(Assembler::StoreLoad);
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23221
diff changeset
  3206
  lbzx(/*card value*/ Rtmp3, Rbase, Rcard_addr);  // Reload after membar.
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3207
  cmpwi(CCR0, Rtmp3 /* card value */, CardTable::dirty_card_val());
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3208
  beq(CCR0, filtered);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3209
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3210
  // Storing a region crossing, non-NULL oop, card is clean.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3211
  // Dirty card and log.
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49010
diff changeset
  3212
  li(Rtmp3, CardTable::dirty_card_val());
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3213
  //release(); // G1: oops are allowed to get visible after dirty marking.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3214
  stbx(Rtmp3, Rbase, Rcard_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3215
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3216
  add(Rcard_addr, Rbase, Rcard_addr); // This is the address which needs to get enqueued.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3217
  Rbase = noreg; // end of lifetime
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3218
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3219
  const Register Rqueue_index = Rtmp2,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3220
                 Rqueue_buf   = Rtmp3;
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33198
diff changeset
  3221
  ld(Rqueue_index, in_bytes(JavaThread::dirty_card_queue_offset() + DirtyCardQueue::byte_offset_of_index()), R16_thread);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3222
  cmpdi(CCR0, Rqueue_index, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3223
  beq(CCR0, runtime); // index == 0 then jump to runtime
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33198
diff changeset
  3224
  ld(Rqueue_buf, in_bytes(JavaThread::dirty_card_queue_offset() + DirtyCardQueue::byte_offset_of_buf()), R16_thread);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3225
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3226
  addi(Rqueue_index, Rqueue_index, -wordSize); // decrement index
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33198
diff changeset
  3227
  std(Rqueue_index, in_bytes(JavaThread::dirty_card_queue_offset() + DirtyCardQueue::byte_offset_of_index()), R16_thread);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3228
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3229
  stdx(Rcard_addr, Rqueue_buf, Rqueue_index); // store card
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3230
  b(filtered);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3231
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3232
  bind(runtime);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3233
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3234
  // Save the live input values.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3235
  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), Rcard_addr, R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3236
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3237
  bind(filtered_int);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3238
}
23492
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23221
diff changeset
  3239
#endif // INCLUDE_ALL_GCS
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3240
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3241
// Values for last_Java_pc, and last_Java_sp must comply to the rules
27012
f8fdfab4757b 8059592: Recent bugfixes in ppc64 port.
goetz
parents: 25715
diff changeset
  3242
// in frame_ppc.hpp.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3243
void MacroAssembler::set_last_Java_frame(Register last_Java_sp, Register last_Java_pc) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3244
  // Always set last_Java_pc and flags first because once last_Java_sp
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3245
  // is visible has_last_Java_frame is true and users will look at the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3246
  // rest of the fields. (Note: flags should always be zero before we
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3247
  // get here so doesn't need to be set.)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3248
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3249
  // Verify that last_Java_pc was zeroed on return to Java
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3250
  asm_assert_mem8_is_zero(in_bytes(JavaThread::last_Java_pc_offset()), R16_thread,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3251
                          "last_Java_pc not zeroed before leaving Java", 0x200);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3252
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3253
  // When returning from calling out from Java mode the frame anchor's
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3254
  // last_Java_pc will always be set to NULL. It is set here so that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3255
  // if we are doing a call to native (not VM) that we capture the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3256
  // known pc and don't have to rely on the native call having a
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3257
  // standard frame linkage where we can find the pc.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3258
  if (last_Java_pc != noreg)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3259
    std(last_Java_pc, in_bytes(JavaThread::last_Java_pc_offset()), R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3260
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3261
  // Set last_Java_sp last.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3262
  std(last_Java_sp, in_bytes(JavaThread::last_Java_sp_offset()), R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3263
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3264
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3265
void MacroAssembler::reset_last_Java_frame(void) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3266
  asm_assert_mem8_isnot_zero(in_bytes(JavaThread::last_Java_sp_offset()),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3267
                             R16_thread, "SP was not set, still zero", 0x202);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3268
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3269
  BLOCK_COMMENT("reset_last_Java_frame {");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3270
  li(R0, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3271
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3272
  // _last_Java_sp = 0
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3273
  std(R0, in_bytes(JavaThread::last_Java_sp_offset()), R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3274
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3275
  // _last_Java_pc = 0
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3276
  std(R0, in_bytes(JavaThread::last_Java_pc_offset()), R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3277
  BLOCK_COMMENT("} reset_last_Java_frame");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3278
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3279
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3280
void MacroAssembler::set_top_ijava_frame_at_SP_as_last_Java_frame(Register sp, Register tmp1) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3281
  assert_different_registers(sp, tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3282
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3283
  // sp points to a TOP_IJAVA_FRAME, retrieve frame's PC via
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3284
  // TOP_IJAVA_FRAME_ABI.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3285
  // FIXME: assert that we really have a TOP_IJAVA_FRAME here!
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3286
  address entry = pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3287
  load_const_optimized(tmp1, entry);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3288
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3289
  set_last_Java_frame(/*sp=*/sp, /*pc=*/tmp1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3290
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3291
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3292
void MacroAssembler::get_vm_result(Register oop_result) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3293
  // Read:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3294
  //   R16_thread
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3295
  //   R16_thread->in_bytes(JavaThread::vm_result_offset())
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3296
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3297
  // Updated:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3298
  //   oop_result
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3299
  //   R16_thread->in_bytes(JavaThread::vm_result_offset())
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3300
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  3301
  verify_thread();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  3302
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3303
  ld(oop_result, in_bytes(JavaThread::vm_result_offset()), R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3304
  li(R0, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3305
  std(R0, in_bytes(JavaThread::vm_result_offset()), R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3306
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3307
  verify_oop(oop_result);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3308
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3309
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3310
void MacroAssembler::get_vm_result_2(Register metadata_result) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3311
  // Read:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3312
  //   R16_thread
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3313
  //   R16_thread->in_bytes(JavaThread::vm_result_2_offset())
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3314
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3315
  // Updated:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3316
  //   metadata_result
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3317
  //   R16_thread->in_bytes(JavaThread::vm_result_2_offset())
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3318
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3319
  ld(metadata_result, in_bytes(JavaThread::vm_result_2_offset()), R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3320
  li(R0, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3321
  std(R0, in_bytes(JavaThread::vm_result_2_offset()), R16_thread);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3322
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3323
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  3324
Register MacroAssembler::encode_klass_not_null(Register dst, Register src) {
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  3325
  Register current = (src != noreg) ? src : dst; // Klass is in dst if no src provided.
22843
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3326
  if (Universe::narrow_klass_base() != 0) {
23492
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23221
diff changeset
  3327
    // Use dst as temp if it is free.
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  3328
    sub_const_optimized(dst, current, Universe::narrow_klass_base(), R0);
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  3329
    current = dst;
22843
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3330
  }
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  3331
  if (Universe::narrow_klass_shift() != 0) {
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  3332
    srdi(dst, current, Universe::narrow_klass_shift());
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
  3333
    current = dst;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3334
  }
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  3335
  return current;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3336
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3337
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3338
void MacroAssembler::store_klass(Register dst_oop, Register klass, Register ck) {
22840
e544827769a7 8027965: Adapt PPC to 8015107: NPG: Use consistent naming for metaspace concepts
goetz
parents: 22829
diff changeset
  3339
  if (UseCompressedClassPointers) {
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  3340
    Register compressedKlass = encode_klass_not_null(ck, klass);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  3341
    stw(compressedKlass, oopDesc::klass_offset_in_bytes(), dst_oop);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3342
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3343
    std(klass, oopDesc::klass_offset_in_bytes(), dst_oop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3344
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3345
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3346
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3347
void MacroAssembler::store_klass_gap(Register dst_oop, Register val) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3348
  if (UseCompressedClassPointers) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3349
    if (val == noreg) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3350
      val = R0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3351
      li(val, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3352
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3353
    stw(val, oopDesc::klass_gap_offset_in_bytes(), dst_oop); // klass gap if compressed
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3354
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3355
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  3356
22843
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3357
int MacroAssembler::instr_size_for_decode_klass_not_null() {
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3358
  if (!UseCompressedClassPointers) return 0;
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3359
  int num_instrs = 1;  // shift or move
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3360
  if (Universe::narrow_klass_base() != 0) num_instrs = 7;  // shift + load const + add
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3361
  return num_instrs * BytesPerInstWord;
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3362
}
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3363
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3364
void MacroAssembler::decode_klass_not_null(Register dst, Register src) {
27012
f8fdfab4757b 8059592: Recent bugfixes in ppc64 port.
goetz
parents: 25715
diff changeset
  3365
  assert(dst != R0, "Dst reg may not be R0, as R0 is used here.");
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3366
  if (src == noreg) src = dst;
22829
08b62d0e80ed 8024379: Adapt PPC64 port to 8003424
goetz
parents: 22824
diff changeset
  3367
  Register shifted_src = src;
22843
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3368
  if (Universe::narrow_klass_shift() != 0 ||
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3369
      Universe::narrow_klass_base() == 0 && src != dst) {  // Move required.
22829
08b62d0e80ed 8024379: Adapt PPC64 port to 8003424
goetz
parents: 22824
diff changeset
  3370
    shifted_src = dst;
08b62d0e80ed 8024379: Adapt PPC64 port to 8003424
goetz
parents: 22824
diff changeset
  3371
    sldi(shifted_src, src, Universe::narrow_klass_shift());
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3372
  }
22843
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3373
  if (Universe::narrow_klass_base() != 0) {
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29325
diff changeset
  3374
    add_const_optimized(dst, shifted_src, Universe::narrow_klass_base(), R0);
22843
b245fac3b6a4 8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents: 22840
diff changeset
  3375
  }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3376
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3377
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3378
void MacroAssembler::load_klass(Register dst, Register src) {
22840
e544827769a7 8027965: Adapt PPC to 8015107: NPG: Use consistent naming for metaspace concepts
goetz
parents: 22829
diff changeset
  3379
  if (UseCompressedClassPointers) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3380
    lwz(dst, oopDesc::klass_offset_in_bytes(), src);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3381
    // Attention: no null check here!
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3382
    decode_klass_not_null(dst, dst);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3383
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3384
    ld(dst, oopDesc::klass_offset_in_bytes(), src);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3385
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3386
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3387
46961
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46789
diff changeset
  3388
// ((OopHandle)result).resolve();
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46789
diff changeset
  3389
void MacroAssembler::resolve_oop_handle(Register result) {
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46789
diff changeset
  3390
  // OopHandle::resolve is an indirection.
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46789
diff changeset
  3391
  ld(result, 0, result);
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46789
diff changeset
  3392
}
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46789
diff changeset
  3393
42068
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41334
diff changeset
  3394
void MacroAssembler::load_mirror_from_const_method(Register mirror, Register const_method) {
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41334
diff changeset
  3395
  ld(mirror, in_bytes(ConstMethod::constants_offset()), const_method);
38074
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 36303
diff changeset
  3396
  ld(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror);
42068
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41334
diff changeset
  3397
  ld(mirror, in_bytes(Klass::java_mirror_offset()), mirror);
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47521
diff changeset
  3398
  resolve_oop_handle(mirror);
38074
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 36303
diff changeset
  3399
}
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 36303
diff changeset
  3400
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3401
// Clear Array
42661
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3402
// For very short arrays. tmp == R0 is allowed.
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3403
void MacroAssembler::clear_memory_unrolled(Register base_ptr, int cnt_dwords, Register tmp, int offset) {
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3404
  if (cnt_dwords > 0) { li(tmp, 0); }
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3405
  for (int i = 0; i < cnt_dwords; ++i) { std(tmp, offset + i * 8, base_ptr); }
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3406
}
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3407
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3408
// Version for constant short array length. Kills base_ptr. tmp == R0 is allowed.
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3409
void MacroAssembler::clear_memory_constlen(Register base_ptr, int cnt_dwords, Register tmp) {
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3410
  if (cnt_dwords < 8) {
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3411
    clear_memory_unrolled(base_ptr, cnt_dwords, tmp);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3412
    return;
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3413
  }
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3414
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3415
  Label loop;
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3416
  const long loopcnt   = cnt_dwords >> 1,
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3417
             remainder = cnt_dwords & 1;
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3418
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3419
  li(tmp, loopcnt);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3420
  mtctr(tmp);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3421
  li(tmp, 0);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3422
  bind(loop);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3423
    std(tmp, 0, base_ptr);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3424
    std(tmp, 8, base_ptr);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3425
    addi(base_ptr, base_ptr, 16);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3426
    bdnz(loop);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3427
  if (remainder) { std(tmp, 0, base_ptr); }
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3428
}
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3429
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3430
// Kills both input registers. tmp == R0 is allowed.
42661
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3431
void MacroAssembler::clear_memory_doubleword(Register base_ptr, Register cnt_dwords, Register tmp, long const_cnt) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3432
  // Procedure for large arrays (uses data cache block zero instruction).
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3433
    Label startloop, fast, fastloop, small_rest, restloop, done;
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  3434
    const int cl_size         = VM_Version::L1_data_cache_line_size(),
42661
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3435
              cl_dwords       = cl_size >> 3,
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3436
              cl_dw_addr_bits = exact_log2(cl_dwords),
42661
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3437
              dcbz_min        = 1,  // Min count of dcbz executions, needs to be >0.
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3438
              min_cnt         = ((dcbz_min + 1) << cl_dw_addr_bits) - 1;
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3439
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3440
  if (const_cnt >= 0) {
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3441
    // Constant case.
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3442
    if (const_cnt < min_cnt) {
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3443
      clear_memory_constlen(base_ptr, const_cnt, tmp);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3444
      return;
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3445
    }
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3446
    load_const_optimized(cnt_dwords, const_cnt, tmp);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3447
  } else {
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3448
    // cnt_dwords already loaded in register. Need to check size.
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3449
    cmpdi(CCR1, cnt_dwords, min_cnt); // Big enough? (ensure >= dcbz_min lines included).
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3450
    blt(CCR1, small_rest);
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3451
  }
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3452
    rldicl_(tmp, base_ptr, 64-3, 64-cl_dw_addr_bits); // Extract dword offset within first cache line.
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3453
    beq(CCR0, fast);                                  // Already 128byte aligned.
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3454
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3455
    subfic(tmp, tmp, cl_dwords);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3456
    mtctr(tmp);                        // Set ctr to hit 128byte boundary (0<ctr<cl_dwords).
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3457
    subf(cnt_dwords, tmp, cnt_dwords); // rest.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3458
    li(tmp, 0);
42661
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3459
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3460
  bind(startloop);                     // Clear at the beginning to reach 128byte boundary.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3461
    std(tmp, 0, base_ptr);             // Clear 8byte aligned block.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3462
    addi(base_ptr, base_ptr, 8);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3463
    bdnz(startloop);
42661
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3464
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3465
  bind(fast);                                  // Clear 128byte blocks.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3466
    srdi(tmp, cnt_dwords, cl_dw_addr_bits);    // Loop count for 128byte loop (>0).
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3467
    andi(cnt_dwords, cnt_dwords, cl_dwords-1); // Rest in dwords.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3468
    mtctr(tmp);                                // Load counter.
42661
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3469
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3470
  bind(fastloop);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3471
    dcbz(base_ptr);                    // Clear 128byte aligned block.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3472
    addi(base_ptr, base_ptr, cl_size);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3473
    bdnz(fastloop);
42661
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3474
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3475
  bind(small_rest);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3476
    cmpdi(CCR0, cnt_dwords, 0);        // size 0?
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3477
    beq(CCR0, done);                   // rest == 0
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3478
    li(tmp, 0);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3479
    mtctr(cnt_dwords);                 // Load counter.
42661
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3480
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3481
  bind(restloop);                      // Clear rest.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3482
    std(tmp, 0, base_ptr);             // Clear 8byte aligned block.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3483
    addi(base_ptr, base_ptr, 8);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3484
    bdnz(restloop);
42661
2343dd675325 8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents: 42068
diff changeset
  3485
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3486
  bind(done);
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3487
}
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  3488
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3489
/////////////////////////////////////////// String intrinsics ////////////////////////////////////////////
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  3490
36303
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3491
#ifdef COMPILER2
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3492
// Intrinsics for CompactStrings
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3493
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3494
// Compress char[] to byte[] by compressing 16 bytes at once.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3495
void MacroAssembler::string_compress_16(Register src, Register dst, Register cnt,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3496
                                        Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3497
                                        Label& Lfailure) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3498
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3499
  const Register tmp0 = R0;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3500
  assert_different_registers(src, dst, cnt, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3501
  Label Lloop, Lslow;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3502
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3503
  // Check if cnt >= 8 (= 16 bytes)
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3504
  lis(tmp1, 0xFF);                // tmp1 = 0x00FF00FF00FF00FF
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3505
  srwi_(tmp2, cnt, 3);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3506
  beq(CCR0, Lslow);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3507
  ori(tmp1, tmp1, 0xFF);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3508
  rldimi(tmp1, tmp1, 32, 0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3509
  mtctr(tmp2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3510
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3511
  // 2x unrolled loop
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3512
  bind(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3513
  ld(tmp2, 0, src);               // _0_1_2_3 (Big Endian)
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3514
  ld(tmp4, 8, src);               // _4_5_6_7
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3515
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3516
  orr(tmp0, tmp2, tmp4);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3517
  rldicl(tmp3, tmp2, 6*8, 64-24); // _____1_2
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3518
  rldimi(tmp2, tmp2, 2*8, 2*8);   // _0_2_3_3
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3519
  rldicl(tmp5, tmp4, 6*8, 64-24); // _____5_6
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3520
  rldimi(tmp4, tmp4, 2*8, 2*8);   // _4_6_7_7
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3521
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3522
  andc_(tmp0, tmp0, tmp1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3523
  bne(CCR0, Lfailure);            // Not latin1.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3524
  addi(src, src, 16);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3525
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3526
  rlwimi(tmp3, tmp2, 0*8, 24, 31);// _____1_3
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3527
  srdi(tmp2, tmp2, 3*8);          // ____0_2_
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3528
  rlwimi(tmp5, tmp4, 0*8, 24, 31);// _____5_7
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3529
  srdi(tmp4, tmp4, 3*8);          // ____4_6_
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3530
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3531
  orr(tmp2, tmp2, tmp3);          // ____0123
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3532
  orr(tmp4, tmp4, tmp5);          // ____4567
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3533
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3534
  stw(tmp2, 0, dst);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3535
  stw(tmp4, 4, dst);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3536
  addi(dst, dst, 8);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3537
  bdnz(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3538
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3539
  bind(Lslow);                    // Fallback to slow version
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3540
}
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3541
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3542
// Compress char[] to byte[]. cnt must be positive int.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3543
void MacroAssembler::string_compress(Register src, Register dst, Register cnt, Register tmp, Label& Lfailure) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3544
  Label Lloop;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3545
  mtctr(cnt);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3546
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3547
  bind(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3548
  lhz(tmp, 0, src);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3549
  cmplwi(CCR0, tmp, 0xff);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3550
  bgt(CCR0, Lfailure);            // Not latin1.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3551
  addi(src, src, 2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3552
  stb(tmp, 0, dst);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3553
  addi(dst, dst, 1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3554
  bdnz(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3555
}
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3556
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3557
// Inflate byte[] to char[] by inflating 16 bytes at once.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3558
void MacroAssembler::string_inflate_16(Register src, Register dst, Register cnt,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3559
                                       Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3560
  const Register tmp0 = R0;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3561
  assert_different_registers(src, dst, cnt, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3562
  Label Lloop, Lslow;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3563
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3564
  // Check if cnt >= 8
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3565
  srwi_(tmp2, cnt, 3);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3566
  beq(CCR0, Lslow);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3567
  lis(tmp1, 0xFF);                // tmp1 = 0x00FF00FF
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3568
  ori(tmp1, tmp1, 0xFF);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3569
  mtctr(tmp2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3570
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3571
  // 2x unrolled loop
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3572
  bind(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3573
  lwz(tmp2, 0, src);              // ____0123 (Big Endian)
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3574
  lwz(tmp4, 4, src);              // ____4567
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3575
  addi(src, src, 8);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3576
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3577
  rldicl(tmp3, tmp2, 7*8, 64-8);  // _______2
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3578
  rlwimi(tmp2, tmp2, 3*8, 16, 23);// ____0113
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3579
  rldicl(tmp5, tmp4, 7*8, 64-8);  // _______6
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3580
  rlwimi(tmp4, tmp4, 3*8, 16, 23);// ____4557
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3581
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3582
  andc(tmp0, tmp2, tmp1);         // ____0_1_
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3583
  rlwimi(tmp2, tmp3, 2*8, 0, 23); // _____2_3
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3584
  andc(tmp3, tmp4, tmp1);         // ____4_5_
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3585
  rlwimi(tmp4, tmp5, 2*8, 0, 23); // _____6_7
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3586
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3587
  rldimi(tmp2, tmp0, 3*8, 0*8);   // _0_1_2_3
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3588
  rldimi(tmp4, tmp3, 3*8, 0*8);   // _4_5_6_7
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3589
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3590
  std(tmp2, 0, dst);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3591
  std(tmp4, 8, dst);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3592
  addi(dst, dst, 16);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3593
  bdnz(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3594
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3595
  bind(Lslow);                    // Fallback to slow version
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3596
}
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3597
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3598
// Inflate byte[] to char[]. cnt must be positive int.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3599
void MacroAssembler::string_inflate(Register src, Register dst, Register cnt, Register tmp) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3600
  Label Lloop;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3601
  mtctr(cnt);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3602
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3603
  bind(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3604
  lbz(tmp, 0, src);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3605
  addi(src, src, 1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3606
  sth(tmp, 0, dst);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3607
  addi(dst, dst, 2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3608
  bdnz(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3609
}
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3610
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3611
void MacroAssembler::string_compare(Register str1, Register str2,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3612
                                    Register cnt1, Register cnt2,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3613
                                    Register tmp1, Register result, int ae) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3614
  const Register tmp0 = R0,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3615
                 diff = tmp1;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3616
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3617
  assert_different_registers(str1, str2, cnt1, cnt2, tmp0, tmp1, result);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3618
  Label Ldone, Lslow, Lloop, Lreturn_diff;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3619
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3620
  // Note: Making use of the fact that compareTo(a, b) == -compareTo(b, a)
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3621
  // we interchange str1 and str2 in the UL case and negate the result.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3622
  // Like this, str1 is always latin1 encoded, except for the UU case.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3623
  // In addition, we need 0 (or sign which is 0) extend.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3624
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3625
  if (ae == StrIntrinsicNode::UU) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3626
    srwi(cnt1, cnt1, 1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3627
  } else {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3628
    clrldi(cnt1, cnt1, 32);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3629
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3630
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3631
  if (ae != StrIntrinsicNode::LL) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3632
    srwi(cnt2, cnt2, 1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3633
  } else {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3634
    clrldi(cnt2, cnt2, 32);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3635
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3636
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3637
  // See if the lengths are different, and calculate min in cnt1.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3638
  // Save diff in case we need it for a tie-breaker.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3639
  subf_(diff, cnt2, cnt1); // diff = cnt1 - cnt2
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3640
  // if (diff > 0) { cnt1 = cnt2; }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3641
  if (VM_Version::has_isel()) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3642
    isel(cnt1, CCR0, Assembler::greater, /*invert*/ false, cnt2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3643
  } else {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3644
    Label Lskip;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3645
    blt(CCR0, Lskip);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3646
    mr(cnt1, cnt2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3647
    bind(Lskip);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3648
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3649
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3650
  // Rename registers
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3651
  Register chr1 = result;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3652
  Register chr2 = tmp0;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3653
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3654
  // Compare multiple characters in fast loop (only implemented for same encoding).
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3655
  int stride1 = 8, stride2 = 8;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3656
  if (ae == StrIntrinsicNode::LL || ae == StrIntrinsicNode::UU) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3657
    int log2_chars_per_iter = (ae == StrIntrinsicNode::LL) ? 3 : 2;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3658
    Label Lfastloop, Lskipfast;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3659
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3660
    srwi_(tmp0, cnt1, log2_chars_per_iter);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3661
    beq(CCR0, Lskipfast);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3662
    rldicl(cnt2, cnt1, 0, 64 - log2_chars_per_iter); // Remaining characters.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3663
    li(cnt1, 1 << log2_chars_per_iter); // Initialize for failure case: Rescan characters from current iteration.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3664
    mtctr(tmp0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3665
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3666
    bind(Lfastloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3667
    ld(chr1, 0, str1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3668
    ld(chr2, 0, str2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3669
    cmpd(CCR0, chr1, chr2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3670
    bne(CCR0, Lslow);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3671
    addi(str1, str1, stride1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3672
    addi(str2, str2, stride2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3673
    bdnz(Lfastloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3674
    mr(cnt1, cnt2); // Remaining characters.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3675
    bind(Lskipfast);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3676
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3677
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3678
  // Loop which searches the first difference character by character.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3679
  cmpwi(CCR0, cnt1, 0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3680
  beq(CCR0, Lreturn_diff);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3681
  bind(Lslow);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3682
  mtctr(cnt1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3683
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3684
  switch (ae) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3685
    case StrIntrinsicNode::LL: stride1 = 1; stride2 = 1; break;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3686
    case StrIntrinsicNode::UL: // fallthru (see comment above)
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3687
    case StrIntrinsicNode::LU: stride1 = 1; stride2 = 2; break;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3688
    case StrIntrinsicNode::UU: stride1 = 2; stride2 = 2; break;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3689
    default: ShouldNotReachHere(); break;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3690
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3691
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3692
  bind(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3693
  if (stride1 == 1) { lbz(chr1, 0, str1); } else { lhz(chr1, 0, str1); }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3694
  if (stride2 == 1) { lbz(chr2, 0, str2); } else { lhz(chr2, 0, str2); }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3695
  subf_(result, chr2, chr1); // result = chr1 - chr2
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3696
  bne(CCR0, Ldone);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3697
  addi(str1, str1, stride1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3698
  addi(str2, str2, stride2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3699
  bdnz(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3700
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3701
  // If strings are equal up to min length, return the length difference.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3702
  bind(Lreturn_diff);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3703
  mr(result, diff);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3704
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3705
  // Otherwise, return the difference between the first mismatched chars.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3706
  bind(Ldone);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3707
  if (ae == StrIntrinsicNode::UL) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3708
    neg(result, result); // Negate result (see note above).
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3709
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3710
}
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3711
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3712
void MacroAssembler::array_equals(bool is_array_equ, Register ary1, Register ary2,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3713
                                  Register limit, Register tmp1, Register result, bool is_byte) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3714
  const Register tmp0 = R0;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3715
  assert_different_registers(ary1, ary2, limit, tmp0, tmp1, result);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3716
  Label Ldone, Lskiploop, Lloop, Lfastloop, Lskipfast;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3717
  bool limit_needs_shift = false;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3718
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3719
  if (is_array_equ) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3720
    const int length_offset = arrayOopDesc::length_offset_in_bytes();
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3721
    const int base_offset   = arrayOopDesc::base_offset_in_bytes(is_byte ? T_BYTE : T_CHAR);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3722
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3723
    // Return true if the same array.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3724
    cmpd(CCR0, ary1, ary2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3725
    beq(CCR0, Lskiploop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3726
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3727
    // Return false if one of them is NULL.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3728
    cmpdi(CCR0, ary1, 0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3729
    cmpdi(CCR1, ary2, 0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3730
    li(result, 0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3731
    cror(CCR0, Assembler::equal, CCR1, Assembler::equal);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3732
    beq(CCR0, Ldone);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3733
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3734
    // Load the lengths of arrays.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3735
    lwz(limit, length_offset, ary1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3736
    lwz(tmp0, length_offset, ary2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3737
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3738
    // Return false if the two arrays are not equal length.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3739
    cmpw(CCR0, limit, tmp0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3740
    bne(CCR0, Ldone);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3741
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3742
    // Load array addresses.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3743
    addi(ary1, ary1, base_offset);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3744
    addi(ary2, ary2, base_offset);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3745
  } else {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3746
    limit_needs_shift = !is_byte;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3747
    li(result, 0); // Assume not equal.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3748
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3749
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3750
  // Rename registers
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3751
  Register chr1 = tmp0;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3752
  Register chr2 = tmp1;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3753
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3754
  // Compare 8 bytes per iteration in fast loop.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3755
  const int log2_chars_per_iter = is_byte ? 3 : 2;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3756
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3757
  srwi_(tmp0, limit, log2_chars_per_iter + (limit_needs_shift ? 1 : 0));
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3758
  beq(CCR0, Lskipfast);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3759
  mtctr(tmp0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3760
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3761
  bind(Lfastloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3762
  ld(chr1, 0, ary1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3763
  ld(chr2, 0, ary2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3764
  addi(ary1, ary1, 8);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3765
  addi(ary2, ary2, 8);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3766
  cmpd(CCR0, chr1, chr2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3767
  bne(CCR0, Ldone);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3768
  bdnz(Lfastloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3769
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3770
  bind(Lskipfast);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3771
  rldicl_(limit, limit, limit_needs_shift ? 64 - 1 : 0, 64 - log2_chars_per_iter); // Remaining characters.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3772
  beq(CCR0, Lskiploop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3773
  mtctr(limit);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3774
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3775
  // Character by character.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3776
  bind(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3777
  if (is_byte) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3778
    lbz(chr1, 0, ary1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3779
    lbz(chr2, 0, ary2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3780
    addi(ary1, ary1, 1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3781
    addi(ary2, ary2, 1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3782
  } else {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3783
    lhz(chr1, 0, ary1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3784
    lhz(chr2, 0, ary2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3785
    addi(ary1, ary1, 2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3786
    addi(ary2, ary2, 2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3787
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3788
  cmpw(CCR0, chr1, chr2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3789
  bne(CCR0, Ldone);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3790
  bdnz(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3791
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3792
  bind(Lskiploop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3793
  li(result, 1); // All characters are equal.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3794
  bind(Ldone);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3795
}
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3796
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3797
void MacroAssembler::string_indexof(Register result, Register haystack, Register haycnt,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3798
                                    Register needle, ciTypeArray* needle_values, Register needlecnt, int needlecntval,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3799
                                    Register tmp1, Register tmp2, Register tmp3, Register tmp4, int ae) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3800
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3801
  // Ensure 0<needlecnt<=haycnt in ideal graph as prerequisite!
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3802
  Label L_TooShort, L_Found, L_NotFound, L_End;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3803
  Register last_addr = haycnt, // Kill haycnt at the beginning.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3804
  addr      = tmp1,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3805
  n_start   = tmp2,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3806
  ch1       = tmp3,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3807
  ch2       = R0;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3808
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3809
  assert(ae != StrIntrinsicNode::LU, "Invalid encoding");
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3810
  const int h_csize = (ae == StrIntrinsicNode::LL) ? 1 : 2;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3811
  const int n_csize = (ae == StrIntrinsicNode::UU) ? 2 : 1;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3812
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3813
  // **************************************************************************************************
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3814
  // Prepare for main loop: optimized for needle count >=2, bail out otherwise.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3815
  // **************************************************************************************************
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3816
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3817
  // Compute last haystack addr to use if no match gets found.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3818
  clrldi(haycnt, haycnt, 32);         // Ensure positive int is valid as 64 bit value.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3819
  addi(addr, haystack, -h_csize);     // Accesses use pre-increment.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3820
  if (needlecntval == 0) { // variable needlecnt
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3821
   cmpwi(CCR6, needlecnt, 2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3822
   clrldi(needlecnt, needlecnt, 32);  // Ensure positive int is valid as 64 bit value.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3823
   blt(CCR6, L_TooShort);             // Variable needlecnt: handle short needle separately.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3824
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3825
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3826
  if (n_csize == 2) { lwz(n_start, 0, needle); } else { lhz(n_start, 0, needle); } // Load first 2 characters of needle.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3827
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3828
  if (needlecntval == 0) { // variable needlecnt
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3829
   subf(ch1, needlecnt, haycnt);      // Last character index to compare is haycnt-needlecnt.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3830
   addi(needlecnt, needlecnt, -2);    // Rest of needle.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3831
  } else { // constant needlecnt
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3832
  guarantee(needlecntval != 1, "IndexOf with single-character needle must be handled separately");
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3833
  assert((needlecntval & 0x7fff) == needlecntval, "wrong immediate");
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3834
   addi(ch1, haycnt, -needlecntval);  // Last character index to compare is haycnt-needlecnt.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3835
   if (needlecntval > 3) { li(needlecnt, needlecntval - 2); } // Rest of needle.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3836
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3837
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3838
  if (h_csize == 2) { slwi(ch1, ch1, 1); } // Scale to number of bytes.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3839
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3840
  if (ae ==StrIntrinsicNode::UL) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3841
   srwi(tmp4, n_start, 1*8);          // ___0
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3842
   rlwimi(n_start, tmp4, 2*8, 0, 23); // _0_1
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3843
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3844
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3845
  add(last_addr, haystack, ch1);      // Point to last address to compare (haystack+2*(haycnt-needlecnt)).
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3846
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3847
  // Main Loop (now we have at least 2 characters).
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3848
  Label L_OuterLoop, L_InnerLoop, L_FinalCheck, L_Comp1, L_Comp2;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3849
  bind(L_OuterLoop); // Search for 1st 2 characters.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3850
  Register addr_diff = tmp4;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3851
   subf(addr_diff, addr, last_addr);  // Difference between already checked address and last address to check.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3852
   addi(addr, addr, h_csize);         // This is the new address we want to use for comparing.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3853
   srdi_(ch2, addr_diff, h_csize);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3854
   beq(CCR0, L_FinalCheck);           // 2 characters left?
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3855
   mtctr(ch2);                        // num of characters / 2
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3856
  bind(L_InnerLoop);                  // Main work horse (2x unrolled search loop)
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3857
   if (h_csize == 2) {                // Load 2 characters of haystack (ignore alignment).
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3858
    lwz(ch1, 0, addr);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3859
    lwz(ch2, 2, addr);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3860
   } else {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3861
    lhz(ch1, 0, addr);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3862
    lhz(ch2, 1, addr);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3863
   }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3864
   cmpw(CCR0, ch1, n_start);          // Compare 2 characters (1 would be sufficient but try to reduce branches to CompLoop).
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3865
   cmpw(CCR1, ch2, n_start);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3866
   beq(CCR0, L_Comp1);                // Did we find the needle start?
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3867
   beq(CCR1, L_Comp2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3868
   addi(addr, addr, 2 * h_csize);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3869
   bdnz(L_InnerLoop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3870
  bind(L_FinalCheck);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3871
   andi_(addr_diff, addr_diff, h_csize); // Remaining characters not covered by InnerLoop: (num of characters) & 1.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3872
   beq(CCR0, L_NotFound);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3873
   if (h_csize == 2) { lwz(ch1, 0, addr); } else { lhz(ch1, 0, addr); } // One position left at which we have to compare.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3874
   cmpw(CCR1, ch1, n_start);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3875
   beq(CCR1, L_Comp1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3876
  bind(L_NotFound);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3877
   li(result, -1);                    // not found
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3878
   b(L_End);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3879
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3880
   // **************************************************************************************************
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3881
   // Special Case: unfortunately, the variable needle case can be called with needlecnt<2
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3882
   // **************************************************************************************************
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3883
  if (needlecntval == 0) {           // We have to handle these cases separately.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3884
  Label L_OneCharLoop;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3885
  bind(L_TooShort);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3886
   mtctr(haycnt);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3887
   if (n_csize == 2) { lhz(n_start, 0, needle); } else { lbz(n_start, 0, needle); } // First character of needle
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3888
  bind(L_OneCharLoop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3889
   if (h_csize == 2) { lhzu(ch1, 2, addr); } else { lbzu(ch1, 1, addr); }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3890
   cmpw(CCR1, ch1, n_start);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3891
   beq(CCR1, L_Found);               // Did we find the one character needle?
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3892
   bdnz(L_OneCharLoop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3893
   li(result, -1);                   // Not found.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3894
   b(L_End);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3895
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3896
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3897
  // **************************************************************************************************
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3898
  // Regular Case Part II: compare rest of needle (first 2 characters have been compared already)
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3899
  // **************************************************************************************************
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3900
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3901
  // Compare the rest
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3902
  bind(L_Comp2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3903
   addi(addr, addr, h_csize);        // First comparison has failed, 2nd one hit.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3904
  bind(L_Comp1);                     // Addr points to possible needle start.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3905
  if (needlecntval != 2) {           // Const needlecnt==2?
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3906
   if (needlecntval != 3) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3907
    if (needlecntval == 0) { beq(CCR6, L_Found); } // Variable needlecnt==2?
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3908
    Register n_ind = tmp4,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3909
             h_ind = n_ind;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3910
    li(n_ind, 2 * n_csize);          // First 2 characters are already compared, use index 2.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3911
    mtctr(needlecnt);                // Decremented by 2, still > 0.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3912
   Label L_CompLoop;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3913
   bind(L_CompLoop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3914
    if (ae ==StrIntrinsicNode::UL) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3915
      h_ind = ch1;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3916
      sldi(h_ind, n_ind, 1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3917
    }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3918
    if (n_csize == 2) { lhzx(ch2, needle, n_ind); } else { lbzx(ch2, needle, n_ind); }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3919
    if (h_csize == 2) { lhzx(ch1, addr, h_ind); } else { lbzx(ch1, addr, h_ind); }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3920
    cmpw(CCR1, ch1, ch2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3921
    bne(CCR1, L_OuterLoop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3922
    addi(n_ind, n_ind, n_csize);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3923
    bdnz(L_CompLoop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3924
   } else { // No loop required if there's only one needle character left.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3925
    if (n_csize == 2) { lhz(ch2, 2 * 2, needle); } else { lbz(ch2, 2 * 1, needle); }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3926
    if (h_csize == 2) { lhz(ch1, 2 * 2, addr); } else { lbz(ch1, 2 * 1, addr); }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3927
    cmpw(CCR1, ch1, ch2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3928
    bne(CCR1, L_OuterLoop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3929
   }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3930
  }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3931
  // Return index ...
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3932
  bind(L_Found);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3933
   subf(result, haystack, addr);     // relative to haystack, ...
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3934
   if (h_csize == 2) { srdi(result, result, 1); } // in characters.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3935
  bind(L_End);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3936
} // string_indexof
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3937
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3938
void MacroAssembler::string_indexof_char(Register result, Register haystack, Register haycnt,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3939
                                         Register needle, jchar needleChar, Register tmp1, Register tmp2, bool is_byte) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3940
  assert_different_registers(haystack, haycnt, needle, tmp1, tmp2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3941
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3942
  Label L_InnerLoop, L_FinalCheck, L_Found1, L_Found2, L_NotFound, L_End;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3943
  Register addr = tmp1,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3944
           ch1 = tmp2,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3945
           ch2 = R0;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3946
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3947
  const int h_csize = is_byte ? 1 : 2;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3948
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3949
//4:
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3950
   srwi_(tmp2, haycnt, 1);   // Shift right by exact_log2(UNROLL_FACTOR).
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3951
   mr(addr, haystack);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3952
   beq(CCR0, L_FinalCheck);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3953
   mtctr(tmp2);              // Move to count register.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3954
//8:
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3955
  bind(L_InnerLoop);         // Main work horse (2x unrolled search loop).
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3956
   if (!is_byte) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3957
    lhz(ch1, 0, addr);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3958
    lhz(ch2, 2, addr);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3959
   } else {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3960
    lbz(ch1, 0, addr);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3961
    lbz(ch2, 1, addr);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3962
   }
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3963
   (needle != R0) ? cmpw(CCR0, ch1, needle) : cmplwi(CCR0, ch1, (unsigned int)needleChar);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3964
   (needle != R0) ? cmpw(CCR1, ch2, needle) : cmplwi(CCR1, ch2, (unsigned int)needleChar);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3965
   beq(CCR0, L_Found1);      // Did we find the needle?
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3966
   beq(CCR1, L_Found2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3967
   addi(addr, addr, 2 * h_csize);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3968
   bdnz(L_InnerLoop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3969
//16:
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3970
  bind(L_FinalCheck);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3971
   andi_(R0, haycnt, 1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3972
   beq(CCR0, L_NotFound);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3973
   if (!is_byte) { lhz(ch1, 0, addr); } else { lbz(ch1, 0, addr); } // One position left at which we have to compare.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3974
   (needle != R0) ? cmpw(CCR1, ch1, needle) : cmplwi(CCR1, ch1, (unsigned int)needleChar);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3975
   beq(CCR1, L_Found1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3976
//21:
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3977
  bind(L_NotFound);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3978
   li(result, -1);           // Not found.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3979
   b(L_End);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3980
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3981
  bind(L_Found2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3982
   addi(addr, addr, h_csize);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3983
//24:
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3984
  bind(L_Found1);            // Return index ...
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3985
   subf(result, haystack, addr); // relative to haystack, ...
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3986
   if (!is_byte) { srdi(result, result, 1); } // in characters.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3987
  bind(L_End);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3988
} // string_indexof_char
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3989
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3990
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3991
void MacroAssembler::has_negatives(Register src, Register cnt, Register result,
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3992
                                   Register tmp1, Register tmp2) {
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3993
  const Register tmp0 = R0;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3994
  assert_different_registers(src, result, cnt, tmp0, tmp1, tmp2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3995
  Label Lfastloop, Lslow, Lloop, Lnoneg, Ldone;
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3996
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3997
  // Check if cnt >= 8 (= 16 bytes)
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3998
  lis(tmp1, (int)(short)0x8080);  // tmp1 = 0x8080808080808080
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  3999
  srwi_(tmp2, cnt, 4);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4000
  li(result, 1);                  // Assume there's a negative byte.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4001
  beq(CCR0, Lslow);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4002
  ori(tmp1, tmp1, 0x8080);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4003
  rldimi(tmp1, tmp1, 32, 0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4004
  mtctr(tmp2);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4005
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4006
  // 2x unrolled loop
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4007
  bind(Lfastloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4008
  ld(tmp2, 0, src);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4009
  ld(tmp0, 8, src);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4010
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4011
  orr(tmp0, tmp2, tmp0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4012
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4013
  and_(tmp0, tmp0, tmp1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4014
  bne(CCR0, Ldone);               // Found negative byte.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4015
  addi(src, src, 16);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4016
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4017
  bdnz(Lfastloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4018
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4019
  bind(Lslow);                    // Fallback to slow version
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4020
  rldicl_(tmp0, cnt, 0, 64-4);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4021
  beq(CCR0, Lnoneg);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4022
  mtctr(tmp0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4023
  bind(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4024
  lbz(tmp0, 0, src);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4025
  addi(src, src, 1);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4026
  andi_(tmp0, tmp0, 0x80);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4027
  bne(CCR0, Ldone);               // Found negative byte.
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4028
  bdnz(Lloop);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4029
  bind(Lnoneg);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4030
  li(result, 0);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4031
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4032
  bind(Ldone);
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4033
}
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4034
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4035
#endif // Compiler2
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35913
diff changeset
  4036
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4037
// Helpers for Intrinsic Emitters
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4038
//
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4039
// Revert the byte order of a 32bit value in a register
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4040
//   src: 0x44556677
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4041
//   dst: 0x77665544
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4042
// Three steps to obtain the result:
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4043
//  1) Rotate src (as doubleword) left 5 bytes. That puts the leftmost byte of the src word
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4044
//     into the rightmost byte position. Afterwards, everything left of the rightmost byte is cleared.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4045
//     This value initializes dst.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4046
//  2) Rotate src (as word) left 3 bytes. That puts the rightmost byte of the src word into the leftmost
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4047
//     byte position. Furthermore, byte 5 is rotated into byte 6 position where it is supposed to go.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4048
//     This value is mask inserted into dst with a [0..23] mask of 1s.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4049
//  3) Rotate src (as word) left 1 byte. That puts byte 6 into byte 5 position.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4050
//     This value is mask inserted into dst with a [8..15] mask of 1s.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4051
void MacroAssembler::load_reverse_32(Register dst, Register src) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4052
  assert_different_registers(dst, src);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4053
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4054
  rldicl(dst, src, (4+1)*8, 56);       // Rotate byte 4 into position 7 (rightmost), clear all to the left.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4055
  rlwimi(dst, src,     3*8,  0, 23);   // Insert byte 5 into position 6, 7 into 4, leave pos 7 alone.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4056
  rlwimi(dst, src,     1*8,  8, 15);   // Insert byte 6 into position 5, leave the rest alone.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4057
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4058
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4059
// Calculate the column addresses of the crc32 lookup table into distinct registers.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4060
// This loop-invariant calculation is moved out of the loop body, reducing the loop
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4061
// body size from 20 to 16 instructions.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4062
// Returns the offset that was used to calculate the address of column tc3.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4063
// Due to register shortage, setting tc3 may overwrite table. With the return offset
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4064
// at hand, the original table address can be easily reconstructed.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4065
int MacroAssembler::crc32_table_columns(Register table, Register tc0, Register tc1, Register tc2, Register tc3) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4066
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4067
#ifdef VM_LITTLE_ENDIAN
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4068
  // This is what we implement (the DOLIT4 part):
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4069
  // ========================================================================= */
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4070
  // #define DOLIT4 c ^= *buf4++; \
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4071
  //         c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4072
  //             crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4073
  // #define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4074
  // ========================================================================= */
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4075
  const int ix0 = 3*(4*CRC32_COLUMN_SIZE);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4076
  const int ix1 = 2*(4*CRC32_COLUMN_SIZE);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4077
  const int ix2 = 1*(4*CRC32_COLUMN_SIZE);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4078
  const int ix3 = 0*(4*CRC32_COLUMN_SIZE);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4079
#else
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4080
  // This is what we implement (the DOBIG4 part):
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4081
  // =========================================================================
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4082
  // #define DOBIG4 c ^= *++buf4; \
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4083
  //         c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4084
  //             crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4085
  // #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4086
  // =========================================================================
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4087
  const int ix0 = 4*(4*CRC32_COLUMN_SIZE);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4088
  const int ix1 = 5*(4*CRC32_COLUMN_SIZE);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4089
  const int ix2 = 6*(4*CRC32_COLUMN_SIZE);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4090
  const int ix3 = 7*(4*CRC32_COLUMN_SIZE);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4091
#endif
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4092
  assert_different_registers(table, tc0, tc1, tc2);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4093
  assert(table == tc3, "must be!");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4094
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35085
diff changeset
  4095
  addi(tc0, table, ix0);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35085
diff changeset
  4096
  addi(tc1, table, ix1);
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35085
diff changeset
  4097
  addi(tc2, table, ix2);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4098
  if (ix3 != 0) addi(tc3, table, ix3);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4099
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4100
  return ix3;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4101
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4102
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4103
/**
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4104
 * uint32_t crc;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4105
 * timesXtoThe32[crc & 0xFF] ^ (crc >> 8);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4106
 */
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4107
void MacroAssembler::fold_byte_crc32(Register crc, Register val, Register table, Register tmp) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4108
  assert_different_registers(crc, table, tmp);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4109
  assert_different_registers(val, table);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4110
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4111
  if (crc == val) {                   // Must rotate first to use the unmodified value.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4112
    rlwinm(tmp, val, 2, 24-2, 31-2);  // Insert (rightmost) byte 7 of val, shifted left by 2, into byte 6..7 of tmp, clear the rest.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4113
                                      // As we use a word (4-byte) instruction, we have to adapt the mask bit positions.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4114
    srwi(crc, crc, 8);                // Unsigned shift, clear leftmost 8 bits.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4115
  } else {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4116
    srwi(crc, crc, 8);                // Unsigned shift, clear leftmost 8 bits.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4117
    rlwinm(tmp, val, 2, 24-2, 31-2);  // Insert (rightmost) byte 7 of val, shifted left by 2, into byte 6..7 of tmp, clear the rest.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4118
  }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4119
  lwzx(tmp, table, tmp);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4120
  xorr(crc, crc, tmp);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4121
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4122
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4123
/**
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4124
 * uint32_t crc;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4125
 * timesXtoThe32[crc & 0xFF] ^ (crc >> 8);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4126
 */
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4127
void MacroAssembler::fold_8bit_crc32(Register crc, Register table, Register tmp) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4128
  fold_byte_crc32(crc, crc, table, tmp);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4129
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4130
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4131
/**
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4132
 * Emits code to update CRC-32 with a byte value according to constants in table.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4133
 *
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4134
 * @param [in,out]crc   Register containing the crc.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4135
 * @param [in]val       Register containing the byte to fold into the CRC.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4136
 * @param [in]table     Register containing the table of crc constants.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4137
 *
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4138
 * uint32_t crc;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4139
 * val = crc_table[(val ^ crc) & 0xFF];
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4140
 * crc = val ^ (crc >> 8);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4141
 */
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4142
void MacroAssembler::update_byte_crc32(Register crc, Register val, Register table) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4143
  BLOCK_COMMENT("update_byte_crc32:");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4144
  xorr(val, val, crc);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4145
  fold_byte_crc32(crc, val, table, val);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4146
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4147
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4148
/**
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4149
 * @param crc   register containing existing CRC (32-bit)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4150
 * @param buf   register pointing to input byte buffer (byte*)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4151
 * @param len   register containing number of bytes
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4152
 * @param table register pointing to CRC table
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4153
 */
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4154
void MacroAssembler::update_byteLoop_crc32(Register crc, Register buf, Register len, Register table,
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4155
                                           Register data, bool loopAlignment) {
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4156
  assert_different_registers(crc, buf, len, table, data);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4157
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4158
  Label L_mainLoop, L_done;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4159
  const int mainLoop_stepping  = 1;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4160
  const int mainLoop_alignment = loopAlignment ? 32 : 4; // (InputForNewCode > 4 ? InputForNewCode : 32) : 4;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4161
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4162
  // Process all bytes in a single-byte loop.
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35085
diff changeset
  4163
  clrldi_(len, len, 32);                         // Enforce 32 bit. Anything to do?
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4164
  beq(CCR0, L_done);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4165
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35085
diff changeset
  4166
  mtctr(len);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4167
  align(mainLoop_alignment);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4168
  BIND(L_mainLoop);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4169
    lbz(data, 0, buf);                           // Byte from buffer, zero-extended.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4170
    addi(buf, buf, mainLoop_stepping);           // Advance buffer position.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4171
    update_byte_crc32(crc, data, table);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4172
    bdnz(L_mainLoop);                            // Iterate.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4173
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4174
  bind(L_done);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4175
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4176
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4177
/**
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4178
 * Emits code to update CRC-32 with a 4-byte value according to constants in table
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4179
 * Implementation according to jdk/src/share/native/java/util/zip/zlib-1.2.8/crc32.c
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4180
 */
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4181
// A not on the lookup table address(es):
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4182
// The lookup table consists of two sets of four columns each.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4183
// The columns {0..3} are used for little-endian machines.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4184
// The columns {4..7} are used for big-endian machines.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4185
// To save the effort of adding the column offset to the table address each time
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4186
// a table element is looked up, it is possible to pass the pre-calculated
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4187
// column addresses.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4188
// Uses R9..R12 as work register. Must be saved/restored by caller, if necessary.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4189
void MacroAssembler::update_1word_crc32(Register crc, Register buf, Register table, int bufDisp, int bufInc,
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4190
                                        Register t0,  Register t1,  Register t2,  Register t3,
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4191
                                        Register tc0, Register tc1, Register tc2, Register tc3) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4192
  assert_different_registers(crc, t3);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4193
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4194
  // XOR crc with next four bytes of buffer.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4195
  lwz(t3, bufDisp, buf);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4196
  if (bufInc != 0) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4197
    addi(buf, buf, bufInc);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4198
  }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4199
  xorr(t3, t3, crc);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4200
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4201
  // Chop crc into 4 single-byte pieces, shifted left 2 bits, to form the table indices.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4202
  rlwinm(t0, t3,  2,         24-2, 31-2);  // ((t1 >>  0) & 0xff) << 2
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4203
  rlwinm(t1, t3,  32+(2- 8), 24-2, 31-2);  // ((t1 >>  8) & 0xff) << 2
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4204
  rlwinm(t2, t3,  32+(2-16), 24-2, 31-2);  // ((t1 >> 16) & 0xff) << 2
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4205
  rlwinm(t3, t3,  32+(2-24), 24-2, 31-2);  // ((t1 >> 24) & 0xff) << 2
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4206
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4207
  // Use the pre-calculated column addresses.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4208
  // Load pre-calculated table values.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4209
  lwzx(t0, tc0, t0);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4210
  lwzx(t1, tc1, t1);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4211
  lwzx(t2, tc2, t2);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4212
  lwzx(t3, tc3, t3);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4213
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4214
  // Calculate new crc from table values.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4215
  xorr(t0,  t0, t1);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4216
  xorr(t2,  t2, t3);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4217
  xorr(crc, t0, t2);  // Now crc contains the final checksum value.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4218
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4219
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4220
/**
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4221
 * @param crc   register containing existing CRC (32-bit)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4222
 * @param buf   register pointing to input byte buffer (byte*)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4223
 * @param len   register containing number of bytes
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4224
 * @param table register pointing to CRC table
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4225
 *
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4226
 * Uses R9..R12 as work register. Must be saved/restored by caller!
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4227
 */
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4228
void MacroAssembler::kernel_crc32_2word(Register crc, Register buf, Register len, Register table,
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4229
                                        Register t0,  Register t1,  Register t2,  Register t3,
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4230
                                        Register tc0, Register tc1, Register tc2, Register tc3,
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4231
                                        bool invertCRC) {
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4232
  assert_different_registers(crc, buf, len, table);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4233
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4234
  Label L_mainLoop, L_tail;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4235
  Register  tmp  = t0;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4236
  Register  data = t0;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4237
  Register  tmp2 = t1;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4238
  const int mainLoop_stepping  = 8;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4239
  const int tailLoop_stepping  = 1;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4240
  const int log_stepping       = exact_log2(mainLoop_stepping);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4241
  const int mainLoop_alignment = 32; // InputForNewCode > 4 ? InputForNewCode : 32;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4242
  const int complexThreshold   = 2*mainLoop_stepping;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4243
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4244
  // Don't test for len <= 0 here. This pathological case should not occur anyway.
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4245
  // Optimizing for it by adding a test and a branch seems to be a waste of CPU cycles
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4246
  // for all well-behaved cases. The situation itself is detected and handled correctly
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4247
  // within update_byteLoop_crc32.
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4248
  assert(tailLoop_stepping == 1, "check tailLoop_stepping!");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4249
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4250
  BLOCK_COMMENT("kernel_crc32_2word {");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4251
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4252
  if (invertCRC) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4253
    nand(crc, crc, crc);                      // 1s complement of crc
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4254
  }
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4255
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4256
  // Check for short (<mainLoop_stepping) buffer.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4257
  cmpdi(CCR0, len, complexThreshold);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4258
  blt(CCR0, L_tail);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4259
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4260
  // Pre-mainLoop alignment did show a slight (1%) positive effect on performance.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4261
  // We leave the code in for reference. Maybe we need alignment when we exploit vector instructions.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4262
  {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4263
    // Align buf addr to mainLoop_stepping boundary.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4264
    neg(tmp2, buf);                           // Calculate # preLoop iterations for alignment.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4265
    rldicl(tmp2, tmp2, 0, 64-log_stepping);   // Rotate tmp2 0 bits, insert into tmp2, anding with mask with 1s from 62..63.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4266
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4267
    if (complexThreshold > mainLoop_stepping) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4268
      sub(len, len, tmp2);                       // Remaining bytes for main loop (>=mainLoop_stepping is guaranteed).
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4269
    } else {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4270
      sub(tmp, len, tmp2);                       // Remaining bytes for main loop.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4271
      cmpdi(CCR0, tmp, mainLoop_stepping);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4272
      blt(CCR0, L_tail);                         // For less than one mainloop_stepping left, do only tail processing
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4273
      mr(len, tmp);                              // remaining bytes for main loop (>=mainLoop_stepping is guaranteed).
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4274
    }
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4275
    update_byteLoop_crc32(crc, buf, tmp2, table, data, false);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4276
  }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4277
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4278
  srdi(tmp2, len, log_stepping);                 // #iterations for mainLoop
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4279
  andi(len, len, mainLoop_stepping-1);           // remaining bytes for tailLoop
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4280
  mtctr(tmp2);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4281
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4282
#ifdef VM_LITTLE_ENDIAN
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4283
  Register crc_rv = crc;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4284
#else
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4285
  Register crc_rv = tmp;                         // Load_reverse needs separate registers to work on.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4286
                                                 // Occupies tmp, but frees up crc.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4287
  load_reverse_32(crc_rv, crc);                  // Revert byte order because we are dealing with big-endian data.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4288
  tmp = crc;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4289
#endif
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4290
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4291
  int reconstructTableOffset = crc32_table_columns(table, tc0, tc1, tc2, tc3);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4292
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4293
  align(mainLoop_alignment);                     // Octoword-aligned loop address. Shows 2% improvement.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4294
  BIND(L_mainLoop);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4295
    update_1word_crc32(crc_rv, buf, table, 0, 0, crc_rv, t1, t2, t3, tc0, tc1, tc2, tc3);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4296
    update_1word_crc32(crc_rv, buf, table, 4, mainLoop_stepping, crc_rv, t1, t2, t3, tc0, tc1, tc2, tc3);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4297
    bdnz(L_mainLoop);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4298
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4299
#ifndef VM_LITTLE_ENDIAN
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4300
  load_reverse_32(crc, crc_rv);                  // Revert byte order because we are dealing with big-endian data.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4301
  tmp = crc_rv;                                  // Tmp uses it's original register again.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4302
#endif
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4303
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4304
  // Restore original table address for tailLoop.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4305
  if (reconstructTableOffset != 0) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4306
    addi(table, table, -reconstructTableOffset);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4307
  }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4308
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4309
  // Process last few (<complexThreshold) bytes of buffer.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4310
  BIND(L_tail);
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4311
  update_byteLoop_crc32(crc, buf, len, table, data, false);
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4312
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4313
  if (invertCRC) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4314
    nand(crc, crc, crc);                      // 1s complement of crc
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4315
  }
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4316
  BLOCK_COMMENT("} kernel_crc32_2word");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4317
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4318
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4319
/**
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4320
 * @param crc   register containing existing CRC (32-bit)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4321
 * @param buf   register pointing to input byte buffer (byte*)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4322
 * @param len   register containing number of bytes
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4323
 * @param table register pointing to CRC table
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4324
 *
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4325
 * uses R9..R12 as work register. Must be saved/restored by caller!
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4326
 */
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4327
void MacroAssembler::kernel_crc32_1word(Register crc, Register buf, Register len, Register table,
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4328
                                        Register t0,  Register t1,  Register t2,  Register t3,
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4329
                                        Register tc0, Register tc1, Register tc2, Register tc3,
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4330
                                        bool invertCRC) {
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4331
  assert_different_registers(crc, buf, len, table);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4332
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4333
  Label L_mainLoop, L_tail;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4334
  Register  tmp          = t0;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4335
  Register  data         = t0;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4336
  Register  tmp2         = t1;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4337
  const int mainLoop_stepping  = 4;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4338
  const int tailLoop_stepping  = 1;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4339
  const int log_stepping       = exact_log2(mainLoop_stepping);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4340
  const int mainLoop_alignment = 32; // InputForNewCode > 4 ? InputForNewCode : 32;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4341
  const int complexThreshold   = 2*mainLoop_stepping;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4342
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4343
  // Don't test for len <= 0 here. This pathological case should not occur anyway.
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4344
  // Optimizing for it by adding a test and a branch seems to be a waste of CPU cycles
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4345
  // for all well-behaved cases. The situation itself is detected and handled correctly
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4346
  // within update_byteLoop_crc32.
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4347
  assert(tailLoop_stepping == 1, "check tailLoop_stepping!");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4348
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4349
  BLOCK_COMMENT("kernel_crc32_1word {");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4350
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4351
  if (invertCRC) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4352
    nand(crc, crc, crc);                      // 1s complement of crc
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4353
  }
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4354
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4355
  // Check for short (<mainLoop_stepping) buffer.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4356
  cmpdi(CCR0, len, complexThreshold);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4357
  blt(CCR0, L_tail);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4358
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4359
  // Pre-mainLoop alignment did show a slight (1%) positive effect on performance.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4360
  // We leave the code in for reference. Maybe we need alignment when we exploit vector instructions.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4361
  {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4362
    // Align buf addr to mainLoop_stepping boundary.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4363
    neg(tmp2, buf);                              // Calculate # preLoop iterations for alignment.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4364
    rldicl(tmp2, tmp2, 0, 64-log_stepping);      // Rotate tmp2 0 bits, insert into tmp2, anding with mask with 1s from 62..63.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4365
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4366
    if (complexThreshold > mainLoop_stepping) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4367
      sub(len, len, tmp2);                       // Remaining bytes for main loop (>=mainLoop_stepping is guaranteed).
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4368
    } else {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4369
      sub(tmp, len, tmp2);                       // Remaining bytes for main loop.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4370
      cmpdi(CCR0, tmp, mainLoop_stepping);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4371
      blt(CCR0, L_tail);                         // For less than one mainloop_stepping left, do only tail processing
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4372
      mr(len, tmp);                              // remaining bytes for main loop (>=mainLoop_stepping is guaranteed).
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4373
    }
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4374
    update_byteLoop_crc32(crc, buf, tmp2, table, data, false);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4375
  }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4376
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4377
  srdi(tmp2, len, log_stepping);                 // #iterations for mainLoop
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4378
  andi(len, len, mainLoop_stepping-1);           // remaining bytes for tailLoop
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4379
  mtctr(tmp2);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4380
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4381
#ifdef VM_LITTLE_ENDIAN
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4382
  Register crc_rv = crc;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4383
#else
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4384
  Register crc_rv = tmp;                         // Load_reverse needs separate registers to work on.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4385
                                                 // Occupies tmp, but frees up crc.
35541
cba047a086d5 8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents: 35085
diff changeset
  4386
  load_reverse_32(crc_rv, crc);                  // Revert byte order because we are dealing with big-endian data.
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4387
  tmp = crc;
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4388
#endif
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4389
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4390
  int reconstructTableOffset = crc32_table_columns(table, tc0, tc1, tc2, tc3);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4391
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4392
  align(mainLoop_alignment);                     // Octoword-aligned loop address. Shows 2% improvement.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4393
  BIND(L_mainLoop);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4394
    update_1word_crc32(crc_rv, buf, table, 0, mainLoop_stepping, crc_rv, t1, t2, t3, tc0, tc1, tc2, tc3);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4395
    bdnz(L_mainLoop);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4396
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4397
#ifndef VM_LITTLE_ENDIAN
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4398
  load_reverse_32(crc, crc_rv);                  // Revert byte order because we are dealing with big-endian data.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4399
  tmp = crc_rv;                                  // Tmp uses it's original register again.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4400
#endif
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4401
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4402
  // Restore original table address for tailLoop.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4403
  if (reconstructTableOffset != 0) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4404
    addi(table, table, -reconstructTableOffset);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4405
  }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4406
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4407
  // Process last few (<complexThreshold) bytes of buffer.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4408
  BIND(L_tail);
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4409
  update_byteLoop_crc32(crc, buf, len, table, data, false);
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4410
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4411
  if (invertCRC) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4412
    nand(crc, crc, crc);                      // 1s complement of crc
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4413
  }
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4414
  BLOCK_COMMENT("} kernel_crc32_1word");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4415
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4416
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4417
/**
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4418
 * @param crc   register containing existing CRC (32-bit)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4419
 * @param buf   register pointing to input byte buffer (byte*)
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4420
 * @param len   register containing number of bytes
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4421
 * @param table register pointing to CRC table
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4422
 *
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4423
 * Uses R7_ARG5, R8_ARG6 as work registers.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4424
 */
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4425
void MacroAssembler::kernel_crc32_1byte(Register crc, Register buf, Register len, Register table,
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4426
                                        Register t0,  Register t1,  Register t2,  Register t3,
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4427
                                        bool invertCRC) {
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4428
  assert_different_registers(crc, buf, len, table);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4429
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4430
  Register  data = t0;                   // Holds the current byte to be folded into crc.
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4431
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4432
  BLOCK_COMMENT("kernel_crc32_1byte {");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4433
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4434
  if (invertCRC) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4435
    nand(crc, crc, crc);                      // 1s complement of crc
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4436
  }
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4437
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4438
  // Process all bytes in a single-byte loop.
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4439
  update_byteLoop_crc32(crc, buf, len, table, data, true);
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4440
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4441
  if (invertCRC) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4442
    nand(crc, crc, crc);                      // 1s complement of crc
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4443
  }
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4444
  BLOCK_COMMENT("} kernel_crc32_1byte");
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4445
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4446
41334
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4447
/**
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4448
 * @param crc             register containing existing CRC (32-bit)
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4449
 * @param buf             register pointing to input byte buffer (byte*)
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4450
 * @param len             register containing number of bytes
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4451
 * @param table           register pointing to CRC table
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4452
 * @param constants       register pointing to CRC table for 128-bit aligned memory
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4453
 * @param barretConstants register pointing to table for barrett reduction
49376
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4454
 * @param t0-t4           temp registers
41334
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4455
 */
49376
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4456
void MacroAssembler::kernel_crc32_1word_vpmsum(Register crc, Register buf, Register len, Register table,
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4457
                                               Register constants, Register barretConstants,
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4458
                                               Register t0, Register t1, Register t2, Register t3, Register t4,
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4459
                                               bool invertCRC) {
41334
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4460
  assert_different_registers(crc, buf, len, table);
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4461
49376
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4462
  Label L_alignedHead, L_tail;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4463
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4464
  BLOCK_COMMENT("kernel_crc32_1word_vpmsum {");
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4465
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4466
  // 1. ~c
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4467
  if (invertCRC) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4468
    nand(crc, crc, crc);                      // 1s complement of crc
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4469
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4470
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4471
  // 2. use kernel_crc32_1word for short len
41334
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4472
  clrldi(len, len, 32);
49376
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4473
  cmpdi(CCR0, len, 512);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4474
  blt(CCR0, L_tail);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4475
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4476
  // 3. calculate from 0 to first aligned address
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4477
  const int alignment = 16;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4478
  Register prealign = t0;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4479
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4480
  andi_(prealign, buf, alignment - 1);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4481
  beq(CCR0, L_alignedHead);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4482
  subfic(prealign, prealign, alignment);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4483
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4484
  subf(len, prealign, len);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4485
  update_byteLoop_crc32(crc, buf, prealign, table, t2, false);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4486
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4487
  // 4. calculate from first aligned address as far as possible
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4488
  BIND(L_alignedHead);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4489
  kernel_crc32_1word_aligned(crc, buf, len, constants, barretConstants, t0, t1, t2, t3, t4);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4490
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4491
  // 5. remaining bytes
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4492
  BIND(L_tail);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4493
  Register tc0 = t4;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4494
  Register tc1 = constants;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4495
  Register tc2 = barretConstants;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4496
  kernel_crc32_1word(crc, buf, len, table, t0, t1, t2, t3, tc0, tc1, tc2, table, false);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4497
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4498
  // 6. ~c
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4499
  if (invertCRC) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4500
    nand(crc, crc, crc);                      // 1s complement of crc
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4501
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4502
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4503
  BLOCK_COMMENT("} kernel_crc32_1word_vpmsum");
41334
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4504
}
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4505
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4506
/**
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4507
 * @param crc             register containing existing CRC (32-bit)
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4508
 * @param buf             register pointing to input byte buffer (byte*)
49376
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4509
 * @param len             register containing number of bytes (will get updated to remaining bytes)
41334
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4510
 * @param constants       register pointing to CRC table for 128-bit aligned memory
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4511
 * @param barretConstants register pointing to table for barrett reduction
49376
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4512
 * @param t0-t4           temp registers
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4513
 * Precondition: len should be >= 512. Otherwise, nothing will be done.
41334
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4514
 */
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4515
void MacroAssembler::kernel_crc32_1word_aligned(Register crc, Register buf, Register len,
49376
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4516
    Register constants, Register barretConstants,
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4517
    Register t0, Register t1, Register t2, Register t3, Register t4) {
41334
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4518
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4519
  // Save non-volatile vector registers (frameless).
49376
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4520
  Register offset = t1;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4521
  int offsetInt = 0;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4522
  offsetInt -= 16; li(offset, offsetInt); stvx(VR20, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4523
  offsetInt -= 16; li(offset, offsetInt); stvx(VR21, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4524
  offsetInt -= 16; li(offset, offsetInt); stvx(VR22, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4525
  offsetInt -= 16; li(offset, offsetInt); stvx(VR23, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4526
  offsetInt -= 16; li(offset, offsetInt); stvx(VR24, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4527
  offsetInt -= 16; li(offset, offsetInt); stvx(VR25, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4528
#ifndef VM_LITTLE_ENDIAN
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4529
  offsetInt -= 16; li(offset, offsetInt); stvx(VR26, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4530
#endif
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4531
  offsetInt -= 8; std(R14, offsetInt, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4532
  offsetInt -= 8; std(R15, offsetInt, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4533
  offsetInt -= 8; std(R16, offsetInt, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4534
  offsetInt -= 8; std(R17, offsetInt, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4535
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4536
  // Implementation uses an inner loop which uses between 256 and 16 * unroll_factor
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4537
  // bytes per iteration. The basic scheme is:
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4538
  // lvx: load vector (Big Endian needs reversal)
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4539
  // vpmsumw: carry-less 32 bit multiplications with constant representing a large CRC shift
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4540
  // vxor: xor partial results together to get unroll_factor2 vectors
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4541
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4542
  // Outer loop performs the CRC shifts needed to combine the unroll_factor2 vectors.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4543
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4544
  // Using 16 * unroll_factor / unroll_factor_2 bytes for constants.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4545
  const int unroll_factor = 2048;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4546
  const int unroll_factor2 = 8;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4547
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4548
  // Support registers.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4549
  Register offs[] = { noreg, t0, t1, t2, t3, t4, crc /* will live in VCRC */, R14 };
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4550
  Register num_bytes = R15,
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4551
           loop_count = R16,
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4552
           cur_const = R17;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4553
  // Constant array for outer loop: unroll_factor2 - 1 registers,
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4554
  // Constant array for inner loop: unroll_factor / unroll_factor2 registers.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4555
  VectorRegister consts0[] = { VR16, VR17, VR18, VR19, VR20, VR21, VR22 },
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4556
                 consts1[] = { VR23, VR24 };
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4557
  // Data register arrays: 2 arrays with unroll_factor2 registers.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4558
  VectorRegister data0[] = { VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7 },
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4559
                 data1[] = { VR8, VR9, VR10, VR11, VR12, VR13, VR14, VR15 };
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4560
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4561
  VectorRegister VCRC = data0[0];
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4562
  VectorRegister Vc = VR25;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4563
  VectorRegister swap_bytes = VR26; // Only for Big Endian.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4564
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4565
  // We have at least 1 iteration (ensured by caller).
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4566
  Label L_outer_loop, L_inner_loop, L_last;
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4567
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4568
  // If supported set DSCR pre-fetch to deepest.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4569
  if (VM_Version::has_mfdscr()) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4570
    load_const_optimized(t0, VM_Version::_dscr_val | 7);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4571
    mtdscr(t0);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4572
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4573
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4574
  mtvrwz(VCRC, crc); // crc lives lives in VCRC, now
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4575
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4576
  for (int i = 1; i < unroll_factor2; ++i) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4577
    li(offs[i], 16 * i);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4578
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4579
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4580
  // Load consts for outer loop
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4581
  lvx(consts0[0], constants);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4582
  for (int i = 1; i < unroll_factor2 - 1; ++i) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4583
    lvx(consts0[i], offs[i], constants);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4584
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4585
  addi(constants, constants, (unroll_factor2 - 1) * 16);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4586
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4587
  load_const_optimized(num_bytes, 16 * unroll_factor);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4588
  load_const_optimized(loop_count, unroll_factor / (2 * unroll_factor2) - 1); // One double-iteration peeled off.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4589
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4590
  // Reuse data registers outside of the loop.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4591
  VectorRegister Vtmp = data1[0];
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4592
  VectorRegister Vtmp2 = data1[1];
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4593
  VectorRegister zeroes = data1[2];
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4594
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4595
  vspltisb(Vtmp, 0);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4596
  vsldoi(VCRC, Vtmp, VCRC, 8); // 96 bit zeroes, 32 bit CRC.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4597
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4598
  // Load vector for vpermxor (to xor both 64 bit parts together)
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4599
  lvsl(Vtmp, buf);   // 000102030405060708090a0b0c0d0e0f
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4600
  vspltisb(Vc, 4);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4601
  vsl(Vc, Vtmp, Vc); // 00102030405060708090a0b0c0d0e0f0
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4602
  xxspltd(Vc->to_vsr(), Vc->to_vsr(), 0);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4603
  vor(Vc, Vtmp, Vc); // 001122334455667708192a3b4c5d6e7f
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4604
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4605
#ifdef VM_LITTLE_ENDIAN
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4606
#define BE_swap_bytes(x)
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4607
#else
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4608
  vspltisb(Vtmp2, 0xf);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4609
  vxor(swap_bytes, Vtmp, Vtmp2);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4610
#define BE_swap_bytes(x) vperm(x, x, x, swap_bytes)
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4611
#endif
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4612
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4613
  cmpd(CCR0, len, num_bytes);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4614
  blt(CCR0, L_last);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4615
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4616
  // ********** Main loop start **********
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4617
  align(32);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4618
  bind(L_outer_loop);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4619
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4620
  // Begin of unrolled first iteration (no xor).
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4621
  lvx(data1[0], buf);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4622
  mr(cur_const, constants);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4623
  for (int i = 1; i < unroll_factor2 / 2; ++i) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4624
    lvx(data1[i], offs[i], buf);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4625
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4626
  vpermxor(VCRC, VCRC, VCRC, Vc); // xor both halves to 64 bit result.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4627
  lvx(consts1[0], cur_const);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4628
  mtctr(loop_count);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4629
  for (int i = 0; i < unroll_factor2 / 2; ++i) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4630
    BE_swap_bytes(data1[i]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4631
    if (i == 0) { vxor(data1[0], data1[0], VCRC); } // xor in previous CRC.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4632
    lvx(data1[i + unroll_factor2 / 2], offs[i + unroll_factor2 / 2], buf);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4633
    vpmsumw(data0[i], data1[i], consts1[0]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4634
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4635
  addi(buf, buf, 16 * unroll_factor2);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4636
  subf(len, num_bytes, len);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4637
  lvx(consts1[1], offs[1], cur_const);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4638
  addi(cur_const, cur_const, 32);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4639
  // Begin of unrolled second iteration (head).
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4640
  for (int i = 0; i < unroll_factor2 / 2; ++i) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4641
    BE_swap_bytes(data1[i + unroll_factor2 / 2]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4642
    if (i == 0) { lvx(data1[0], buf); } else { lvx(data1[i], offs[i], buf); }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4643
    vpmsumw(data0[i + unroll_factor2 / 2], data1[i + unroll_factor2 / 2], consts1[0]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4644
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4645
  for (int i = 0; i < unroll_factor2 / 2; ++i) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4646
    BE_swap_bytes(data1[i]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4647
    lvx(data1[i + unroll_factor2 / 2], offs[i + unroll_factor2 / 2], buf);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4648
    vpmsumw(data1[i], data1[i], consts1[1]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4649
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4650
  addi(buf, buf, 16 * unroll_factor2);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4651
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4652
  // Generate most performance relevant code. Loads + half of the vpmsumw have been generated.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4653
  // Double-iteration allows using the 2 constant registers alternatingly.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4654
  align(32);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4655
  bind(L_inner_loop);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4656
  for (int j = 1; j < 3; ++j) { // j < unroll_factor / unroll_factor2 - 1 for complete unrolling.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4657
    if (j & 1) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4658
      lvx(consts1[0], cur_const);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4659
    } else {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4660
      lvx(consts1[1], offs[1], cur_const);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4661
      addi(cur_const, cur_const, 32);
41334
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4662
    }
49376
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4663
    for (int i = 0; i < unroll_factor2; ++i) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4664
      int idx = i + unroll_factor2 / 2, inc = 0; // For modulo-scheduled input.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4665
      if (idx >= unroll_factor2) { idx -= unroll_factor2; inc = 1; }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4666
      BE_swap_bytes(data1[idx]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4667
      vxor(data0[i], data0[i], data1[i]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4668
      if (i == 0) lvx(data1[0], buf); else lvx(data1[i], offs[i], buf);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4669
      vpmsumw(data1[idx], data1[idx], consts1[(j + inc) & 1]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4670
    }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4671
    addi(buf, buf, 16 * unroll_factor2);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4672
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4673
  bdnz(L_inner_loop);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4674
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4675
  // Tail of last iteration (no loads).
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4676
  for (int i = 0; i < unroll_factor2 / 2; ++i) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4677
    BE_swap_bytes(data1[i + unroll_factor2 / 2]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4678
    vxor(data0[i], data0[i], data1[i]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4679
    vpmsumw(data1[i + unroll_factor2 / 2], data1[i + unroll_factor2 / 2], consts1[1]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4680
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4681
  for (int i = 0; i < unroll_factor2 / 2; ++i) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4682
    vpmsumw(data0[i], data0[i], consts0[unroll_factor2 - 2 - i]); // First half of fixup shifts.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4683
    vxor(data0[i + unroll_factor2 / 2], data0[i + unroll_factor2 / 2], data1[i + unroll_factor2 / 2]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4684
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4685
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4686
  // Last data register is ok, other ones need fixup shift.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4687
  for (int i = unroll_factor2 / 2; i < unroll_factor2 - 1; ++i) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4688
    vpmsumw(data0[i], data0[i], consts0[unroll_factor2 - 2 - i]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4689
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4690
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4691
  // Combine to 128 bit result vector VCRC = data0[0].
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4692
  for (int i = 1; i < unroll_factor2; i<<=1) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4693
    for (int j = 0; j <= unroll_factor2 - 2*i; j+=2*i) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4694
      vxor(data0[j], data0[j], data0[j+i]);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4695
    }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4696
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4697
  cmpd(CCR0, len, num_bytes);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4698
  bge(CCR0, L_outer_loop);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4699
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4700
  // Last chance with lower num_bytes.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4701
  bind(L_last);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4702
  srdi(loop_count, len, exact_log2(16 * 2 * unroll_factor2)); // Use double-iterations.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4703
  add_const_optimized(constants, constants, 16 * (unroll_factor / unroll_factor2)); // Point behind last one.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4704
  sldi(R0, loop_count, exact_log2(16 * 2)); // Bytes of constants to be used.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4705
  clrrdi(num_bytes, len, exact_log2(16 * 2 * unroll_factor2));
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4706
  subf(constants, R0, constants); // Point to constant to be used first.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4707
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4708
  addic_(loop_count, loop_count, -1); // One double-iteration peeled off.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4709
  bgt(CCR0, L_outer_loop);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4710
  // ********** Main loop end **********
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4711
#undef BE_swap_bytes
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4712
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4713
  // Restore DSCR pre-fetch value.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4714
  if (VM_Version::has_mfdscr()) {
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4715
    load_const_optimized(t0, VM_Version::_dscr_val);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4716
    mtdscr(t0);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4717
  }
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4718
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4719
  vspltisb(zeroes, 0);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4720
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4721
  // Combine to 64 bit result.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4722
  vpermxor(VCRC, VCRC, VCRC, Vc); // xor both halves to 64 bit result.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4723
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4724
  // Reduce to 32 bit CRC: Remainder by multiply-high.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4725
  lvx(Vtmp, barretConstants);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4726
  vsldoi(Vtmp2, zeroes, VCRC, 12);  // Extract high 32 bit.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4727
  vpmsumd(Vtmp2, Vtmp2, Vtmp);      // Multiply by inverse long poly.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4728
  vsldoi(Vtmp2, zeroes, Vtmp2, 12); // Extract high 32 bit.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4729
  vsldoi(Vtmp, zeroes, Vtmp, 8);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4730
  vpmsumd(Vtmp2, Vtmp2, Vtmp);      // Multiply quotient by long poly.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4731
  vxor(VCRC, VCRC, Vtmp2);          // Remainder fits into 32 bit.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4732
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4733
  // Move result. len is already updated.
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4734
  vsldoi(VCRC, VCRC, zeroes, 8);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4735
  mfvrd(crc, VCRC);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4736
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4737
  // Restore non-volatile Vector registers (frameless).
41334
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4738
  offsetInt = 0;
49376
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4739
  offsetInt -= 16; li(offset, offsetInt); lvx(VR20, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4740
  offsetInt -= 16; li(offset, offsetInt); lvx(VR21, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4741
  offsetInt -= 16; li(offset, offsetInt); lvx(VR22, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4742
  offsetInt -= 16; li(offset, offsetInt); lvx(VR23, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4743
  offsetInt -= 16; li(offset, offsetInt); lvx(VR24, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4744
  offsetInt -= 16; li(offset, offsetInt); lvx(VR25, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4745
#ifndef VM_LITTLE_ENDIAN
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4746
  offsetInt -= 16; li(offset, offsetInt); lvx(VR26, offset, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4747
#endif
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4748
  offsetInt -= 8;  ld(R14, offsetInt, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4749
  offsetInt -= 8;  ld(R15, offsetInt, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4750
  offsetInt -= 8;  ld(R16, offsetInt, R1_SP);
7cd503c499a0 8198894: [PPC64] More generic vector CRC implementation
mdoerr
parents: 49347
diff changeset
  4751
  offsetInt -= 8;  ld(R17, offsetInt, R1_SP);
41334
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4752
}
8b28be7b8613 8164920: ppc: enhancement of CRC32 intrinsic
mdoerr
parents: 39444
diff changeset
  4753
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4754
void MacroAssembler::kernel_crc32_singleByte(Register crc, Register buf, Register len, Register table, Register tmp, bool invertCRC) {
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4755
  assert_different_registers(crc, buf, /* len,  not used!! */ table, tmp);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4756
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4757
  BLOCK_COMMENT("kernel_crc32_singleByte:");
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4758
  if (invertCRC) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4759
    nand(crc, crc, crc);                // 1s complement of crc
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4760
  }
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4761
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4762
  lbz(tmp, 0, buf);                     // Byte from buffer, zero-extended.
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4763
  update_byte_crc32(crc, tmp, table);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4764
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4765
  if (invertCRC) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4766
    nand(crc, crc, crc);                // 1s complement of crc
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4767
  }
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4768
}
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4769
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4770
void MacroAssembler::kernel_crc32_singleByteReg(Register crc, Register val, Register table, bool invertCRC) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4771
  assert_different_registers(crc, val, table);
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4772
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4773
  BLOCK_COMMENT("kernel_crc32_singleByteReg:");
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4774
  if (invertCRC) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4775
    nand(crc, crc, crc);                // 1s complement of crc
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4776
  }
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4777
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4778
  update_byte_crc32(crc, val, table);
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4779
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4780
  if (invertCRC) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4781
    nand(crc, crc, crc);                // 1s complement of crc
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
  4782
  }
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4783
}
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4784
31773
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4785
// dest_lo += src1 + src2
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4786
// dest_hi += carry1 + carry2
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4787
void MacroAssembler::add2_with_carry(Register dest_hi,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4788
                                     Register dest_lo,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4789
                                     Register src1, Register src2) {
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4790
  li(R0, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4791
  addc(dest_lo, dest_lo, src1);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4792
  adde(dest_hi, dest_hi, R0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4793
  addc(dest_lo, dest_lo, src2);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4794
  adde(dest_hi, dest_hi, R0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4795
}
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4796
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4797
// Multiply 64 bit by 64 bit first loop.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4798
void MacroAssembler::multiply_64_x_64_loop(Register x, Register xstart,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4799
                                           Register x_xstart,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4800
                                           Register y, Register y_idx,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4801
                                           Register z,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4802
                                           Register carry,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4803
                                           Register product_high, Register product,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4804
                                           Register idx, Register kdx,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4805
                                           Register tmp) {
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4806
  //  jlong carry, x[], y[], z[];
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4807
  //  for (int idx=ystart, kdx=ystart+1+xstart; idx >= 0; idx--, kdx--) {
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4808
  //    huge_128 product = y[idx] * x[xstart] + carry;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4809
  //    z[kdx] = (jlong)product;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4810
  //    carry  = (jlong)(product >>> 64);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4811
  //  }
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4812
  //  z[xstart] = carry;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4813
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4814
  Label L_first_loop, L_first_loop_exit;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4815
  Label L_one_x, L_one_y, L_multiply;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4816
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4817
  addic_(xstart, xstart, -1);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4818
  blt(CCR0, L_one_x);   // Special case: length of x is 1.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4819
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4820
  // Load next two integers of x.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4821
  sldi(tmp, xstart, LogBytesPerInt);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4822
  ldx(x_xstart, x, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4823
#ifdef VM_LITTLE_ENDIAN
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4824
  rldicl(x_xstart, x_xstart, 32, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4825
#endif
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4826
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4827
  align(32, 16);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4828
  bind(L_first_loop);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4829
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4830
  cmpdi(CCR0, idx, 1);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4831
  blt(CCR0, L_first_loop_exit);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4832
  addi(idx, idx, -2);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4833
  beq(CCR0, L_one_y);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4834
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4835
  // Load next two integers of y.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4836
  sldi(tmp, idx, LogBytesPerInt);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4837
  ldx(y_idx, y, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4838
#ifdef VM_LITTLE_ENDIAN
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4839
  rldicl(y_idx, y_idx, 32, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4840
#endif
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4841
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4842
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4843
  bind(L_multiply);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4844
  multiply64(product_high, product, x_xstart, y_idx);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4845
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4846
  li(tmp, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4847
  addc(product, product, carry);         // Add carry to result.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4848
  adde(product_high, product_high, tmp); // Add carry of the last addition.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4849
  addi(kdx, kdx, -2);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4850
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4851
  // Store result.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4852
#ifdef VM_LITTLE_ENDIAN
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4853
  rldicl(product, product, 32, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4854
#endif
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4855
  sldi(tmp, kdx, LogBytesPerInt);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4856
  stdx(product, z, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4857
  mr_if_needed(carry, product_high);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4858
  b(L_first_loop);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4859
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4860
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4861
  bind(L_one_y); // Load one 32 bit portion of y as (0,value).
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4862
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4863
  lwz(y_idx, 0, y);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4864
  b(L_multiply);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4865
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4866
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4867
  bind(L_one_x); // Load one 32 bit portion of x as (0,value).
31773
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4868
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4869
  lwz(x_xstart, 0, x);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4870
  b(L_first_loop);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4871
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4872
  bind(L_first_loop_exit);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4873
}
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4874
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4875
// Multiply 64 bit by 64 bit and add 128 bit.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4876
void MacroAssembler::multiply_add_128_x_128(Register x_xstart, Register y,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4877
                                            Register z, Register yz_idx,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4878
                                            Register idx, Register carry,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4879
                                            Register product_high, Register product,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4880
                                            Register tmp, int offset) {
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4881
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4882
  //  huge_128 product = (y[idx] * x_xstart) + z[kdx] + carry;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4883
  //  z[kdx] = (jlong)product;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4884
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4885
  sldi(tmp, idx, LogBytesPerInt);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4886
  if (offset) {
31773
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4887
    addi(tmp, tmp, offset);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4888
  }
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4889
  ldx(yz_idx, y, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4890
#ifdef VM_LITTLE_ENDIAN
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4891
  rldicl(yz_idx, yz_idx, 32, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4892
#endif
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4893
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4894
  multiply64(product_high, product, x_xstart, yz_idx);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4895
  ldx(yz_idx, z, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4896
#ifdef VM_LITTLE_ENDIAN
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4897
  rldicl(yz_idx, yz_idx, 32, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4898
#endif
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4899
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4900
  add2_with_carry(product_high, product, carry, yz_idx);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4901
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4902
  sldi(tmp, idx, LogBytesPerInt);
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
  4903
  if (offset) {
31773
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4904
    addi(tmp, tmp, offset);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4905
  }
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4906
#ifdef VM_LITTLE_ENDIAN
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4907
  rldicl(product, product, 32, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4908
#endif
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4909
  stdx(product, z, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4910
}
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4911
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4912
// Multiply 128 bit by 128 bit. Unrolled inner loop.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4913
void MacroAssembler::multiply_128_x_128_loop(Register x_xstart,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4914
                                             Register y, Register z,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4915
                                             Register yz_idx, Register idx, Register carry,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4916
                                             Register product_high, Register product,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4917
                                             Register carry2, Register tmp) {
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4918
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4919
  //  jlong carry, x[], y[], z[];
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4920
  //  int kdx = ystart+1;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4921
  //  for (int idx=ystart-2; idx >= 0; idx -= 2) { // Third loop
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4922
  //    huge_128 product = (y[idx+1] * x_xstart) + z[kdx+idx+1] + carry;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4923
  //    z[kdx+idx+1] = (jlong)product;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4924
  //    jlong carry2 = (jlong)(product >>> 64);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4925
  //    product = (y[idx] * x_xstart) + z[kdx+idx] + carry2;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4926
  //    z[kdx+idx] = (jlong)product;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4927
  //    carry = (jlong)(product >>> 64);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4928
  //  }
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4929
  //  idx += 2;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4930
  //  if (idx > 0) {
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4931
  //    product = (y[idx] * x_xstart) + z[kdx+idx] + carry;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4932
  //    z[kdx+idx] = (jlong)product;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4933
  //    carry = (jlong)(product >>> 64);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4934
  //  }
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4935
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4936
  Label L_third_loop, L_third_loop_exit, L_post_third_loop_done;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4937
  const Register jdx = R0;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4938
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4939
  // Scale the index.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4940
  srdi_(jdx, idx, 2);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4941
  beq(CCR0, L_third_loop_exit);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4942
  mtctr(jdx);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4943
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4944
  align(32, 16);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4945
  bind(L_third_loop);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4946
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4947
  addi(idx, idx, -4);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4948
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4949
  multiply_add_128_x_128(x_xstart, y, z, yz_idx, idx, carry, product_high, product, tmp, 8);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4950
  mr_if_needed(carry2, product_high);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4951
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4952
  multiply_add_128_x_128(x_xstart, y, z, yz_idx, idx, carry2, product_high, product, tmp, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4953
  mr_if_needed(carry, product_high);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4954
  bdnz(L_third_loop);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4955
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4956
  bind(L_third_loop_exit);  // Handle any left-over operand parts.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4957
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4958
  andi_(idx, idx, 0x3);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4959
  beq(CCR0, L_post_third_loop_done);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4960
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4961
  Label L_check_1;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4962
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4963
  addic_(idx, idx, -2);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4964
  blt(CCR0, L_check_1);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4965
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4966
  multiply_add_128_x_128(x_xstart, y, z, yz_idx, idx, carry, product_high, product, tmp, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4967
  mr_if_needed(carry, product_high);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4968
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4969
  bind(L_check_1);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4970
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4971
  addi(idx, idx, 0x2);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  4972
  andi_(idx, idx, 0x1);
31773
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4973
  addic_(idx, idx, -1);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4974
  blt(CCR0, L_post_third_loop_done);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4975
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4976
  sldi(tmp, idx, LogBytesPerInt);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4977
  lwzx(yz_idx, y, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4978
  multiply64(product_high, product, x_xstart, yz_idx);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4979
  lwzx(yz_idx, z, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4980
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4981
  add2_with_carry(product_high, product, yz_idx, carry);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4982
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4983
  sldi(tmp, idx, LogBytesPerInt);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4984
  stwx(product, z, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4985
  srdi(product, product, 32);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4986
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4987
  sldi(product_high, product_high, 32);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4988
  orr(product, product, product_high);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4989
  mr_if_needed(carry, product);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4990
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4991
  bind(L_post_third_loop_done);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4992
}   // multiply_128_x_128_loop
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  4993
47521
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  4994
void MacroAssembler::muladd(Register out, Register in,
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  4995
                            Register offset, Register len, Register k,
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  4996
                            Register tmp1, Register tmp2, Register carry) {
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  4997
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  4998
  // Labels
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  4999
  Label LOOP, SKIP;
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5000
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5001
  // Make sure length is positive.
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5002
  cmpdi  (CCR0,    len,     0);
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5003
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5004
  // Prepare variables
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5005
  subi   (offset,  offset,  4);
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5006
  li     (carry,   0);
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5007
  ble    (CCR0,    SKIP);
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5008
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5009
  mtctr  (len);
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5010
  subi   (len,     len,     1    );
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5011
  sldi   (len,     len,     2    );
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5012
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5013
  // Main loop
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5014
  bind(LOOP);
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5015
  lwzx   (tmp1,    len,     in   );
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5016
  lwzx   (tmp2,    offset,  out  );
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5017
  mulld  (tmp1,    tmp1,    k    );
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5018
  add    (tmp2,    carry,   tmp2 );
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5019
  add    (tmp2,    tmp1,    tmp2 );
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5020
  stwx   (tmp2,    offset,  out  );
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5021
  srdi   (carry,   tmp2,    32   );
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5022
  subi   (offset,  offset,  4    );
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5023
  subi   (len,     len,     4    );
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5024
  bdnz   (LOOP);
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5025
  bind(SKIP);
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5026
}
122833427b36 8185976: PPC64: Implement MulAdd and SquareToLen intrinsics
goetz
parents: 47520
diff changeset
  5027
31773
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5028
void MacroAssembler::multiply_to_len(Register x, Register xlen,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5029
                                     Register y, Register ylen,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5030
                                     Register z, Register zlen,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5031
                                     Register tmp1, Register tmp2,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5032
                                     Register tmp3, Register tmp4,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5033
                                     Register tmp5, Register tmp6,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5034
                                     Register tmp7, Register tmp8,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5035
                                     Register tmp9, Register tmp10,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5036
                                     Register tmp11, Register tmp12,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5037
                                     Register tmp13) {
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5038
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5039
  ShortBranchVerifier sbv(this);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5040
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5041
  assert_different_registers(x, xlen, y, ylen, z, zlen,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5042
                             tmp1, tmp2, tmp3, tmp4, tmp5, tmp6);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5043
  assert_different_registers(x, xlen, y, ylen, z, zlen,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5044
                             tmp1, tmp2, tmp3, tmp4, tmp5, tmp7);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5045
  assert_different_registers(x, xlen, y, ylen, z, zlen,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5046
                             tmp1, tmp2, tmp3, tmp4, tmp5, tmp8);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5047
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5048
  const Register idx = tmp1;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5049
  const Register kdx = tmp2;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5050
  const Register xstart = tmp3;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5051
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5052
  const Register y_idx = tmp4;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5053
  const Register carry = tmp5;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5054
  const Register product = tmp6;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5055
  const Register product_high = tmp7;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5056
  const Register x_xstart = tmp8;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5057
  const Register tmp = tmp9;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5058
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5059
  // First Loop.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5060
  //
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5061
  //  final static long LONG_MASK = 0xffffffffL;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5062
  //  int xstart = xlen - 1;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5063
  //  int ystart = ylen - 1;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5064
  //  long carry = 0;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5065
  //  for (int idx=ystart, kdx=ystart+1+xstart; idx >= 0; idx-, kdx--) {
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5066
  //    long product = (y[idx] & LONG_MASK) * (x[xstart] & LONG_MASK) + carry;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5067
  //    z[kdx] = (int)product;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5068
  //    carry = product >>> 32;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5069
  //  }
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5070
  //  z[xstart] = (int)carry;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5071
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5072
  mr_if_needed(idx, ylen);        // idx = ylen
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5073
  mr_if_needed(kdx, zlen);        // kdx = xlen + ylen
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5074
  li(carry, 0);                   // carry = 0
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5075
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5076
  Label L_done;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5077
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5078
  addic_(xstart, xlen, -1);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5079
  blt(CCR0, L_done);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5080
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5081
  multiply_64_x_64_loop(x, xstart, x_xstart, y, y_idx, z,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5082
                        carry, product_high, product, idx, kdx, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5083
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5084
  Label L_second_loop;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5085
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5086
  cmpdi(CCR0, kdx, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5087
  beq(CCR0, L_second_loop);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5088
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5089
  Label L_carry;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5090
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5091
  addic_(kdx, kdx, -1);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5092
  beq(CCR0, L_carry);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5093
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5094
  // Store lower 32 bits of carry.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5095
  sldi(tmp, kdx, LogBytesPerInt);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5096
  stwx(carry, z, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5097
  srdi(carry, carry, 32);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5098
  addi(kdx, kdx, -1);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5099
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5100
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5101
  bind(L_carry);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5102
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5103
  // Store upper 32 bits of carry.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5104
  sldi(tmp, kdx, LogBytesPerInt);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5105
  stwx(carry, z, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5106
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5107
  // Second and third (nested) loops.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5108
  //
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5109
  //  for (int i = xstart-1; i >= 0; i--) { // Second loop
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5110
  //    carry = 0;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5111
  //    for (int jdx=ystart, k=ystart+1+i; jdx >= 0; jdx--, k--) { // Third loop
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5112
  //      long product = (y[jdx] & LONG_MASK) * (x[i] & LONG_MASK) +
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5113
  //                     (z[k] & LONG_MASK) + carry;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5114
  //      z[k] = (int)product;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5115
  //      carry = product >>> 32;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5116
  //    }
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5117
  //    z[i] = (int)carry;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5118
  //  }
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5119
  //
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5120
  //  i = xlen, j = tmp1, k = tmp2, carry = tmp5, x[i] = rdx
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5121
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5122
  bind(L_second_loop);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5123
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5124
  li(carry, 0);                   // carry = 0;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5125
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5126
  addic_(xstart, xstart, -1);     // i = xstart-1;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5127
  blt(CCR0, L_done);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5128
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5129
  Register zsave = tmp10;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5130
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5131
  mr(zsave, z);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5132
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5133
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5134
  Label L_last_x;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5135
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5136
  sldi(tmp, xstart, LogBytesPerInt);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5137
  add(z, z, tmp);                 // z = z + k - j
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5138
  addi(z, z, 4);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5139
  addic_(xstart, xstart, -1);     // i = xstart-1;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5140
  blt(CCR0, L_last_x);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5141
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5142
  sldi(tmp, xstart, LogBytesPerInt);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5143
  ldx(x_xstart, x, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5144
#ifdef VM_LITTLE_ENDIAN
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5145
  rldicl(x_xstart, x_xstart, 32, 0);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5146
#endif
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5147
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5148
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5149
  Label L_third_loop_prologue;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5150
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5151
  bind(L_third_loop_prologue);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5152
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5153
  Register xsave = tmp11;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5154
  Register xlensave = tmp12;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5155
  Register ylensave = tmp13;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5156
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5157
  mr(xsave, x);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5158
  mr(xlensave, xstart);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5159
  mr(ylensave, ylen);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5160
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5161
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5162
  multiply_128_x_128_loop(x_xstart, y, z, y_idx, ylen,
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5163
                          carry, product_high, product, x, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5164
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5165
  mr(z, zsave);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5166
  mr(x, xsave);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5167
  mr(xlen, xlensave);   // This is the decrement of the loop counter!
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5168
  mr(ylen, ylensave);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5169
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5170
  addi(tmp3, xlen, 1);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5171
  sldi(tmp, tmp3, LogBytesPerInt);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5172
  stwx(carry, z, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5173
  addic_(tmp3, tmp3, -1);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5174
  blt(CCR0, L_done);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5175
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5176
  srdi(carry, carry, 32);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5177
  sldi(tmp, tmp3, LogBytesPerInt);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5178
  stwx(carry, z, tmp);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5179
  b(L_second_loop);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5180
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5181
  // Next infrequent code is moved outside loops.
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5182
  bind(L_last_x);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5183
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5184
  lwz(x_xstart, 0, x);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5185
  b(L_third_loop_prologue);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5186
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5187
  bind(L_done);
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 30764
diff changeset
  5188
}   // multiply_to_len
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5189
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5190
void MacroAssembler::asm_assert(bool check_equal, const char *msg, int id) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5191
#ifdef ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5192
  Label ok;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5193
  if (check_equal) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5194
    beq(CCR0, ok);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5195
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5196
    bne(CCR0, ok);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5197
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5198
  stop(msg, id);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5199
  bind(ok);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5200
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5201
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5202
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5203
void MacroAssembler::asm_assert_mems_zero(bool check_equal, int size, int mem_offset,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5204
                                          Register mem_base, const char* msg, int id) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5205
#ifdef ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5206
  switch (size) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5207
    case 4:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5208
      lwz(R0, mem_offset, mem_base);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5209
      cmpwi(CCR0, R0, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5210
      break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5211
    case 8:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5212
      ld(R0, mem_offset, mem_base);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5213
      cmpdi(CCR0, R0, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5214
      break;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5215
    default:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5216
      ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5217
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5218
  asm_assert(check_equal, msg, id);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5219
#endif // ASSERT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5220
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5221
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5222
void MacroAssembler::verify_thread() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5223
  if (VerifyThread) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5224
    unimplemented("'VerifyThread' currently not implemented on PPC");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5225
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5226
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5227
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5228
// READ: oop. KILL: R0. Volatile floats perhaps.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5229
void MacroAssembler::verify_oop(Register oop, const char* msg) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5230
  if (!VerifyOops) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5231
    return;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5232
  }
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  5233
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22852
diff changeset
  5234
  address/* FunctionDescriptor** */fd = StubRoutines::verify_oop_subroutine_entry_address();
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  5235
  const Register tmp = R11; // Will be preserved.
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5236
  const int nbytes_save = MacroAssembler::num_volatile_regs * 8;
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  5237
  save_volatile_gprs(R1_SP, -nbytes_save); // except R0
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  5238
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5239
  mr_if_needed(R4_ARG2, oop);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  5240
  save_LR_CR(tmp); // save in old frame
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  5241
  push_frame_reg_args(nbytes_save, tmp);
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  5242
  // load FunctionDescriptor** / entry_address *
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  5243
  load_const_optimized(tmp, fd, R0);
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22867
diff changeset
  5244
  // load FunctionDescriptor* / entry_address
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5245
  ld(tmp, 0, tmp);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5246
  load_const_optimized(R3_ARG1, (address)msg, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5247
  // Call destination for its side effect.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5248
  call_c(tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5249
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5250
  pop_frame();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5251
  restore_LR_CR(tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5252
  restore_volatile_gprs(R1_SP, -nbytes_save); // except R0
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5253
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5254
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5255
void MacroAssembler::verify_oop_addr(RegisterOrConstant offs, Register base, const char* msg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5256
  if (!VerifyOops) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5257
    return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5258
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5259
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5260
  address/* FunctionDescriptor** */fd = StubRoutines::verify_oop_subroutine_entry_address();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5261
  const Register tmp = R11; // Will be preserved.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5262
  const int nbytes_save = MacroAssembler::num_volatile_regs * 8;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5263
  save_volatile_gprs(R1_SP, -nbytes_save); // except R0
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5264
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5265
  ld(R4_ARG2, offs, base);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5266
  save_LR_CR(tmp); // save in old frame
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5267
  push_frame_reg_args(nbytes_save, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5268
  // load FunctionDescriptor** / entry_address *
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5269
  load_const_optimized(tmp, fd, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5270
  // load FunctionDescriptor* / entry_address
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 34148
diff changeset
  5271
  ld(tmp, 0, tmp);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  5272
  load_const_optimized(R3_ARG1, (address)msg, R0);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  5273
  // Call destination for its side effect.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5274
  call_c(tmp);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  5275
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5276
  pop_frame();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5277
  restore_LR_CR(tmp);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27012
diff changeset
  5278
  restore_volatile_gprs(R1_SP, -nbytes_save); // except R0
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5279
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5280
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5281
const char* stop_types[] = {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5282
  "stop",
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5283
  "untested",
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5284
  "unimplemented",
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5285
  "shouldnotreachhere"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5286
};
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5287
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5288
static void stop_on_request(int tp, const char* msg) {
25374
d7fb2af5d53c 8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents: 23492
diff changeset
  5289
  tty->print("PPC assembly code requires stop: (%s) %s\n", stop_types[tp%/*stop_end*/4], msg);
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32596
diff changeset
  5290
  guarantee(false, "PPC assembly code requires stop: %s", msg);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5291
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5292
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5293
// Call a C-function that prints output.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5294
void MacroAssembler::stop(int type, const char* msg, int id) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5295
#ifndef PRODUCT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5296
  block_comment(err_msg("stop: %s %s {", stop_types[type%stop_end], msg));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5297
#else
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5298
  block_comment("stop {");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5299
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5300
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5301
  // setup arguments
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5302
  load_const_optimized(R3_ARG1, type);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5303
  load_const_optimized(R4_ARG2, (void *)msg, /*tmp=*/R0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5304
  call_VM_leaf(CAST_FROM_FN_PTR(address, stop_on_request), R3_ARG1, R4_ARG2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5305
  illtrap();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5306
  emit_int32(id);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5307
  block_comment("} stop;");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5308
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5309
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5310
#ifndef PRODUCT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5311
// Write pattern 0x0101010101010101 in memory region [low-before, high+after].
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5312
// Val, addr are temp registers.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5313
// If low == addr, addr is killed.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5314
// High is preserved.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5315
void MacroAssembler::zap_from_to(Register low, int before, Register high, int after, Register val, Register addr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5316
  if (!ZapMemory) return;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5317
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5318
  assert_different_registers(low, val);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5319
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5320
  BLOCK_COMMENT("zap memory region {");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5321
  load_const_optimized(val, 0x0101010101010101);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5322
  int size = before + after;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5323
  if (low == high && size < 5 && size > 0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5324
    int offset = -before*BytesPerWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5325
    for (int i = 0; i < size; ++i) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5326
      std(val, offset, low);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5327
      offset += (1*BytesPerWord);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5328
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5329
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5330
    addi(addr, low, -before*BytesPerWord);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5331
    assert_different_registers(high, val);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5332
    if (after) addi(high, high, after * BytesPerWord);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5333
    Label loop;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5334
    bind(loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5335
    std(val, 0, addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5336
    addi(addr, addr, 8);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5337
    cmpd(CCR6, addr, high);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5338
    ble(CCR6, loop);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5339
    if (after) addi(high, high, -after * BytesPerWord);  // Correct back to old value.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5340
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5341
  BLOCK_COMMENT("} zap memory region");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5342
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5343
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
  5344
#endif // !PRODUCT
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  5345
48476
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  5346
void SkipIfEqualZero::skip_to_label_if_equal_zero(MacroAssembler* masm, Register temp,
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  5347
                                                  const bool* flag_addr, Label& label) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  5348
  int simm16_offset = masm->load_const_optimized(temp, (address)flag_addr, R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  5349
  assert(sizeof(bool) == 1, "PowerPC ABI");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  5350
  masm->lbz(temp, simm16_offset, temp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  5351
  masm->cmpwi(CCR0, temp, 0);
48476
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  5352
  masm->beq(CCR0, label);
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  5353
}
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  5354
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  5355
SkipIfEqualZero::SkipIfEqualZero(MacroAssembler* masm, Register temp, const bool* flag_addr) : _masm(masm), _label() {
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  5356
  skip_to_label_if_equal_zero(masm, temp, flag_addr, _label);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  5357
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  5358
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  5359
SkipIfEqualZero::~SkipIfEqualZero() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  5360
  _masm->bind(_label);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents: 23211
diff changeset
  5361
}